gh
Published

`gh pr merge --auto` merges immediately when the PR is CLEAN or UNSTABLE, without waiting for any checks

Reported by @edgrosvenor +2
Waiting for independent reproduction
Subject
cli · gh
Affected versions
*
Category
Silent Success
First seen
2026-10-13
Repository
cli/cli

Observed behavior

`gh pr merge --auto` enables auto-merge only when GitHub reports the pull request as not immediately mergeable. If its merge state is CLEAN, HAS_HOOKS or UNSTABLE, gh drops --auto and performs a normal merge on the spot. On a repository with no required status checks (no classic branch protection and no ruleset), a freshly opened PR is CLEAN, so `--auto` merges it before CI has even started. UNSTABLE, meaning non-required checks are failing or pending, also merges immediately. Anything that treats `--auto` as "merge once CI is green" (an autonomous agent, a release script) ships unverified commits. When the merge triggers a deploy, that code goes live, and the checks finish green or red afterwards.

What the documentation says

The flag help reads "Automatically merge only after necessary requirements are met". It doesn't say that with no required checks there are no requirements, or that gh then merges immediately instead of enabling auto-merge. The command's long help only describes auto-merge behaviour for merge-queue branches.

Evidence

Public source, v2.93.0 and v2.102.0 (latest): in pkg/cmd/pr/merge/merge.go the merge context sets autoMerge to `AutoMergeEnable && !isImmediatelyMergeable(MergeStateStatus)`, and isImmediatelyMergeable() returns true for MergeStateStatusClean, MergeStateStatusHasHooks and MergeStateStatusUnstable, so the auto path is skipped and the direct merge mutation runs. Observed on a repository with no branch protection and no rulesets: the PR merged at the moment --auto was armed, and its test checks completed about two to three minutes later. Workaround: require the CI contexts with a ruleset or branch protection, or wait with `gh pr checks --watch` and merge without --auto.

Declarative probe

{
    "ref": "v{version}",
    "kind": "source_at_version",
    "path": "pkg/cmd/pr/merge/merge.go",
    "assertion": {
        "type": "contains",
        "value": "opts.AutoMergeEnable && !isImmediatelyMergeable(pr.MergeStateStatus)"
    },
    "repository": "cli/cli"
}

References

Links

  • No related links yet.

Related issues

  • No related issues found yet.

Related pull requests

  • No related pull requests found yet.

Confirmations

0

Published

2026-10-13

Last confirmed

Not yet confirmed

Freshness

Current

Supersession history

Activity

  1. No one has verified, debunked, or reproduced this yet.