agentleFS
kaiohenricunhakaiohenricunha/dotbabel/skills/review-prs/SKILL.md

review-prs

Skill0 starsChanged 2 months agoMITView on GitHub

Batch-review multiple PRs in parallel: dispatch one sub-agent per PR in an isolated worktree, aggregate results into a summary table. Triggers on: "review all PRs", "check my PRs", "PR status".

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run all three checks before creating any worktree.

    line 43
  2. Distinctive:

    2c — Worktree collision check: Run once:

    line 67
  3. Very specific:

    Only surviving (non-preflight-failed) PRs proceed.

    line 82
  4. Distinctive:

    After each round, parse each sub-agent's stdout for the result JSON.

    line 160
  5. Distinctive:

    Never silently skip a PR. Every PR gets a row in the aggregate table.

    line 169
  6. Very specific:

    If any PRs have sub-agent-failed: end the table with — "For failed PRs, run /review-pr N individually."

    line 182
  7. Very specific:

    Worktree recreation: if a worktree path disappears mid-run, the sub-agent's if [ !

    line 197
  8. Very specific:

    Every Status row: must cite the evidence_url from the sub-agent's JSON (CI run URL or test output).

    line 199

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Batch-review a list of PRs in parallel. Each PR gets its own sub-agent running the full review-pr workflow (fetch comments → validate → apply fixes → push → resolve threads → CI gate). Results are aggregated into a single summary table.

Trigger: when the user provides a list of PR numbers to review simultaneously, asks to batch-review PRs, or says "review all of these".

Arguments: $ARGUMENTS — space-separated PR numbers (required). Example: /review-prs 42 43 44.

Steps

1. Parse arguments

Bind NUMBERS from $ARGUMENTS. If empty, print usage and stop:

Usage: /review-prs <N1> [N2 N3 ...]

Echo the target list before doing any network calls: "Reviewing N PRs: #A #B #C".

2. Pre-flight checks

Run all three checks before creating any worktree.

2a — PR existence and state. For each PR number:

gh pr view "$N" --json number,title,headRefName,baseRefName,mergeable,mergeStateStatus,state
  • Non-zero exit (PR not found, no access) → mark preflight-failed: not-found; add a synthetic result row for that PR and exclude it from worktree/sub-agent execution.
  • state != "OPEN" → mark preflight-failed: not-open; add a synthetic result row for that PR and exclude it from worktree/sub-agent execution.

Report any exclusions. Never silently skip a PR: every requested PR must appear in the final aggregate table, including preflight-failed rows created here. If zero PRs survive for execution, stop after emitting the aggregate table.

2b — Merge state classification (advisory; from the same JSON above):

mergeablemergeStateStatusTag
CONFLICTINGDIRTYpreflight-warn: conflicts
MERGEABLEBEHINDpreflight-warn: behind
UNKNOWNanypreflight-warn: unknown-state
MERGEABLECLEAN or UNSTABLE(no tag — proceed normally)

Record the tag and pass mergeStateStatus into the sub-agent brief; the sub-agent handles rebase (step 9 of review-pr) and CI (step 10) autonomously.

2c — Worktree collision check. Run once:

git worktree list

For each PR N, check if .claude/worktrees/pr-N appears. If yes: preflight-warn: worktree-exists and set WORKTREE_EXISTS=true for that PR. The sub-agent reuses the existing worktree safely (the if [ ! -d ] guard in review-pr step 5 handles this). If no: WORKTREE_EXISTS=false.

Print the pre-flight summary table before dispatch:

PRTitleMerge StateWorktreePre-flight
#42...CLEANnewok
#43...DIRTYexistswarn: conflicts, worktree-exists

Only surviving (non-preflight-failed) PRs proceed.

3. Batch into rounds of 6

Split surviving PRs into rounds of at most 6. Print the plan before dispatching:

Round 1: #42, #43, #44, #45, #46, #47
Round 2: #48

4. Dispatch parallel sub-agents

For each round: emit a single coordinator message with one Agent tool call per PR — all calls in that round in one message. Use subagent_type: "general-purpose". Wait for all agents in the round to complete before starting the next.

Construct the following brief for each PR, substituting real values for N, TITLE, BASE_REF, MERGE_STATE_STATUS, and WORKTREE_EXISTS:


You are reviewing PR #N ("TITLE") in repo $(gh repo view --json nameWithOwner -q .nameWithOwner).

Working directory: $(git rev-parse --show-toplevel)
Worktree path: .claude/worktrees/pr-N
Worktree already exists: WORKTREE_EXISTS
Base ref: BASE_REF
Merge state at dispatch: MERGE_STATE_STATUS

Follow the review-pr command workflow exactly — all 15 steps — with these constraints:

AUTONOMY
- Do NOT merge. The user merges explicitly via `/merge-pr N` after reviewing the aggregate table.
- Do NOT prompt the user. Make autonomous decisions throughout.
- If a decision requires user judgement (e.g. an ambiguous design change), note it in `blocker`
  and continue with the rest of the review. Do not halt.

WORKTREE
- If WORKTREE_EXISTS is true, skip `git worktree add` and use the existing path as-is.
- If MERGE_STATE_STATUS is BEHIND or DIRTY, rebase onto the base ref before collecting comments
  (review-pr step 9 covers this — do it first, before step 2, when the branch is conflicting).

OUTPUT
After completing step 15, emit exactly ONE JSON object to stdout (no other text after it):

{
  "pr": N,
  "title": "TITLE",
  "comments": <total comments fetched>,
  "valid": <count valid issues>,
  "false_pos": <count false positives>,
  "fixed": <count fixes applied>,
  "security": "clean|findings",
  "ci": "green|fixed|blocked|flaky|skipped",
  "test_plan": "verified|missing|partial|skipped",
  "conflicts": "none|resolved|unresolved",
  "status": "reviewed|blocked|push-failed|test-plan-missing|conflicts-unresolved|sub-agent-failed|preflight-failed",
  "evidence_url": "<CI run URL or test output reference>",
  "blocker": null
}

FAILURE MODES
- Push failure (step 7): set status "push-failed", stop — do not post replies or resolve threads.
- Test plan missing: set status "test-plan-missing"; include evidence_url if available.
- Merge conflicts left unresolved: set status "conflicts-unresolved"; set blocker to a one-line explanation.
- Preflight/setup failure before the review can run: set status "preflight-failed", set blocker to a
  one-line explanation, still emit the JSON. Use zero counts for fields that were never collected.
- Sub-agent execution failure after start but before a normal result is produced: set status
  "sub-agent-failed", set blocker to a one-line explanation, still emit the JSON. Populate
  completed counts best-effort from work finished before the failure.
- Sandbox blocks file writes: emit JSON to stdout regardless.
- Any other unrecoverable error: set status "blocked", set blocker to a one-line explanation,
  still emit the JSON.

5. Collect results and handle partial failures

After each round, parse each sub-agent's stdout for the result JSON.

OutcomeAction
Valid JSONStore for aggregate table
No output / crashstatus: sub-agent-failed, blocker: "no output from sub-agent"
Malformed JSONstatus: sub-agent-failed, blocker: "parse error: <first 100 chars of output>"
status: push-failedRecord as-is; add note: "commits staged locally — run /review-pr N to retry push"

Never silently skip a PR. Every PR gets a row in the aggregate table.

6. Aggregate summary table

Render one row per PR using the collected JSON:

PRTitleCommentsValidFalse PosFixedSecurityCITest PlanConflictsStatus

Status values: reviewed, blocked, push-failed, test-plan-missing, conflicts-unresolved, preflight-failed, sub-agent-failed.

A PR may only be marked reviewed if: push succeeded, test plan verified, every active criterion passed in review-pr step 14, no unresolved CI failures, branch not conflicting (same gate as review-pr step 15).

If any PRs have sub-agent-failed: end the table with — "For failed PRs, run /review-pr N individually."

7. Cleanup

Print (do not auto-run) the cleanup command for every worktree created during this run:

git worktree remove .claude/worktrees/pr-N   # for each N

Rules

  • Never merge from inside a sub-agent or from the coordinator. Use /merge-pr N or /review-pr N explicitly for each PR after reviewing the table.
  • Parallelism cap: 6 concurrent sub-agents per round. Batch the rest into subsequent rounds.
  • Never force-push from sub-agents. If rebase produces a conflict the sub-agent cannot resolve, it marks conflicts: unresolved and stops.
  • Worktree recreation: if a worktree path disappears mid-run, the sub-agent's if [ ! -d ] guard recreates it.
  • Sandbox write blocks: sub-agents emit JSON to stdout; the coordinator captures from stdout, not from files.
  • Every Status row must cite the evidence_url from the sub-agent's JSON (CI run URL or test output).
  • Pre-flight failures are non-fatal to the batch — removed PRs are reported in the pre-flight table and excluded from dispatch. The remaining PRs proceed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.