/agents-skills:driving-prs-to-mergefrom agents-skills
Manages the full post-open PR lifecycle in multi-agent GitHub repos: enabling auto-merge, triaging CI failures, resolving review threads, rescuing conflicted PRs, and operating merge queues.
Ships in agents-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
After opening any PR, the opener owns driving it to merge. No waiting for a human nudge. The loop exit condition: all required checks green AND every review thread resolved — auto-merge then fires on its own. Everything below exists to get to that state cheaply and honestly.
This skill is project-agnostic. The adopting project defines these in its own CLAUDE.md; refer to them by placeholder throughout.
| Placeholder | Meaning |
|---|---|
<owner>/<repo> | GitHub repository slug |
<integration-branch> | Branch PRs target (may differ from the repo default branch — see "After merge") |
<merge-strategy> | Allowed strategy flag (--squash, --merge, --rebase) — and whether a merge queue is enabled (changes the command, see below) |
<local-gate> | The full local verification command CI will mirror (lint + typecheck + tests), ideally scoped to changed packages + dependents |
<worktree-dir> | Where feature branches live on disk (see the dispatching-subagents skill) |
<bot-reviewer> | AI review bot identity (if any), whether it reviews sync or async, and whether the ruleset enables required_review_thread_resolution |
<required-checks> | Names of merge-gating CI checks |
<failure-catalog> | Location of the failure-pattern catalog (maps check-name → likely cause → fix recipe → evidence PR#) |
<flake-ledger> | Where known-flaky jobs are tracked (e.g. a scheduled workflow posting to a pinned issue); absent → degrade to "retry twice on same SHA" |
<per-pr-deploy> | Per-PR preview-environment workflow, if any, and its path filter |
<breaking-change-labels> | Acknowledgment labels/annotations that breaking-change gates honor |
<derived-artifacts> | Generated files (lockfiles, operation manifests) + their regeneration commands |
<append-only-files> | Shared append-only files (changelogs, learnings logs) that conflict trivially |
<ai-mention-trigger> | The human-only AI-action mention string (e.g. @claude), if the repo has one |
<force-push-policy> | Who may force-push feature branches (some environments permission-block sub-agents; orchestrator performs with operator authorization) |
<commit-convention> | Commit message format; see the dispatching-subagents skill for the canonical definition |
Run all three immediately after opening, as one atomic ritual:
gh pr create --base <integration-branch> --title "<conventional title>" \
--body "<... Closes #N ...>" \
--assignee "$(gh api user --jq .login)"
gh pr view <PR#> --json assignees,labels # verify assignee landed
gh pr merge <PR#> --auto <merge-strategy> # merge queue active? OMIT the strategy flag — see below
If the assignee or required labels did not land, repair via the REST API:
gh api -X POST repos/<owner>/<repo>/issues/<PR#>/assignees -f "assignees[]=<login>"
gh api -X POST repos/<owner>/<repo>/issues/<PR#>/labels -f "labels[]=<label>"
Never use gh pr edit for repairs — it can exit 0, print a GraphQL deprecation warning, and persist nothing (observed losing a title fix and assignee, leaving a required title check red).
Why each step:
gh pr list --assignee @me is how each operator filters their in-flight work. Author is automatic; assignee is what the filter reads. (See the issue-locking skill (gh-issue-locking / jira-issue-locking) for the full multi-operator protocol.)<integration-branch>, gh pr merge --auto --squash is rejected by the queue and the auto-merge enrollment silently drops — no error appears on the PR; it just never merges. Pass --auto with no strategy flag. This was the root cause of auto-merge "mysteriously dropping" across many PRs in practice.gh pr merge <PR#> --auto once the blocker clears, or the green PR sits unmerged indefinitely. The command is idempotent — "already queued to merge" is confirmation, not an error.--admin past checks or required reviews — the sanctioned alternatives are <breaking-change-labels> or an honest stop-and-report (see "Meta-gates").When scanning for stuck PRs, use --assignee @me (the ownership signal) as the primary filter. If the agent may have dropped the assignee flag, add a secondary --author sweep to catch assignee-dropped PRs:
gh pr list --repo <owner>/<repo> --assignee @me --state open \
--json number,createdAt,mergeStateStatus,statusCheckRollup \
--jq '[.[] | select(.mergeStateStatus == "DIRTY" or
([.statusCheckRollup[]? | select(.conclusion=="FAILURE")] | length > 0))]
| sort_by(.createdAt) | .[] | {n: .number, age: .createdAt}'
Run <local-gate> before pushing — via git hooks or manually mid-development. If a hook blocks the push, fix the issue and push again; never bypass with --no-verify. Bypassing converts a 30-second local catch into lint/type errors landing in CI 10 minutes after the push — the prohibition exists exactly to prevent that loop. Scope the gate to changed packages and their dependents so it stays fast.
One reliability caveat learned the hard way: with heavy pre-push hooks, git push exit 0 is not proof the push landed (hook rejection can surface as exit 0 in background tasks). Verify git ls-remote origin <branch> matches local HEAD before claiming "pushed".
gh pr view <PR#> --json mergeStateStatus,autoMergeRequest,statusCheckRollup
| State | Means | Your action |
|---|---|---|
BLOCKED | Waiting on a required check (most commonly CI in progress). Normal. | Wait. If green-but-BLOCKED for 30+ min with zero queue activity, check review threads first — it is almost always unresolved threads, not a broken queue. |
CLEAN | All required checks green; eligible to merge or actively in the queue. Often shows autoMerge=false because the queue consumed the flag. | "CLEAN auto=false" after queue pickup means QUEUED, not broken. gh pr merge --auto replying "already queued" is confirmation. Do not panic-toggle. |
UNKNOWN | Being processed by the merge queue; a merge_group run is in flight. Normal. | Wait. |
DIRTY | Branch conflicts with <integration-branch>. | Run the cheap-first rescue ladder (below). |
BEHIND | Behind base but not conflicting. | Auto-rebase (if configured) or gh pr update-branch handles it. |
UNSTABLE | A non-required check failed. | A non-required check failed; doesn't block merge by itself. Check whether it's a known advisory (no action) or a real regression (fix it — prioritize if it gates other work). |
autoMergeRequest: null is ambiguous (never armed OR consumed by the queue), and mergeStateStatus can read CLEAN/UNSTABLE while enqueued. Only GraphQL mergeQueueEntry is definitive:
gh api graphql -f query='query($o:String!,$r:String!,$n:Int!){
repository(owner:$o,name:$r){ pullRequest(number:$n){
mergeQueueEntry{ state position } autoMergeRequest{ enabledAt } } } }' \
-f o=<owner> -f r=<repo> -F n=<PR#>
gh run view --log-failed (and check-summary UIs) usually show only the aggregate/gate job that failed because an upstream job failed — you diagnose the cascade, not the cause. In one production repo this made a checkout transient look like a coverage failure and burned a full rescue dispatch. Fetch the specific failed job's raw log:
gh run list --branch <branch> --limit 3 --json databaseId,workflowName,conclusion
gh run view <run-id> --json jobs --jq '.jobs[] | "\(.name) → \(.conclusion // "running")"'
JOB_ID=$(gh run view <run-id> --json jobs --jq '.jobs[] | select(.name == "<JobName>") | .databaseId')
gh api "repos/<owner>/<repo>/actions/jobs/$JOB_ID/logs" | grep -E "FAIL|Error|::error" | head -20
Walk the pipeline chain in dependency order (e.g. deploy → DB bootstrap → smoke → E2E) so you find the FIRST real failure, not a downstream symptom.
Rebasing or "fixing" a flake wastes rebase debt and can introduce conflicts that wouldn't otherwise exist. In order:
<integration-branch> right now? If yes, lean transient.<flake-ledger>? Mechanical classification rule: a job is flaky iff the same head SHA produced both a failure and a success conclusion. On the list → retry, don't rebase.gh run rerun --failed is rejected on superseded or in-progress runs with a misleading "workflow file may be broken" error — use a full rerun.If your PR changes user-facing behavior (e.g. adds a confirm dialog before delete), an existing E2E spec failing on that flow is a real contract change, not a flake: update the spec to walk the new UX in the same PR. Related trap: whole-page scans (e.g. axe accessibility) inside unrelated specs can catch UI your PR added elsewhere on the page — scope the scan to the component that spec actually tests (matching the spec's stated intent); don't suppress the rule.
Maintain a catalog at <failure-catalog> mapping check-name → likely cause → fix recipe → evidence PR#. Recurring failures recur; pre-classification means a rescue starts at the fix, not the discovery. Seed entries (drawn from a JS/TS project — keep the failure SHAPES, rebuild names and recipes per stack):
await waitFor(() => expect(...)) (JS instance of the shape: assertion races scheduled async work — use your framework's retry-until-true primitive). Retrying forever doesn't fix the race.<per-pr-deploy> caveat: deploy workflows with path filters will NOT re-trigger on an empty commit if the PR's diff doesn't match the deploy paths (e.g. test-only PRs). Pushing empty commits to "bring the deploy back" is a dead end by design — know the filter.
Treat <bot-reviewer> comments identically to human review comments. For each: (1) read it — if a suggestion looks technically wrong, verify before agreeing or refusing (no performative agreement, no reflexive dismissal); (2) apply the change OR reply with a reasoned counter; (3) mark the thread resolved. When the ruleset enables required_review_thread_resolution, auto-merge will not fire while any thread is unresolved — the recurring symptom is a fully green PR stuck BLOCKED with zero queue runs, which looks exactly like a broken merge queue and has caused repeated misdiagnoses in practice. Check threads FIRST.
gh api repos/<owner>/<repo>/pulls/<PR#>/comments # all line comments (bot + human)
gh pr view <PR#> --json reviews,comments # review summaries + top-level comments
# gh pr view --json reviewThreads can return EMPTY even when threads exist — use raw GraphQL:
gh api graphql -f query='query($o:String!,$r:String!,$n:Int!){
repository(owner:$o,name:$r){ pullRequest(number:$n){
reviewThreads(first:50){ nodes{ id isResolved path
comments(first:1){ nodes{ author{login} body } } } } } } }' \
-f o=<owner> -f r=<repo> -F n=<PR#>
# After applying or countering, resolve:
gh api graphql -f query='mutation($t:ID!){
resolveReviewThread(input:{threadId:$t}){ thread{ isResolved } } }' -f t=<thread-node-id>
Three traps with real incident history:
<integration-branch> (observed: a real bug stayed live while its threads showed "resolved"). Before dispatching any thread-fix work, check gh pr view <PR#> --json state; re-land orphaned fixes via a fresh branch off <integration-branch> + cherry-pick.git -C <worktree> log origin/<branch>..HEAD is empty before trusting resolutions.Never post <ai-mention-trigger> from any agent — it is a human-only trigger; one AI session invoking another creates unsupervised loops. Enforce mechanically with a permission deny rule matching the mention string in any CLI invocation.
gh api -X PATCH repos/<owner>/<repo>/pulls/<PR#> -f title=...); the check re-runs on edit.<breaking-change-labels> or an annotated in-file comment with reason — never an admin merge. The hatch leaves an audit trail; the bypass leaves nothing, and without a sanctioned hatch agents under pressure invent unsanctioned ones.--no-verify, skip-checks, deleting tests) converts a visible, attributable failure into invisible debt discovered later without context.Burn the minimum resource at each rung: an API call before an orchestrator action before an agent slot.
gh pr update-branch <PR#> --repo <owner>/<repo> — for DIRTY/BEHIND with zero failing checks. Succeeds (done, no agent) or fails loudly with "Cannot update PR branch due to conflicts" (a real conflict — escalate). This CLI call is fine; the GitHub web "Update branch" button on a conflicted PR is not — it produces a merge nobody verified.
Self-handled trivial conflicts — <append-only-files> conflicts resolve mechanically by keeping both entries; <derived-artifacts> resolve by taking the integration branch's version, then regenerating with the project's generator — never hand-merge generated files; commit the regen.
cd <worktree>
git fetch origin <integration-branch>
git rebase origin/<integration-branch>
# append-only file → keep both entries; derived artifact → checkout theirs, re-run generator
git add <file> && git rebase --continue
git push --force-with-lease origin <branch>
Dispatched rescue agent — only for actual code conflicts, on the PR's existing worktree/branch. See the dispatching-subagents skill for the brief template; the brief must name the failing checks, cite the catalog pattern, and include stop-and-report triggers (a failure that looks like a real regression goes to the operator, not a blind "fix" that adjusts the test).
After resolving locally, always re-run <local-gate> against the merged result before pushing — conflicts resolved without re-running gates ship silent semantic breakage.
Force-push discipline. After rebasing any already-pushed branch, the push requires --force-with-lease — never bare --force (lease protects against clobbering a concurrent push from a CI auto-rebase bot or sibling operator; recovery from a bare force-push on a shared branch requires force-pushing every downstream branch, because history is rewritten). Plain pushes apply only to never-pushed branches. Never force-push protected/integration branches — it rewrites history every open PR and CI run is based on; recovery requires force-pushing every downstream branch. Per <force-push-policy>, sub-agents may be permission-blocked from force pushes — the orchestrator performs them, after explicit operator authorization where required.
Auto-rebase starvation: only relevant if the project runs an auto-rebase automation (most don't). Never apply do-not-rebase proactively or at PR-open — apply it only after you observe a CI run cancelled by a rebase, then remove it once the PR nears the front of the queue. See the issue control-field skill (gh-issue-labels for GitHub labels, jira-issue-fields for Jira fields) for the opt-in rule and counter-risk.
gh-readonly-queue/<integration-branch>/pr-<N> branch (base + queued entries). Diagnose boots from those merge-group runs, not the PR's checks. Any flaky merge-gating test boots whatever shares the queue group.gh pr merge --disable-auto does NOT dequeue. Recovery: GraphQL dequeuePullRequest(input:{id:<pr-node-id>}) → push → re-arm gh pr merge --auto. A wedged queue (queued 30–40 min, branch locked, no merge-group run ever starts) needs dequeue → gh pr update-branch → re-arm.gh pr merge --auto after every ejection.When multiple PRs are stuck, work the oldest first — older PRs accumulate the most rebase debt and re-fail on every new integration-branch merge; newest-first compounds that cost.
Exactly two skip-ahead exceptions: (a) a newer PR unblocks the older one (lint-rule or CI-infra fix the older is downstream of) — merge the unblocker first; (b) the older PR has a stop-and-report awaiting operator decision.
What NOT to rescue (each rule prevents an observed waste mode): auto-merge engaged and CI merely running — auto-merge handles the wait, a "babysit" agent burns tokens in no-op polling; a single flake on a non-required check — retry catches it; an older PR about to be unblocked by a newer PR currently merging — let it land.
When a branch must be cut off another open PR's branch (file overlap): open the child as draft with --base <parent-branch> and do NOT enable auto-merge. If auto-merge is armed early, GitHub squash-merges the child into the parent feature branch; a later parent rebase+force-push can silently erase the child's commit from the merge chain — losing the work entirely. Draft state is the mechanical guard. After the parent merges (gh pr view <parent#> --json mergedAt):
git fetch origin <integration-branch>
git rebase origin/<integration-branch> # parent's commits already in base; only your increments remain
git push --force-with-lease origin <branch>
gh pr edit <PR#> --base <integration-branch> # GitHub may have retargeted automatically — check first
gh pr ready <PR#>
gh pr merge <PR#> --auto <merge-strategy> # engage auto-merge NOW (queue → no strategy flag)
Any agent encountering a failing gating signal owns getting it fixed, even if the failure pre-dates their branch. "I didn't break it" is not an exemption — one tolerated red check trains every agent to ignore red checks. But run the four coordination probes first (two agents independently "owning" the same broken test produce conflicting PRs); any hit → link to it and stand down:
gh pr list --state open --search "<test/file/path>"
gh pr list --state open --search "<failing test name or assertion>"
gh issue list --state open --label bug --search "<test name>"
git ls-remote --heads origin | grep -i "<test-keyword>"
Then: a separate dedicated fix PR off freshly-fetched <integration-branch>, cross-linked from your primary PR — never bundled (bundling muddies review, couples merge risk, and hides the fix from other agents' probes). Classify the dependency explicitly: the fix gates your primary PR only if it shares a package/test surface your CI exercises; otherwise both land in parallel. One known counter-case: never split an E2E-spec fix from the component change it depends on — circularly dependent, neither passes alone.
Resolution priority, documented in the fix-PR body:
.skip() permitted only with a simultaneously-filed issue (see the issue-filing skill (gh-issue-filing for GitHub, jira-issue-filing for Jira)), referenced both inline at the skip site AND in the PR body. Untracked skips outlive their blocker and the coverage hole becomes permanent.One scoping caveat: don't chase a deploy failure that predates your change (same step failed on a prior commit without your code) when the operator handles deploy health separately — your merged change rides the next green deploy; chasing it derails the task at hand. Confirm which regime the project runs.
For orchestrator-dispatched work, peer review is selective, cold, and never approves:
<the project's hard rules>." Prefixing "the implementer says this works" anchors the reviewer and defeats the point.--approve: reviewers use gh pr review --comment or --request-changes only. Approval-by-proxy satisfies human-review branch protection without any human in the loop; express positive verdicts as comments.<ai-mention-trigger>.If <integration-branch> is not the repo's default branch, GitHub will not auto-close Closes #N issues — the orchestrator must close them explicitly and release the issue lock, or zombie issues get re-dispatched and claim labels go stale. Protocol: see the issue-locking skill. Run the close-on-merge sweep every monitoring tick (see the orchestrating-slots skill).
This skill runs in high-volume, repetitive orchestration loops where tokens compound across many rounds and many agents. Operate in caveman mode (load the caveman skill) to cut token use on all working output — status, reasoning, slot tables, completion reports, dispatch and coordination chatter.
Caveman compresses prose only. It must NEVER alter machine-precise content, which stays byte-exact: lock-comment markers, the RECON OK / RECON-ERROR contract lines, JQL, gh / Atlassian-MCP commands, label and field names/values, file:line references, code blocks, and acceptance-criteria checklists. Compress the narration, never the protocol.
Durable prose a human reads later — issue/ticket bodies and PR descriptions — is the exception: write those through the humanizer skill (see the issue-filing skill), not in caveman.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pr-lifecycle, ci-triage, merge-queue, auto-merge, review-threads
npx claudepluginhub skyfox675/agents-skills --plugin agents-skills32 skills in this plugin
/browser-diagnosisReproduce and root-cause a front-end bug in a real browser using whichever browser MCP is connected — Chrome (claude-in-chrome), Playwright, Cypress, or Chrome DevTools — not just one. Drive the page as the signed-in user, watch the network and console, capture the failing request/response, shim/mock to isolate the fault, and record a repro, then hand the evidence to the issue being filed. Use whenever a symptom needs live-browser evidence (the toast says failed but it saved, a column shows zero, a click 404s) and from the /…-use-browser command family (and the engine-pinned /…-use-chrome, /…-use-playwright, /…-use-cypress variants), the /…-use-aws-browser commands, and the diagnostician agent. Picks the available MCP automatically and degrades gracefully when none is connected./cavemanUltra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested./ci-flake-huntingThe authoritative method for hunting, root-causing, and fixing CI flakes so the merge queue stops ejecting correct PRs and churn drops. A flake is a test that fails then passes on retry with NO code change explaining it — every red speculative merge-queue build ejects a correct PR and disarms its auto-merge, so a live flake taxes every PR behind it. Encodes the loop — MINE CI history for real flakes → REPRODUCE harsher-than-CI → ROOT-CAUSE the real mechanism (hydration/render race, settle race, mock-order, loading-state race, click-through fragility) → FIX FORWARD (test or component, never mask) → VERIFY by re-running many times → UNSTICK the PRs the flake stranded → REPEAT. And how to tell a true code flake from transient INFRA (CDN/mirror outage, expired token mid-suite, rate-limit/WAF, external-service cap, cloud state-lock, CI-provider billing/outage, upstream bump) which must NOT be code-fixed. Use whenever chasing CI instability, "deflake this spec", "CI keeps ejecting my PR", "is this a flake or real", a shard that intermittently reds the queue, or running the ci-flake-hunter lane. Distinct from ci-speed-hunting (which owns slow-but-green jobs — flake never touches timing/sharding)./ci-speed-huntingThe authoritative method for hunting, diagnosing, and fixing CI SLOWNESS so the merge queue drains faster and throughput rises — the target is wall-clock latency, NOT correctness (a job that is GREEN but slow). Encodes the loop — MINE CI timing for the real long poles → DIAGNOSE the bottleneck class (under-sharded matrix, cold cache, missing/too-broad path-filter tier, serial needs-chain, redundant rebuild) → PROVE the fix keeps identical coverage → FIX FORWARD → VERIFY the before/after delta at unchanged coverage → REPEAT. And the hard line — speed comes from doing the same work faster or skipping PROVABLY irrelevant work, NEVER from deleting tests, narrowing greps, dropping shards, or removing a gate. Use whenever chasing CI latency, "CI is too slow", "speed up the checks", "why does the merge queue take so long", re-sharding an E2E matrix, adding or fixing a cache, tuning changed-paths tiering, or running the ci-speed-hunter lane. Distinct from ci-flake-hunting (which owns failures and flakes — speed never touches a red job)./deploy-watchingSingle-lane interval watcher that keeps the integration environment's deploys healthy by fixing FORWARD — the deploy-health lane of a multi-agent fleet. Each tick it reads the newest deploy run, locates the red (deploy step vs post-deploy smoke), classifies it transient (concurrent-deploy state-lock race, CI-infra blip, known smoke transient) or real (deterministic IaC error, ordered co-deploy race, regression from a merged commit, contention inside the shared environment), re-runs the former, and mints a forward-fix PR for the latter that preserves the offending commit's intent — never a revert, never a skipped test. Loops on an interval ("/loop <interval> start"). Use when running a deploy lane, when the dev/staging deploy went red after a merge, when deciding whether a red deploy needs a re-run or a code fix, when the environment may be running stale code, or when `pr-checks` hands over a failure rooted in the integration branch rather than a PR's diff./dispatching-subagentsTurn a groomed tracker issue into a running implementation sub-agent and a merged PR — issue selection (priority, file-disjointness, bundling), model/effort resolution from chat > labels > defaults, the eight-section dispatch brief (worktree, toolchain prefix, pre-push hygiene, scope, git discipline, PR procedure, return contract), parallel dispatch under a concurrency cap, stalled-agent worktree salvage, and verify-then-trust completion checks. Use whenever you are about to spawn a sub-agent (Agent/Task tool call) to implement, fix, refactor, test, or otherwise write code from a tracker issue — even if the user only says "work the next issues", "fix these bugs", "run the loop", or "send an agent at #N" without saying "dispatch"; also use when a dispatched agent stalls, is watchdog-killed, returns status:failed, or reports completion and you must decide whether to salvage its worktree, re-dispatch, or verify its PR.Other plugins' skills for the same job