github/pr-finisher
Prepare an open pull request for merge from a GitHub Copilot cloud agent. Drives Reviews, local validation, and Mergeable to a ready state. Does not merge, and cannot trigger CI.
npx skills add https://github.com/github/gh-aw --skill pr-finisher
Drive an open PR for the current branch to a merge-ready state from a GitHub Copilot cloud agent. Do not merge. When everything you can act on is done, report ready-for-human-merge and stop.
This skill runs inside a GitHub Copilot cloud agent, not on a developer's machine.
statusCheckRollup reflects an earlier HEAD and goes stale the moment the agent pushes.workflow_dispatch, or a push from a maintainer). The agent must surface this in its summary.A PR is merge-ready when all three are satisfied. Work them concurrently.
| Condition | Definition | Agent's signal |
|---|---|---|
| Reviews | Every unresolved in-scope review thread is addressed on its merits, replied to, and resolved, including GitHub Actions bot threads/comments (github-actions[bot]). Code changes alone do not satisfy this. | copilot-review skill + GraphQL reviewThreads |
| Checks | Local npm run build / npm run lint / npm test pass. Last-known CI runs reviewed at log level. | npm scripts locally; gh pr checks / gh run view --log-failed for prior runs |
| Mergeable | PR is OPEN, not draft, mergeable: MERGEABLE, not BEHIND if the repo requires up-to-date branches. | gh pr view --json mergeable,mergeStateStatus,state,isDraft |
Because the agent cannot re-trigger CI, "Checks" is satisfied at the agent's level when local validation passes and prior CI failures have been root-caused and fixed in the pushed commits. Final green CI requires a human to re-trigger after the agent stops.
Top-level PR comments and review bodies are useful feedback but not a merge gate. Read and action useful ones; do not block on them.
gh pr merge, enable auto-merge, or enqueue. This skill stops at "ready for merge."gh: prefix with GH_PAGER="" or pipe through cat. Without this, commands hang in non-interactive shells.bash sleep, no gh run watch, no gh pr checks --watch, no re-check loop after push. The agent's pushes will not trigger workflows; waiting is futile.npm run build && npm run lint && npm test locally. Treat a green local run as the bar.A failing CI step is a signal, not a nuisance. Even though the agent cannot re-run CI to confirm, the following are forbidden and should trigger ask_user instead:
Anti-pattern test: if the change would make the failure invisible on future PRs without solving it, stop and escalate.
Before declaring a tool broken on a platform: reproduce locally, check version/config, look for transient causes (timeouts, network, runner state). Most "X is broken on macOS/Windows" reports are transient flakes on healthy tooling.
For flaky infra (caches, registries, runners): prefer narrow fixes — targeted retry, higher timeout, pre-flight health check. If a narrow fix doesn't land in one or two attempts, escalate via ask_user.
The agent runs this once. There is no monitoring loop.
GH_PAGER="" gh pr view <number> --json state,isDraft,reviewDecision,mergeable,mergeStateStatus,statusCheckRollup,headRefOid
GH_PAGER="" gh pr checks <number>
If merged/closed, report and stop. Otherwise classify each condition as ✅ / ❌ / ⏳ / ❓. The CI snapshot here is your only view of CI for this run — capture which checks failed and why before changing anything, because after you push it will be stale.
Delegate to the copilot-review skill and treat that delegation as mandatory, not optional. Insist on full handling of each unresolved in-scope thread (including github-actions[bot]): make change → run relevant local validation → commit → push → reply → resolve. A thread is not handled until reply + resolve both succeed.
Before editing, gather the full review surface with explicit GH queries:
GH_PAGER="" gh pr view <number> --json reviews,reviewThreads,comments
GH_PAGER="" gh pr view <number> --json reviewThreads --jq '.reviewThreads[] | select(.isResolved==false)'
When reviewing collected feedback, apply reviewer scoping from copilot-review: trusted automation and team/collaborator reviewers only. Ignore non-team-member feedback.
GH_PAGER="" gh pr view <number> --json mergeable,mergeStateStatus
CONFLICTING → resolve conflicts using the repo's conventions. If you cannot determine the correct resolution, ask_user.mergeStateStatus: BEHIND → update branch from base. After updating, scan the new commits for tooling drift (lockfiles, toolchains, lint configs); re-run npm install if package.json or package-lock.json changed, and flag drift in the summary so any new errors read as drift, not regressions.Local validation — the agent's only correctness signal. Run in order; fix at each step before moving on:
npm run build
npm run lint
npm test
If workflow lock files need regeneration (e.g., after a gh-aw version bump or .md workflow source change):
gh aw compile
npx ts-node scripts/ci/postprocess-smoke-workflows.ts
Then re-run npm test to verify.
Prior CI failures — for each failure captured during triage, pull logs and fix the root cause:
GH_PAGER="" gh run view <run_id> --log-failed
Classify as: real product/test bug, infra flake, or third-party flake. Apply the fix in the agent's commits and, where possible, reproduce the fix locally via the matching npm script. If the failure can't be reproduced locally (infra-only), state that in the summary so the human re-triggers CI with eyes open. Per anti-pattern rules: 1–2 narrow attempts, then ask_user.
After each iteration that changes files, commit and push immediately. Before stopping, ensure there are no uncommitted or unpushed changes left. Do not re-check gh pr checks expecting a new run. Print the summary and stop.
At the stopping point, print:
- ✅ Reviews — <plain language>
- ✅ Checks (local) — <plain language>
- <status> Checks (CI) — stale after agent push; needs human re-trigger. Prior failures: <fixed | open | not reproducible locally>
- ✅ Mergeable — <plain language>
Actions taken: <what changed in this run>
Hand-off: CI must be re-triggered by a maintainer (close/reopen PR, workflow_dispatch, or push) before merge.
Still needed: <human review, anything not actionable from the agent>
Status vocabulary:
Translate status into plain language. Don't write bare labels. Always state explicitly that CI on the agent's HEAD is unverified until a human re-triggers it.
ask_user with context.The task is complete only when all are true:
npm run build, npm run lint, npm test all pass (or unrelated pre-existing failures explicitly identified).copilot-review skill addressed all in-scope review threads, including GitHub Actions bot review comments/threads (github-actions[bot]) (reply + resolve succeeded for each).BEHIND updated when present.gh pr merge was run.Take github/pr-finisher from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npm, npx.
Without those the skill loads but fails at the first command.