/git-plugin:git-pr-sweep owner/repo [--stage all] [--root /abs/clone] [--dry-run]from git-plugin
Reviews, fixes, and merges all open PRs in a repository across three stages. Use when sweeping an entire PR queue to completion.
Ships in git-plugin. 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; scripts run unread.
Review one repository's open PRs, fix confirmed findings on the PRs' own branches, then ready and merge what passes every gate. Scripts decide every count and gate; only the main session readies and merges.
| Use this skill when... | Use another skill instead when... |
|---|---|
| Taking a repo's PR queue, ready drafts included, through review, fix and merge | Grooming the backlog with no code changes → git-plugin:git-triage |
| Merging only what a fresh review found clean | Human review threads on one PR → recommend the user run /git:pr-feedback |
Merging a known PR chain → git-plugin:git-merge-hazards |
git log --max-count=1 --onelinegit branch --show-currentParse these from $ARGUMENTS:
| Argument | Default | Meaning |
|---|---|---|
<owner/repo> | git-plugin:git-repo-detection | The one repository swept; a github.com URL works too |
--stage review|fix|merge|all | all | all runs the stages in order, stopping when one leaves nothing for the next |
--root PATH | current checkout | Absolute path of a clone whose origin is the repo |
--review FILE | none | review.json; required by --stage fix; --stage merge without it merges nothing |
--fix FILE... | none | fix-<i>.json files, for --stage merge |
--dry-run | off | Stop before pr-fix, gh pr ready and merge-chain.sh; print the plan |
<work> is <root>/tmp/pr-sweep/ when tmp/ is git-ignored there, else the session scratchpad.
Outside <root>'s repository, pass worktrees: "<root>/.claude/worktrees" in every Workflow's args. Formats: references/handoff-formats.md.
Execute this PR sweep one stage at a time, reading each script's summary before going on.
Invoke git-plugin:git-coworker-check on <root>; stop if another agent is active there.
List open PRs, drafts included, classified by script:
bash ${CLAUDE_SKILL_DIR}/scripts/list-sweep-prs.sh --resolve-blockers --out <work>/roster.json <owner> <repo>
Show the counts; TRUNCATED=true (the 500-PR ceiling) goes in the final report.
--stage review|all)Plan the runs (small PRs share a finder pair):
bash ${CLAUDE_SKILL_DIR}/scripts/plan-review-runs.sh --out <work>/review-plan.json <work>/roster.json
Fetch every head and base once, so no agent fetches:
bash ${CLAUDE_SKILL_DIR}/scripts/prefetch-heads.sh --root <root> <work>/roster.json
On MISSING= PRs re-run Step 1; still missing → report them unreviewed and re-plan without them.
For each runs[i], in order, adapt workflows/pr-review.workflow.js and run it with args {repo, root, prs: runs[i].prs, groups: runs[i].groups, context, decided}. Write each return verbatim to
<work>/review-<i>.json.
For each review-<i>.json with unverified rows, re-run the template once with claims = that
run's unverified rows and prs = those PRs' rows from review-plan.json runs[i].prs; write
<work>/verify-<i>.json.
Join every file written, review files first:
bash ${CLAUDE_SKILL_DIR}/scripts/merge-review.sh --out <work>/review.json <work>/review-1.json <work>/review-2.json <work>/verify-1.json
--stage fix|all)Turn confirmed findings into units; every PR that must not be fixed is excluded with its reason:
bash ${CLAUDE_SKILL_DIR}/scripts/review-to-units.sh --chunk 3 --out <work>/units.json <work>/roster.json <work>/review.json
For each runs[i], in order (the next run must see this one's push), adapt
workflows/pr-fix.workflow.js and run it with args {repo, root, base: "origin/<default>", units: runs[i], gates, setup, skills: ["git-plugin:git-commit-workflow"], decisions, trailer}.
gates are the repo's test and lint commands; decisions relay Lauri's choices as given.
Write each return to <work>/fix-<i>.json.
Before re-dispatching a FAILED or UNVERIFIED unit fresh, clear what it left
(references/fix-redispatch.md), then
gh pr list -R <owner>/<repo> --head <branch> --state all --json number,state,headRefOid.
--stage merge|all)Main session only, in order; stop handling: references/merge-procedure.md.
A red check on a PR you mean to merge goes through git-plugin:git-merge-hazards § 4's triage first.
Take the review timestamp first, before the re-list, so a later push stops merge-chain.sh:
date -u +%Y-%m-%dT%H:%M:%SZ.
Re-list fresh (a blocker may have merged mid-sweep): repeat Step 1.2.
Gate every PR:
bash ${CLAUDE_SKILL_DIR}/scripts/merge-gate.sh --out <work>/gate.json <work>/roster.json <work>/review.json <work>/fix-1.json <work>/fix-2.json
If gate.json has ready drafts, adapt workflows/pr-merge.workflow.js, run it with args
{repo, plan: gate.json, roster: roster.json}, write <work>/plan.json; else plan.json is gate.json.
For each draft in plan.ready, one literal number per call:
gh pr ready 12 -R <owner>/<repo>, then confirm with gh pr view 12 -R <owner>/<repo> --json isDraft.
For each plan.merge chunk, in a background Bash call, --repo and --prs as literals; before
each later chunk, repeat steps 2–3 and drop PRs that no longer pass. Right before every call,
read each PR's head, gh pr view 12 -R <owner>/<repo> --json headRefOid, and drop (report as head
moved) any whose head differs from its gated roster head_sha (#3748):
bash ${CLAUDE_SKILL_DIR}/../git-merge-hazards/scripts/merge-chain.sh --repo <owner>/<repo> --prs 12,15,19 --review-ts <ts> --fetch-dir <root>
Read the === MERGE CHAIN === block. A CONFLICT or CI_RED stop gets one pr-fix run for that PR,
then steps 1–6 for REMAINING; DENIED and GUARD_LATE_COMMIT are reported for Lauri.
| draft_class | Reviewed | Fixed | Readied and merged |
|---|---|---|---|
not_draft | yes | yes | when G1–G7 pass |
ready_candidate | yes | yes | when G1–G8 pass and pr-merge's reader finds no unmet ## Draft status condition |
blocked, blockers_unresolved | yes | yes | no; reported with each blocker not MERGED |
wip, no_section, no_blocker_urls | yes | no | no; surfaced with findings and reason |
WIP markers, gates and per-kind policy (release-please, Renovate, external authors): references/draft-gates.md.
workflows/pr-review.workflow.js, workflows/pr-fix.workflow.js and workflows/pr-merge.workflow.js
ship beside this skill. Each is a TEMPLATE to adapt, not a script to run verbatim. Read it, then
rewrite it for the work in front of you.
Adapt freely: the lens and reader prompt wording, lensBrief, verifyCap, decided[], the
repo's gates, setup and trailer, and the merge chunk size.
Agent budget (pr-review.workflow.js): 15 — 2 finders per group over GROUPS.slice(0, 4) plus 7 verifiers over toVerify.slice(0, 7).
Agent budget (pr-fix.workflow.js): 13 — per unit over UNITS.slice(0, 3) a fixer, a verifier, and on fix-needed a repairer and a re-verifier, plus 1 finalise.
Agent budget (pr-merge.workflow.js): 8 — one reader per ready draft over READY.slice(0, 8).
Preserve across any adaptation: (a) every loop bound comes from a script (planner groups,
review-to-units.sh units, merge-gate.sh ready drafts), with literal slices in the fan-outs and an
abort over a cap, never a truncation; (b) the closed enums: refute-by-default
confirmed|partially|refuted (an unreproduced confirmation is a dead verifier), pass|fix-needed|reject,
and ready|hold where only a consistent ready clears a draft; (c) Rank is pr-review's barrier, Finalise is pr-fix's (push order on one remote), the plan rebuild is pr-merge's;
(d) pr-fix's rr-shared region stays byte-identical with repair-round's, minus its stage helpers
(scripts/tests/test-pr-sweep-workflows.sh).
Never Workflow({resumeFromRunId}) to retry a few failed worktree agents — a resume re-runs agents
that already succeeded and opens duplicate PRs (#1868). Re-dispatch the failed units fresh and
sequentially after checking gh pr list --head <branch> --state all --json number,state.
Push, PR creation, and GitHub mutations happen only in the single sequential finalise stage, never inside a fanned-out agent.
Skip the harness when: the repo has one open PR (review and fix inline), or plan.ready is empty.
reason, link;
PRs in chunks a stop left unrun are not_attempted. Under a row with findings, list them and
its fix_block: the only place a Renovate, external or unreadyable draft's findings surface.bash ${CLAUDE_SKILL_DIR}/scripts/prune-worktrees.sh --root <root> and list its
WORKTREE_<i>= lines in the report. Remove none: a peer session can hold the same names.REFERENCE.md (opens in a new tab)references/draft-gates.md (opens in a new tab)references/fix-redispatch.md (opens in a new tab)references/handoff-formats.md (opens in a new tab)references/merge-procedure.md (opens in a new tab)scripts/lib/summary.sh (opens in a new tab)scripts/list-sweep-prs.sh (opens in a new tab)scripts/merge-gate.sh (opens in a new tab)scripts/merge-review.sh (opens in a new tab)scripts/plan-review-runs.sh (opens in a new tab)scripts/prefetch-heads.sh (opens in a new tab)scripts/prune-worktrees.sh (opens in a new tab)scripts/review-to-units.sh (opens in a new tab)scripts/tests/fixtures/blocker-states.json (opens in a new tab)scripts/tests/fixtures/graphql-pages.json (opens in a new tab)scripts/tests/run-workflows.mjs (opens in a new tab)scripts/tests/test-list-sweep-prs.sh (opens in a new tab)scripts/tests/test-merge-gate.sh (opens in a new tab)scripts/tests/test-plan-review-runs.sh (opens in a new tab)scripts/tests/test-pr-sweep-workflows.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laurigates/claude-plugins --plugin git-plugin52 skills in this plugin
/deadbranchdeadbranch CLI for stale-branch cleanup — dry-run preview, TUI or non-interactive delete, protects main/develop/WIP. Use when asked to clean up branches, prune branches, or remove stale branches./external-pr-trustAuthorship as a precondition of merging — bot vs stranger classification, what a merge executes, the merge-guard hook. Use when bulk-merging PRs, or when a merge is denied for a non-self author./gh-cli-agenticgh CLI commands with JSON output for agents. Use when querying PRs, issues, runs, or repo metadata; inspecting PR checks; fetching failed CI logs; or mapping a github.com URL to an API call./git-api-prGitHub API PR creation without local git. Use when submitting file changes as a PR without local commits — quick fixes, typos, config updates, or bypassing local git state./git-branch-namingBranch names: type prefix (feat/, fix/, chore/), issue number, kebab-case. Use when picking a name for a new branch or setting a repo's branch-naming convention./git-branch-pr-workflowBranch management and PR workflows — git switch/restore, GitHub MCP. Use when creating branches, opening PRs, or working with feature branches.Other plugins' skills for the same job