/codereview:codereviewfrom codereview
Pre-PR code review with severity grading, tiered model routing, and whole-repo sweep. Detects TOCTOU races, accessibility gaps, hardcoded secrets, silent failures, docs drift, and dead code. Produces a structured report with Overall Grade and Recommended Actions.
Ships in codereview. 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.
$ARGUMENTS
Read the user input before proceeding (if not empty). Valid inputs:
security, performance, types, bugs, tests, docs, a11y, race-conditions, dead-codebaseDir=app/ fileExtensions=ts,jsfull, prompts
unchanged; answer each named point in Phase C and say where it was checkedaté nota A / until grade A: review rounds with the fixes between them, each round read-only
(configuration.md, Re-review rounds)Defaults are baseDir=src/, fileExtensions=ts,tsx, frameworkPatterns=react, tests **/*.{test,spec}.{ts,tsx} and **/test/**, UI_LIB src/components/ui/**, prisma/**, **/generated/**, CONFIG *.config.*, tsconfig*, .env*, package.json.
Perform a comprehensive, automated code review of all changes in the current branch compared to the base branch. Produce a structured Markdown report with severity-rated findings, test coverage assessment, and a final grade.
This skill is stack-agnostic. Defaults target TypeScript/React but all values are configurable.
The agents read their own contract by absolute path ({SKILL_DIR}/references/…); the orchestrator
reads a file only at the step that needs it:
references/configuration.md — where cited below, and when $ARGUMENTS has key=value overrides
or names a repo besides the cwd, the stack is not TypeScript/React or a doc holds code a step
runs.references/per-file-agent.md — read it yourself only if Phase B runs inline (≤3 CODE files):
the Phase B agent contract.references/verification-round.md — read it when a re-review range (base= from an earlier round) has
prose files: when the verification round runs, its launch and its Phase C closing rule. The verifier,
always an agent, loads its own contract, references/verify-agent.md.references/sweep-agent.md — read it yourself when the sweep runs inline or the agent under-reports
and you redo the deepsearch: the Phase B2 contract.references/detection-passes.md — read it yourself when a phase runs inline, and in Phase C for the
recalibration rules and the pass 6.10 remediation block (the agents load it on their own): every
pass (Zen 5.x, 6.1–6.12) and its severity rules.references/toctou-patterns.md — the TOCTOU catalog with code examples. Agents load it only for
check-then-act shapes; read it in Phase C when a race spans files (check in one, act in another).references/report-template.md — read at Phase C step 10, before writing the report.assets/trigger-evals.json — read before changing the description.| Phase | Task | Runs in | Why |
|---|---|---|---|
| A | Git context, file classification, test mapping, secrets pre-scan | inline (main session) | Fixed commands with one right answer |
| B | Per-file analysis (detection passes) | review-model agents, in parallel | Pattern matching on code, no deep reasoning |
| C | Cross-file review, severity calibration, report | Main model (whatever the session runs) | Judgment, cross-references, a coherent report |
≤3 CODE files → skip routing and run Phase B inline too; the agent overhead isn't worth it, except on code this session wrote (configuration.md, Code this session wrote).
Before B/B2, read references/runtime-routing.md for model selection and complete result capture.
Bind REVIEW_MODEL: Codex → gpt-6.1-terra; Claude Code → sonnet. Pass it explicitly.
Read-only. The report in the conversation is the only output; it suggests fixes, never applies them. Don't modify, create, or delete files or run destructive commands — everything it runs (git, grep, the secrets script, dead-code tooling) is a pure read.
Could not analyze: {filename} ({reason}).Regardless of failures, always produce a final report listing all files analyzed and all failures.
Every step is a fixed command with one right answer, so it runs inline, not in an agent: an agent only adds variation, latency and the chance of a silently dropped field — and without the secrets pre-scan JSON the F-grade gate goes blind. Outputs are small.
Apply any $ARGUMENTS overrides before classifying, and keep the raw outputs. Three Bash turns cover steps 1–8 — (1) steps 1–3, base-branch detection as one fallback chain, and git ls-files '*handoff*', with the version and installPath read in separate calls (configuration.md, Stale copy); (2) step 4; (3) steps 5–8 as parallel calls in one message:
git rev-parse --is-inside-work-treegit ls-remote --symref origin HEAD, main, master; stale base, merged branch, worktree: configuration.md, Base and batchinggit rev-parse --abbrev-ref HEADgit merge-base {BASE_BRANCH} HEAD, or the base commit the user names (base=<sha>, even in prose); an end other than HEAD is head=<sha> (configuration.md)git diff {MERGE_BASE}...HEAD --name-onlygit diff {MERGE_BASE}...HEAD --statgit log {MERGE_BASE}..HEAD --oneline --no-decorategit diff {MERGE_BASE}...HEAD --unified=0 | bash {SKILL_DIR}/scripts/scan_secrets.sh
({SKILL_DIR} = absolute path of this SKILL.md's directory). It prints JSON {findings:[...], scanners:[...], errors:[...]}; keep it verbatim as SECRETS_PRESCAN, the authoritative source for Phase C's Secrets Detection table and F-grade gate. A crash or non-JSON output means the scan did not run: warn the user and re-run it — an absent payload is never "scan returned clean".base= from an earlier round), in step 8's batch: python3 {SKILL_DIR}/scripts/prose_units.py --repo . --base {MERGE_BASE} --head HEAD, where head=<sha> replaces HEAD as in steps 4–8; keep its JSON as PROSE_SCOPE (each file's kind, units and identifiers, and the totals). A non-zero exit means no scope, never "no prose files": the round runs in full, and the report says so. worktree mode has no verification round.Classify each changed file:
bin/tool, #!/usr/bin/env bash)For each CODE file, probe candidate test file paths — same dir ({Base}.test.{ext}, {Base}.spec.{ext}), a __tests__ sibling, then the project test root, then a changed test that imports it — and record it as WITH_TESTS / STALE_TESTS / NO_TESTS. Probe all CODE files in one Bash call (path|status each), a scratchpad script in bash with nullglob (configuration.md, Test probe): zsh aborts an unmatched glob, and a bare == as = not found.
Phase A hands Phases B and C: BASE_BRANCH, BRANCH_NAME, MERGE_BASE, DIFF_STAT, COMMIT_LOG, the FILES list (path, category, test_status), COUNTS per category, SECRETS_PRESCAN and, on a re-review, PROSE_SCOPE.
If CHANGED_FILES empty, dirty git status --porcelain → worktree mode (references/configuration.md). Both empty → output "No changes detected between this branch and {BASE_BRANCH}." and stop — unless the user scoped paths: then empty is a pathspec error (configuration.md §Path-scoped reviews).
More than 15 CODE files: order the groups by change size (diff stat lines); every file still gets an agent, none is cut.
For each CODE file (or group of 2-3 small files sharing imports), each changed TESTS file on a test-quality focus (6.12) and each DOCS file this session, its pipeline or the handoff it continues wrote (configuration.md, Docs this session wrote), spawn a review-model agent to analyze it. Launch all agents in parallel, in one message.
Each agent reads its instructions itself from {SKILL_DIR}/references/per-file-agent.md, so every agent gets the same contract. Emit only the launch prompt below, placeholders filled — nothing added (no themes, framing or reproduction requests: those come back marked needs reproduction), nothing removed; exception: a refused Read under {SKILL_DIR} (runtime-routing.md, Contrato ilegível). model: REVIEW_MODEL on every call.
Agent(model: REVIEW_MODEL, prompt: "
Start with ONE batch of parallel tool calls: Read {SKILL_DIR}/references/per-file-agent.md,
Read {SKILL_DIR}/references/detection-passes.md, run `git -P diff {MERGE_BASE}...HEAD -- {FILE_PATH}`,
and Read {FILE_PATH}. Then follow per-file-agent.md exactly — it carries your instructions,
scope and output format.
- Repository: {REPO}
- Branch: {BRANCH_NAME} → {BASE_BRANCH}
- Merge base: {MERGE_BASE}
- Framework: {frameworkPatterns}
- File: {FILE_PATH} (category: {CATEGORY}) — one line per file in the group
- Focus area: {FOCUS or 'full'}
- Skill dir: {SKILL_DIR}
- Hard rules: {CLAUDE.md prohibitions, verbatim, or none}
")
The agent returns a numbered findings list (N. [SEVERITY] {category} — {file}:{line} — {title}, with Description and Suggestion), or No findings for {FILE_PATH}, and ends with Tool calls: … | Files read in full: … and END_OF_FILE_REVIEW.
Grouping: files that import from each other share an agent when possible (max 3), catching intra-group issues without the main model. A TOCTOU race spanning files (service reads, controller acts) is flagged single-file with "cross-file verification needed"; Phase C judges it.
Verification round. On a re-review whose PROSE_SCOPE has a DOCS or DOC_ONLY file, read
references/verification-round.md first: it holds the conditions and the routing. When they hold, the
files it routes go to verifier agents, never inline, and every other file of the range keeps this phase
as written.
Spawn one dedicated agent for pass 6.9 (Dead Code & Unused Symbols), in the same parallel batch as the Phase B agents. It is separate because dead code is a whole-repo reference-graph question: a per-file agent sees one file and cannot tell whether an exported symbol is referenced elsewhere. This agent gets the changed-file list, the diff, and grep/tooling access to the whole repo.
When to run it:
$ARGUMENTS) → run it, with Bucket A only — what this PR introduced or orphaned.knip/ts-prune/vulture…, capped) runs only on focus dead-code or sweep=full. It was the expensive part of the sweep and none of it belongs to the PR; the report says in one line how to get it.dead-code → run it and skip the per-file passes (the only analysis). Focus bugs → run it (dead code often masks or accompanies bugs).security, a11y, types, performance, docs, tests, race-conditions) → skip it. Unlike 6.10, dead code is hygiene, not a gate; in a focused security review it is noise.Output discipline: the orchestrator sees only the agent's final assistant message, never its grep/tool outputs — so that message is the filled return template from sweep-agent.md (ending in END_OF_DEAD_CODE_SWEEP), not "done". Launch prompt, placeholders filled:
Agent(model: REVIEW_MODEL, prompt: "
Start with ONE batch of parallel tool calls: Read {SKILL_DIR}/references/sweep-agent.md,
Read {SKILL_DIR}/references/detection-passes.md (pass 6.9), and run `git -P diff {MERGE_BASE}...HEAD`.
Then follow sweep-agent.md exactly — it carries the two buckets, the guardrails and the
return template.
- Repository root: {REPO}
- Branch: {BRANCH_NAME} → {BASE_BRANCH}
- Merge base: {MERGE_BASE}
- Framework: {frameworkPatterns}
- Changed CODE/CONFIG files: {LIST_OF_CHANGED_FILES}
- Focus area: {FOCUS or 'full'}
- Sweep: {full | pr} — `full` only when `$ARGUMENTS` carries `sweep=full`
- Skill dir: {SKILL_DIR}
- Hard rules: {CLAUDE.md prohibitions, verbatim, or none}
")
Under-report (no END_OF_DEAD_CODE_SWEEP, or a bare status sentence) → re-run the grep deepsearch inline for the changed files; unlike the secrets gate, a missing dead-code result is non-blocking — note "dead-code sweep incomplete" and proceed.
After all review-model agents return, the main model:
END_OF_FILE_REVIEW line is partial: keep what it reports and mark the file partially analyzed in the report
secrets_prescan.findings is authoritative — every entry is real (regex matched + exception filter applied) and goes straight into the Secrets Detection table.secrets_prescan (by {file, line, kind}) enters the table only if (a) it shows a concrete literal credential, not a category like "potential leak", AND (b) it matches a 6.10 category or a clear equivalent; otherwise drop it as low-signal speculation.{file, line, kind}; on collision, keep the higher severity and prefer source=ggshield > gitleaks > regex > agent for provenance.catch syntax. A per-file claim that a future drift would blind a site was made without the tests: find the test that pins it before keeping the severity (detection-passes.md 6.11).secrets_prescan OR ≥1 entry from an agent that survived the supplemental filter in step 2:
secrets_prescan.errors is non-empty (script crashed, ggshield timed out), also surface a warning to the user — the gate may have under-reported.dead-code focus or sweep=full):
BUCKET_B: skipped → the template's one-line note instead of a table.references/report-template.md; order:
BLOCKED banner (only if step 8 triggered) · Secrets Detection table (always; "Status: PASS" with
0 rows when clean) · findings table (CRITICAL > HIGH > MEDIUM > LOW, grouped by file) · Zen
Principles summary · Bug/Security/Performance/Types summary · test coverage table · documentation
sync table · 🧹 Dead Code & Cleanup (when the sweep ran — Bucket A primary, Bucket B as a capped
pre-existing summary when on; dead-code findings also feed Recommended Actions → Consider Fixing
and the Code Quality rationale) · Overall Grade table · Recommended Actions (every bucket,
_None._ when empty) · Cost footprint line, last.The Overall Grade table, the Recommended Actions block and the Cost footprint close every report, in full even with little to say: the template's fallbacks, never prose in place of the table.
/cost (or the harness's per-session cost log) before and after any change to this skill; a change
without that pair of numbers is a guess.base=<head the last round reviewed> and stops at the first round with no MEDIUM or worse and no
behavior finding (report-template.md, Documentation row); a fix written as prose is the
likeliest home of the next finding (measured 11 → 5 → 3 → 0).*** (the report itself is copied into chat history).assets/trigger-evals.json (opens in a new tab)references/configuration.md (opens in a new tab)references/detection-passes.md (opens in a new tab)references/per-file-agent.md (opens in a new tab)references/report-template.md (opens in a new tab)references/runtime-routing.md (opens in a new tab)references/sweep-agent.md (opens in a new tab)references/toctou-patterns.md (opens in a new tab)references/verification-round.md (opens in a new tab)references/verify-agent.md (opens in a new tab)scripts/prose_units.py (opens in a new tab)scripts/scan_secrets.py (opens in a new tab)scripts/scan_secrets.sh (opens in a new tab)tests/test_prose_contract.py (opens in a new tab)tests/test_prose_units.py (opens in a new tab)tests/test_scan_secrets.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub j0ruge/skills --plugin codereview2 skills in this plugin
Other plugins' skills for the same job