| name | merge |
| description | PR autopilot: create/manage PRs, enforce CI gates, apply surgical fixes, and squash-merge via `gh`. |
Merge
Intent
Run a continuous PR operator: keep PRs created, green, reviewed, and squash-merged (via gh) with minimal-incision fixes.
Quick start
- Ensure
gh auth statussucceeds. - Ensure labels exist:
auto:manage,auto:hold. - (Optional) Add
.github/auto-merge.ymlfromassets/auto-merge.yml. - Start the monitor loop.
Label contract
auto:manage: opt-in to automation.auto:hold: pause automation.
Contributor guidance:
- Add
auto:manageto opt in. - Add
auto:holdto stop the operator.
PR creation policy
- For every non-default branch without an open PR, create a PR.
- Use the repo PR template if present; else use
assets/pr-template.md. - Prefer
gh pr create --filland applyauto:manage. - Default to ready-for-review (no drafts unless configured).
Monitor loop
Repeat with adaptive polling:
- List open PRs:
gh pr list --state open --json number,title,headRefName,labels,isDraft. - For each PR:
- Skip if
auto:hold. - Skip if not
auto:manageand not agent-created. - If draft, mark ready:
gh pr ready. - Ensure branch is up to date.
- Enforce CI gate.
- If failing, run the surgical fix loop.
- When green, auto-approve and squash-merge.
- Skip if
CI gate
- Treat any pending or failing check as a hard block.
- Use:
gh pr checks,gh run list,gh run watch.
Surgical fix loop
Smallest change that makes CI green:
- Read the failure from CI logs.
- Apply the minimal fix on the PR branch.
- Commit with a terse message (e.g.,
fix(ci): <cause>). - Push and re-check.
- Limit attempts (default 3). On exhaustion or hard conflicts:
- Leave a summary comment.
- Request changes as last resort.
- Apply
auto:hold.
Branch updates (jj-first)
- Prefer
jjfor writes; fall back togitonly when needed. - Rebase onto the default branch; force-push only when required.
Merge
- When checks are green and no hold:
- Approve:
gh pr review --approve. - Squash-merge:
gh pr merge --squash.
- Approve:
Adaptive polling
- Poll under 60s unless CI is slow.
- Use recent CI duration to back off (cap at 120s).
- Exponential backoff on API errors.
Status reporting
- Maintain a single PR comment/check-run named
AutoMerge Operator. - Update in place (avoid comment spam).
Recipes
- Create:
gh pr create --fill --head <branch> --label auto:manage - Checks:
gh pr checks <num> - Merge:
gh pr merge <num> --squash
Assets
assets/auto-merge.ymlassets/pr-template.md