Catalogue / merge-github-pr
merge-github-pr
MITSignedUse when safely merge GitHub pull requests that are ready--- name: merge-github-pr description: Use when safely merge GitHub pull requests that are ready license: MIT metadata: author: Petr Král (pekral.cz) ---
Entry contract: from this skill directory, read the file printed by bash ../_shared/resolve-command-helper.sh --entry.
Constraints
- Apply @rules/git/general.md
- Never merge a PR without a converged code review. A code review must have been run on the PR's final diff and report no errors — 0 Critical, and no undeferred Moderate. A Moderate is either fixed in the review loop or, at the cap round only, deferred into a tracker sub-issue; a security-relevant Moderate (the S1–S3 carve-out) never defers and always blocks. This is the hard merge gate from
@rules/git/pull-requests.md*Merging*, verified in step 2. Its exemptions are a `FAST`-tier PR, a dependency-only PR (@rules/git/pull-requests.md*FAST-tier pull requests*, *Dependency-only pull requests*), and the opt-in low-risk path, which replaces it, qualified in step 2. - Never merge PRs with conflicts
- Never merge PRs with failing CI — the only sanctioned relaxation is the *GitHub Actions billing exception* below; no other explicit instruction, including "merge anytime", overrides a real CI failure
- Never bypass required approvals or protections. The approval check is
@rules/git/pull-requests.md*Merging* (a GitHub approval, the converged code review, or on the low-risk path its confirmed evidence);CHANGES_REQUESTEDblocks, and a GitHub refusal stops the run — never--admin - This skill never hands a merge to
@skills/merge-github-pr-fast/SKILL.md. That skill is the user's own explicit/merge-github-pr-fastcommand (@rules/git/pull-requests.md*Fast hotfix merge — an explicit, owner-invoked exception*), and no caller of this skill chooses it - Every merge holds a passing full quality-gate run on the exact head commit being merged (*Pre-merge quality gate*) — accepted from the run recorded by
the command workflow*Finalization* for those exact bytes, carried forward from an earlier head after a rebase that only moved the base (@skills/resolve-issue/references/quality-gates.md*Rebase that moves the head — analyse the incoming changes first*, with CI green on the merged head), or executed here; a merge never proceeds without one - The only tolerated CI failure is a GitHub Actions billing / account-limit error, and only because that same gate run stands in for the missing CI signal. An explicit "merge anytime" request waives waiting for CI, never the gate (see *GitHub Actions billing exception* below). Any other failure — real test failure, lint, static analysis — still blocks.
---
Execution
1. Load PRs
- Identify candidate PRs ready for merge
- Repository ownership (hard gate, runs first) — for each candidate, confirm the PR belongs to the current checkout (
references/trusted-record-parser.md*The trusted ownership check*): compare the remotes before any clone, then run the trusted copy ofskills/_shared/assert-current-repo.sh <URL>. Exit code4means the PR lives in a different repository: stop, report the mismatch, and never merge it. Exit code5means ownership could not be proven: stop and tell the caller to run from inside the target checkout.
Only a zero exit permits the flow to continue — every non-zero exit and an unavailable copy are a hard stop, and the deterministic loader's "exit 2/3 → fall back to the MCP server" convention never applies to this guard: there is no fallback for an ownership verdict.
- For each candidate, load PR context by running the trusted copy of
skills/code-review-github/scripts/load-issue.sh <URL>(references/trusted-record-parser.md) with the full GitHub PR URL, never a bare number. Never callgh pr view,gh pr checks, orgh api /repos/.../pulls/...directly; the one exception is the wait read in@rules/git/pull-requests.md*Waiting for CI — read the checks every 3 minutes*. ReadisDraft,isCrossRepository,mergeable,mergeStateStatus,reviewDecision,reviews[],statusCheckRollup[], andfiles[]off the resulting JSON document. - No trusted copy, no merge (
references/trusted-record-parser.mditem 6); the GitHub MCP server never stands in for it.
2. Pre-checks (must all pass)
Merge path — selected by the merge risk of the exact head
The low-risk path is opt-in: the project sets merge.low-risk-path and risk.critical-paths in its default-branch manifest, and the trusted classifier answers low-risk-merge=yes for the exact head (@rules/git/pull-requests.md *Low-risk merge path*). Read references/low-risk-path.md and follow it. It replaces the code-review gate, the delegated security coverage check, and the CI wait below with one security-only check, run before step 3 executes any code from the head. Every other case takes the full path, and every check below applies as written.
For each PR, derive the verdict from the JSON document loaded in step 1:
- Converged code review on the final diff (hard gate, two exemptions: `FAST`-tier PRs and dependency-only PRs; the low-risk path replaces it) — a code review must have run on the effective PR diff being merged and report no errors: 0 Critical, and no undeferred Moderate.
Verify it: read the newest trusted code-review report with the trusted copy of skills/_shared/cr-header.sh --report <loader-file> (references/trusted-record-parser.md) — the hidden record of the newest trusted pull-request review that @skills/code-review-github/SKILL.md / @skills/process-code-review/SKILL.md posted, or a legacy cr-comment comment when that is newer (skills/_shared/review-trust.jq newest_trusted_report) — read its verdict against the three tests below, and confirm it reflects the current effective PR diff.
- `Critical 0` in the `Counts:` line. Any Critical blocks, unconditionally.
- Every Moderate it reports is accounted for. A Moderate is accounted for when the comment shows it fixed, or when its own
## Deferred to sub-issuessection carries it with a created sub-issue URL (@skills/process-code-review/references/round-three-deferral.md). A converged run publishes one comment carrying every value this gate reads (@rules/code-review/general.md*One published comment per review run — a TL;DR, not a systematic report*); never wait for a second comment. A Moderate that appears in the findings and in neither place is undeferred and blocks. - No deferred entry is security-relevant. A deferred Moderate that meets the S1–S3 carve-out (
@rules/code-review/general.md*Assignment-Declared Test-Only Conditions — Exclusion Gate (issue #17)*) was never deferrable, so its presence in the deferral list is itself the blocker: report it and do not merge.
Older inline review comments (the cr-inline marker, @skills/code-review-github/references/cr-wrapper-contract.md *Findings in the review body*) are the agent's own findings placed on their lines. They are never read as reviewer feedback and add no verdict: this gate reads the Counts: line and the ## Deferred to sub-issues section of the newest trusted report, the hidden record of its review included. Every CR run posts a new pull-request review on the PR and leaves the earlier reports unchanged (@skills/code-review/SKILL.md *Cross-run history*), so the newest trusted report is the only current one; an older report is never read as the verdict. A pull request whose newest trusted report is still a legacy cr-comment comment is read from that comment. Treat the newest trusted report as current when either its Reviewed revision: equals headRefOid, or its Reviewed diff fingerprint: equals a freshly recomputed fingerprint of the current effective PR diff using the canonical command in @rules/code-review/general.md. A content-identical history rewrite keeps the review current: a rebase, squash, amend, or force-push that changes only commit identity must not create a redundant CR round. The fingerprint is evidence only after the comment's author marker and authorAssociation prove it was produced by a trusted review run; never accept an arbitrary PR-body value. A missing or different fingerprint on a different head fails closed and requires review. New actionable reviewer feedback posted after the accepted CR remains separately unfulfilled and also requires processing. If the newest trusted code-review report (references/trusted-record-parser.md) does not exist, still carries a Critical or an undeferred Moderate, or neither its reviewed SHA nor its recomputed diff fingerprint matches, do not merge — report that the code-review gate is unmet and that the review must be run (or re-run) to convergence via @skills/code-review-github/SKILL.md + @skills/process-code-review/SKILL.md first. Apart from the *FAST-tier PR exemption*, the *Dependency-only PR exemption* below, and the low-risk path (*Merge path* above), this gate is never waived — not by an explicit merge request, not by the billing exception below, and not by a GitHub reviewDecision == "APPROVED" on its own.
- Delegated security coverage is verified before merge. Require the trusted delivery verdict for the current pull request. The security comment must be linked, trusted and at least as recent as the newest commit. Missing or stale evidence blocks the merge. The low-risk and explicit hotfix paths retain their own security requirements.
This is not hypothetical — a security pass that dies mid-run (API error, session limit, cancelled agent) leaves exactly this state: the code review published its delegation token and nothing ever arrived to honour it. Report the gap and require the security review to be re-run. The gate reads the code-review comment, so it is vacuous on a PR merged under the *FAST-tier PR exemption* or the *Dependency-only PR exemption* below (no review ran, therefore no delegation was ever claimed) — but on every PR that does carry a code-review comment it applies without exception.
- Not a Draft —
isDraft == false. A Draft PR signals the review/fix loop has not converged (@rules/git/pull-requests.md*Draft pull requests*): the Draft state mirrors the unmet code-review gate, so do not merge a Draft and report it as skipped. If the PR's code review has in fact converged (0 Critical, no undeferred Moderate), it must first be promoted out of Draft by@skills/process-code-review/SKILL.md(gh pr ready) before this skill will merge it — never flip a Draft to ready here just to merge it. The billing exception below never relaxes this. - No merge conflicts —
mergeable == "MERGEABLE"andmergeStateStatusis notDIRTYorBEHIND - CI is passing (not on the low-risk path) — every entry in
statusCheckRollup[]has a passingstate(SUCCESS/NEUTRAL/SKIPPED), with the single billing exception below, which rests on the mandatory *Pre-merge quality gate* run in its place. An entry whosestateisPENDING,EXPECTED,QUEUED,IN_PROGRESS,WAITING, orREQUESTEDis still pending: wait for it per@rules/git/pull-requests.md*Waiting for CI — read the checks every 3 minutes*, then run every pre-check again - The approval check is met — by
reviewDecision == "APPROVED"or, on a same-repository PR (isCrossRepository == false), by the converged code-review comment verified above, unless the helper-agents check ofreferences/trusted-record-parser.mdwithholds it.@rules/git/pull-requests.md*Merging* owns the rule. Record the source for the merge report (*Output*). - A fork PR needs `reviewDecision == "APPROVED"`. A missing or
nullisCrossRepositorycounts as a fork PR (fail closed).
Preview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 32.2 kB | 0f1c5ff138ae |
| SKILVAULT_SOURCE.json | 1.7 kB | d9f1e36be670 |
| THIRD_PARTY_NOTICES.md | 1.1 kB | aef1ecb399c8 |
| references/interactive-testing-follow-up.md | 2.5 kB | 1aa4552b5a90 |
| references/low-risk-path.md | 12.3 kB | 9d554711a15d |
| references/merge-exemptions.md | 16.6 kB | 1a9e4790dba6 |
| references/open-merge-decisions.md | 2.5 kB | 76b3921901ca |
| references/trusted-record-parser.md | 15.2 kB | 210485b0230f |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 0.1.0 Current | 851162fcceda | 2 Dec 2026 |
Locking a skill to one version needs Pro.