| name | auto-merge |
| description | Auto-merge a PR after it is marked ready-for-review, if the change is small, non-disruptive, and all checks pass. |
| license | Apache-2.0 |
| metadata | {"audience":"autonomous-agents"} |
Auto-merge
Merge a PR that was just promoted from draft to ready-for-review,
only when the change is small, non-disruptive, and every required
check is green. This skill is the natural successor to mark-pr-ready.
When to load this skill
Load after the mark-pr-ready skill has run (or after a
pull_request.ready_for_review event). Do not load it for PRs
that were created as ready-for-review from the start — only for PRs
that transitioned from draft.
Preconditions (all must be true)
- The PR is open and marked ready for review (not draft).
- The PR targets the repo's default branch.
- All CI checks have completed and passed.
- The diff is small and non-disruptive (see size gate below).
- No reviewer has requested changes.
- No unresolved review threads.
- At least 10 minutes have passed since the PR was marked ready
for review, with no new reviewer comments or change requests
during that window.
If any precondition fails, stop — do not merge. For precondition 7,
if the quiet period hasn't elapsed yet, schedule a one-shot follow-up
for the remaining time (Flue Durable Object scheduleFollowUp /
platform schedule(), or a run_once timer when running in-container)
and stop. The follow-up will re-trigger this skill when the period is up.
Size gate
Classify the PR as "small and non-disruptive" only when all of
these hold:
- Total lines changed (additions + deletions) ≤ 150.
- No more than 5 files changed.
- No changes to CI/CD configuration (
.github/workflows/, Dockerfile,
docker-compose*, Makefile, Justfile, Terraform *.tf).
- No changes to dependency lockfiles (
bun.lock, package-lock.json,
yarn.lock, pnpm-lock.yaml, Cargo.lock, go.sum).
- No database migrations or schema changes.
- No changes to authentication, authorization, or secrets handling.
- No deletions of public API surface (exported functions, REST
endpoints, GraphQL types).
If the PR exceeds the size gate, stop. Post a comment noting the PR
needs human review and list which criteria it exceeded.
Workflow
-
Check quiet period. Verify the PR was marked ready at least
10 minutes ago with no reviewer activity since:
READY_AT=$(gh api "repos/<owner>/<repo>/issues/<N>/timeline" --paginate \
--jq '[.[] | select(.event=="ready_for_review")] | last | .created_at')
Calculate elapsed time. If less than 10 minutes have passed,
schedule a one-shot follow-up (Flue DO scheduleFollowUp / platform
schedule(), or in-container timer) for the remaining time with
entity_key set to the PR entity, and stop. The follow-up prompt
should instruct the agent to reload the auto-merge skill.
Also check for any reviewer comments or changes_requested
reviews that arrived after READY_AT:
gh api "repos/<owner>/<repo>/pulls/<N>/reviews" \
--jq '[.[] | select(.submitted_at > "'$READY_AT'" and .state != "APPROVED" and .state != "COMMENTED")]'
If any exist, stop — the PR needs human attention.
-
Verify PR state and target branch:
PR_JSON=$(gh pr view <N> --json state,isDraft,baseRefName)
STATE=$(echo "$PR_JSON" | jq -r '.state')
IS_DRAFT=$(echo "$PR_JSON" | jq -r '.isDraft')
BASE=$(echo "$PR_JSON" | jq -r '.baseRefName')
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
- Expect
STATE=OPEN, IS_DRAFT=false. If draft or closed, stop.
- Expect
BASE == DEFAULT_BRANCH. If the PR targets a release or
other protected branch, stop — those need human review.
-
Verify all checks pass:
CHECKS=$(gh pr view <N> --json statusCheckRollup \
--jq )
When NOT to merge
- The PR has "CHANGES_REQUESTED" reviews.
- The PR has unresolved review threads.
- The PR modifies security-sensitive code.
- The PR exceeds the size gate.
- Any required check is not green.
- Any check is still running (not yet completed).
- The PR targets a branch other than the repo's default branch.
In all these cases, leave a comment explaining why auto-merge was
skipped, and let a human decide.
Notes
- This skill should be loaded by the coordinator after
mark-pr-ready
completes, or in response to a pull_request.ready_for_review webhook.
- The
--auto flag on gh pr merge respects branch protection rules.
If the repo requires approvals, the merge will wait until those are
satisfied.
- Never force-merge or bypass branch protection.