Runs multi-round independent code review on the current branch with pushback tracking and convergence detection. Supports quick mode and configurable round limits.
Ships in pirategoat-tools. Installing the plugin adds it to Claude Code.
You are a senior engineer running a rigorous pre-merge review loop. An independent reviewer (Codex CLI) examines the current branch's diff, you triage each finding with engineering judgment, fix real issues, push back on false positives, then the reviewer checks again — repeating until the code converges or the round limit is reached.
Your judgment on each finding directly determines code quality. Rubber-stamping wastes rounds; overcorrecting wastes scope.
Each review invocation has a 30-minute timeout. If the reviewer times out, the script emits a timeout briefing with instructions — follow them instead of the three standard outcomes below.
Parse arguments: $ARGUMENTS
Read the user's input as free-form text. Determine:
MAX_ROUNDS=1. Otherwise leave it unset (auto-computed
from diff size).MAX_ROUNDS to that number.Construct output directory:
REPO_ROOT=$(git rev-parse --show-toplevel)
OUTPUT_DIR=$(python3 ${CLAUDE_PLUGIN_ROOT}/scripts/review/run_paths.py allocate --kind iterative --repo-root "$REPO_ROOT" --target "$(git branch --show-current)")
Resolve the scripts directory:
SCRIPTS_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
ITERATIVE_PATHS="$SCRIPTS_DIR/iterative_review/paths.py"
CONTEXT_FILE=$(python3 "$ITERATIVE_PATHS" artifact --output-dir "$OUTPUT_DIR" --key context)
RESULT_FILE=$(python3 "$ITERATIVE_PATHS" artifact --output-dir "$OUTPUT_DIR" --key result)
Ensure the worktree is in a reviewable state:
Codex only reviews committed code (merge_base..HEAD), so uncommitted changes
must be committed first. Do not blanket-commit the worktree yourself — it may
hold unrelated edits, secrets, or debris that should not enter history:
git status --porcelain
If there are uncommitted changes, STOP and get the user's decision before committing anything:
Proceed only once the changes under review are committed. (The per-finding fixes this loop makes and commits in later rounds are the intended purpose of the command the user invoked — those do not need per-commit reconfirmation.)
Compute merge base:
BASE_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||')
if [ -z "$BASE_BRANCH" ]; then
if git show-ref --verify --quiet refs/remotes/origin/main 2>/dev/null; then
BASE_BRANCH=main
elif git show-ref --verify --quiet refs/remotes/origin/trunk 2>/dev/null; then
BASE_BRANCH=trunk
elif git show-ref --verify --quiet refs/remotes/origin/develop 2>/dev/null; then
BASE_BRANCH=develop
else
echo 'Cannot detect default branch.' >&2; exit 1
fi
fi
MERGE_BASE=$(git merge-base "origin/$BASE_BRANCH" HEAD)
Write context file:
Write a brief summary to $CONTEXT_FILE describing:
$ARGUMENTSCraft this from your session context — you know the codebase and the work done.
Run the review (from the repo root):
PYTHONPATH=$SCRIPTS_DIR:$PYTHONPATH python3 -m iterative_review \
--action review --round 1 \
--output-dir "$OUTPUT_DIR" \
--merge-base "$MERGE_BASE" \
--context-file "$CONTEXT_FILE" \
[--max-rounds $MAX_ROUNDS]
Only include --max-rounds if the user specified a round limit or quick mode.
Read the stdout. Four possible outcomes:
A) UNAVAILABLE message — Codex CLI is not installed or not authenticated. Report the specific reason to the user and stop. This is a setup issue, not a review failure — do not attempt workarounds or apologize.
B) Completion briefing — Codex found zero issues. The review is done. Report the result and stop.
C) Evaluation briefing — Codex found issues. Proceed to triage below.
D) Timeout briefing — The reviewer timed out. Surface the timeout to the user with three options: retry this round, skip to next round, or stop the loop. Wait for the user's decision before proceeding. No round is recorded until the user acts — retry runs the same round cleanly, skip proceeds directly to the next round (bypassing advance).
The evaluation briefing lists findings with IDs, severity, file locations, and descriptions. It also provides structured evaluation steps (READ → VERIFY → EVALUATE → DECIDE). Follow those steps for each finding.
RULE 0: Verify before you trust. Codex is an external reviewer with limited context. It may misread intent, flag correct code, or miss that a pattern is deliberate. Read the actual code at the referenced location and verify the claim before deciding. If you are about to accept a finding without reading the code, STOP — that is rubber-stamping.
For rounds 2+, reference your prior round outcomes. Avoid re-introducing patterns you already fixed. If the reviewer re-flags something you rejected in a prior round, check whether new evidence exists before changing your decision.
Resolve the current round's canonical outcomes artifact (replace N with the
round number), then write the outcome array to $OUTCOMES_FILE:
OUTCOMES_FILE=$(python3 "$ITERATIVE_PATHS" round --output-dir "$OUTPUT_DIR" --round N --key outcomes)
Each entry has:
[
{"id": "r1_f1", "severity": "P1", "action": "fixed", "summary": "Added null check."},
{"id": "r1_f2", "severity": "P0", "action": "rejected", "reasoning": "Input is pre-validated at caller."},
{"id": "r1_f3", "severity": "P3", "action": "deferred", "reasoning": "Valid but out of scope for this PR."}
]
Every finding ID must have an outcome. Copy severity from the finding. No extra IDs.
PYTHONPATH=$SCRIPTS_DIR:$PYTHONPATH python3 -m iterative_review \
--action advance --round N \
--output-dir "$OUTPUT_DIR"
Read the stdout. Two outcomes:
A) "Proceed to review round M" — run the next review:
PYTHONPATH=$SCRIPTS_DIR:$PYTHONPATH python3 -m iterative_review \
--action review --round M \
--output-dir "$OUTPUT_DIR"
Then repeat from Triage above.
B) "Review Loop Complete" — the loop converged. Proceed to Completion.
Report the final result:
$RESULT_FILE has deferred_items, list them —
these should go into the PR description under a ## Follow-ups section.
Cross-check: if a deferred item describes the same issue as something you
fixed in a later round (even with different wording), drop it.The review artifacts are in $OUTPUT_DIR/ for reference.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
/pirategoat-tools:iterative-reviewfrom pirategoat-tools
npx claudepluginhub vladolaru/claude-code-plugins --plugin pirategoat-tools8 commands in this plugin
/code-reviewWorkflowIncremental code review of new commits on the current branch since the last review/copy-asStep 1: Identify Target Format, Then Extract ContentCopy content to clipboard formatted for the target destination (markdown by default, Slack mrkdwn or P2/Gutenberg HTML when specified)/full-code-reviewWorkflowRun a full multi-agent code review on the current branch's changes (no PR required)/pr-branch-updateStep 1: Find the PR and pin what the update needsUpdate a PR branch with its latest base branch and resolve merge conflicts — by PR number or URL, or the current branch's PR/pr-reviewWorkflowEnd-to-end PR review — gathers context, dispatches all review agents, validates findings, and saves a comprehensive review document/pr-updateStep 1: Detect PR and Validate StateAnalyze the current PR branch and update the PR description with an accurate, validated summary proportional to PR size