Claude Code as the reviewer
A reviewer script for replz that gives Claude Code your REVIEW.md as it was at the case's base, the diff, and a two-stage answer format, so replz can grade raw and verified findings separately.
replz grades whatever reviewer command the config names. This recipe is the script burgee uses
on itself, .sdlc/replz/reviewer.sh: it builds a prompt from the rules the repository had at the
case's base, asks for findings in two stages, and prints the JSON replz reads. Swap claude -p
for any command that reads a prompt on stdin.
The script
Keep it in your checkout, for example at .sdlc/replz/reviewer.sh:
#!/usr/bin/env bash
# The reviewer `replz run` grades. It runs in the case's worktree at its head, with REPLZ_BASE
# set, and prints the findings as a JSON array on stdout.
set -euo pipefail
: "${REPLZ_BASE:?replz sets REPLZ_BASE; run this through replz run}"
reviewer=${REPLZ_REVIEWER:-claude -p}
prompt=$(mktemp)
trap 'rm -f "$prompt"' EXIT
{
echo 'You review one pull request. Report what must change before it merges.'
echo
echo '## The rules (REVIEW.md, from the base branch)'
git show "$REPLZ_BASE:REVIEW.md" 2>/dev/null || echo '(none at this base)'
echo
echo '## The diff'
git diff --no-color "$REPLZ_BASE" HEAD
echo
cat <<'PROMPT'
## Your answer
Work in two stages. First list every problem you notice (stage "raw"). Then check each one against
the code and keep only those you confirmed (stage "final"); a dropped one stays in "raw" only.
Print only a JSON array, no prose, of objects:
{"stage": "raw" | "final", "severity": "must-fix" | "should-fix" | "nit" | "pre-existing",
"text": "<one sentence: what is wrong and where>", "item": "<checklist item id, if one prompted it>"}
Leave "item" out when no checklist item prompted the finding. Print [] when there is nothing.
PROMPT
} > "$prompt"
# The model may fence its JSON; print the array alone.
$reviewer < "$prompt" | sed -n '/^\[/,/^\]/p'- The rules come from the base, through
git show "$REPLZ_BASE:REVIEW.md". A bug from last year is reviewed with last year's rules, which is what the reviewer had when it missed it. To measure today's rules on old bugs instead, read the file from your checkout. - The diff is base to head, the pull request as the reviewer saw it. The worktree holds the whole tree at head, so a reviewer that reads more files can.
- Two stages from one call.
rawandfinallet the report show a bug found and then dropped by the reviewer's own check. - burgee's own script also adds the checklist items triggerlist
selects for the diff, so findings can name an
itemand the report can count each item.
The config
setup: npm ci --ignore-scripts --no-audit --no-fund
reviewer: bash "$REPLZ_REPO/.sdlc/replz/reviewer.sh"
grader: claude -p --model {model}
maxFindings: 10
stages: [raw, final]
checks: []The reviewer's path goes through $REPLZ_REPO because the command runs inside
the case's worktree, at an old commit where the script may not exist yet. The
config explains it.
Run it
REPLZ_REVIEWER="claude -p --model <the model CI reviews with>" \
npx replz run --set tune --model <the cheapest current model>The reviewer runs with the model CI uses, so the score is the score of what ships. The grader
runs with the cheapest model that grades reliably, because it is called once per finding.
REPLZ_REVIEWER is split on spaces, so its words cannot hold spaces themselves.
Try the wiring on one case with a stand-in reviewer first: a failure on case nine of twenty has already paid for eight reviews.
Coming from promptfoo
Move the code-review part of a promptfoo suite to replz: hand-written review prompts become pull requests that shipped a bug, assertions become a one-sentence answer key graded per finding, and the report adds controls, recall per stage and a firing count for each check.
A stand-in reviewer
Check that the replz config, the worktrees, the checks and the report all work before paying for a model: a reviewer and a grader written as two small Node scripts, run with the real replz run on a real history.