pullrequests-review-loop
Poll an automated PR reviewer's reviews (login from --reviewer or WORKBENCH_REVIEWER), judge each finding (the reviewer is flaky - never obey blindly), dispatch fixer subagents, and loop until clean or a round cap. Use between pipeline-watch and merge.
- License 许可
- MIT
- 最近更新
- 2026-10-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- pullrequests-review-loop
- description
- Poll an automated PR reviewer's reviews (login from --reviewer or WORKBENCH_REVIEWER), judge each finding (the reviewer is flaky - never obey blindly), dispatch fixer subagents, and loop until clean or a round cap. Use between pipeline-watch and merge.
02 资源文件 3
- 脚本scripts/review_state.py7.4 KB
- 脚本tests/test_review_loop_structure.py895 B
- 脚本tests/test_review_state.py19.8 KB
03 SKILL.md 正文
pullrequests-review-loop
Drives the review-fix loop between CI going green (pullrequests-watch)
and merge. An automated PR reviewer (login from --reviewer or WORKBENCH_REVIEWER) posts GitHub PR reviews (APPROVED / CHANGES_REQUESTED /
COMMENTED) plus inline comments on our PRs. It is flaky:
observed flipping CHANGES_REQUESTED -> APPROVED on the exact same
unchanged commit, and sometimes going unreachable and never reviewing at all.
This skill never obeys its verdict blindly in either direction - a
CHANGES_REQUESTED might be wrong, an APPROVED might be papering over a
real finding from two minutes earlier. The calling agent always judges.
GitHub only. The review loop covers GitHub PRs; any GitHub host works
(the WORKBENCH_SCM_HOSTS map is honoured). On a GitLab repo the script prints
pullrequests-review-loop: <repo>: unsupported on GitLab (review-loop is GitHub-only) on stderr, still processes the run's GitHub repos, and exits 1.
A local-only repo (no PR host) is reported skipped on stderr and does not fail
the run. For GitLab, judge unresolved discussions via pullrequests-watch reviews= and the MR UI/API.
This skill does not merge. Merging stays the caller's job (merge own PRs step in start-development).
Procedure
-
Poll. Run the script for the PRs in scope:
mise exec -- python3 ${CLAUDE_PLUGIN_ROOT}/skills/pullrequests-review-loop/scripts/review_state.py \ --branch <branch> --repos repoA,repoBor, with explicit PRs:
mise exec -- python3 ${CLAUDE_PLUGIN_ROOT}/skills/pullrequests-review-loop/scripts/review_state.py \ --prs repoA#123,repoB#45--reviewer <login>names the reviewer and wins over envWORKBENCH_REVIEWER; with neither the script exits 2 withreview_state: no reviewer; pass --reviewer <login> or set WORKBENCH_REVIEWER. Output is newline-delimited JSON, one object per PR:repo, pr, url, headSha, prState, mergeable, reviewerDecisionOnHead: APPROVED|CHANGES_REQUESTED|COMMENTED|NONE, reviewsAll: [{state, submittedAt, commitId, onHead, body}, ...] (newest first, reviewer's only), inlineComments: [{path, line, commitId, onHead, createdAt, body}, ...] (newest first, reviewer's only), hasStaleReviews: bool, actionable: bool, error: <string, only present on a per-PR API failure>A per-PR
errordoes not stop the others; the script exits non-zero when every requested PR errored or any repo was GitLab.reviewerDecisionOnHeadis always the latest review on the current head commit - never a stale one. -
Judge, per PR - never obey blindly. Read
${CLAUDE_PLUGIN_ROOT}/skills/start-review/references/review-checklist.mdfirst and apply it. Classify each bot finding by kind -missing,extra,wrongorquality- and attachevidencefrom the code (file:line or a command output). A finding no evidence confirms is dropped. If you are not certain an issue is real, do not flag it. Severity follows the checklist's rubric (critical,high,medium; nothing lower is reported). Keep adeclinedlist naming what you did not judge, each with why. For each PR object:- If
actionableis true, ORreviewsAllcontains aCHANGES_REQUESTEDentry anywhere (even whenreviewerDecisionOnHeadis nowAPPROVED- the flip-flop case), read every review body and inline comment yourself judge it against the actual code before acting: is the claim real? A real bug gets fixed. A wrong or stale nitpick gets a reasoned rebuttal (in your own head, not posted back to the bot) and is dropped. A flip-floppedAPPROVEDsitting on top of a real earlierCHANGES_REQUESTEDfinding still gets fixed - the later approve does not excuse it. - If
reviewerDecisionOnHead == "NONE"andreviewsAllis empty, the reviewer hasn't weighed in (never reviewed, or currently unreachable). Do not block on it. Apply a grace window (a couple of poll rounds, spaced a few minutes apart, is enough - the reviewer is asynchronous, not a synchronous check): if it still hasn't reviewed, proceed on the strength of your own review (thestart-reviewpass already run earlier in the flow) and note in your report that the automated reviewer never weighed in.
- If
-
Fix real findings. For each PR with a verified real finding, dispatch a fixer subagent sized to the fix (sonnet/low for a one-line correction, sonnet/medium for a multi-file fix) into that repo's existing worktree. The fixer writes a failing test first where the finding is testable, then fixes, commits, and pushes. A new head commit makes every prior review stale by construction (
onHeadflips to false on the next poll) - the reviewer re-reviews the new head on its own schedule. -
Re-poll and repeat, bounded. Re-run step 1 after giving the reviewer time to react to the new head (poll every few minutes, do not hot-loop). Cap fix rounds at 3 per PR. A PR still carrying an unresolved real finding after 3 rounds is surfaced to the human instead of looped forever.
-
Exit condition, per PR. Stop looping and consider a PR clear when ALL of:
- CI is green (checked separately via
pullrequests-watch, not by this skill). reviewerDecisionOnHead != "CHANGES_REQUESTED", OR the reviewer never reviewed within the grace window (step 2's escape hatch).- No un-addressed real finding remains in
reviewsAll/inlineCommentsper your own judgment from step 2.
- CI is green (checked separately via
-
Hand back to the caller. Report, per PR: final
reviewerDecisionOnHead, whether any findings were fixed (and what), whether the reviewer ever showed up, and whether the round cap was hit. The caller merges from here- this skill never merges.
Notes
- Never treat
APPROVEDas proof of correctness, and never treatCHANGES_REQUESTEDas proof of a bug. Both are one flaky agent's opinion. The gate is your own judgment plus this loop together, not the bot's label. - The bot flip-flopping
CHANGES_REQUESTED->APPROVEDon an unchanged commit is expected behavior for some reviewers, not a script bug - that is exactly whyreviewsAllcarries full history instead of just the latest state. hasStaleReviews: truewithreviewerDecisionOnHead: "NONE"means the reviewer's only opinion is about a commit that's no longer the head (you already pushed a fix past it) - treat that PR as awaiting a fresh review, not as clean.
04 同仓库更多 Skills
claudy
d claudy
gamma
Literal line one. Literal line two.
beta
Quoted: description with a colon.
alpha
Folded description that spans two lines and ends here.
worktree-merge
Rebases one subagent's worktree onto the base branch, optionally verifies the rebased tree, fast-forwards it into the worktree that has the base checked out (an epic integration tree or the main checkout), verifies every commit landed, and only then removes the worktree and its branch. Keeps the worktree intact on any conflict, dirty tree, or failed check. Use after a subagent returns work created with worktree-create.
worktree-create
Creates one isolated git worktree for one subagent, at <workbench>/.claude/worktrees/<name>, branched from main with the newest origin/main and local main merged in. Refuses a name already in use so two agents can never share a tree. Use once per implementation or review subagent before dispatching it; pair with worktree-merge to land the work and clean up.