review
Multi-agent code review of local Python files, directories, or the current git diff covering architecture, tests, performance, docs, lint, security, and API design. Scope: Python source files in local working tree. Python-file-free targets (pure JS/TS/Go/Rust projects) are out of
Install
npx skills add https://github.com/Borda/AI-Rig/tree/main/plugins/cc_develop/skills/review
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install borda-ai-rig@llmmart
git clone https://github.com/Borda/AI-Rig.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole borda/ai-rig collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Improvement claim evidence
Assess every material improvement claimed in the request, PR title/body or reviewed documentation, including claims without supplied benchmarks.
- Record each claim, its scope and evidence in the existing review report.
- Include the relevant claims, supplied evidence and this measurement protocol in reviewer context; the parent reconciles claim dispositions in the final report even when a specialist is omitted.
- Route performance claims to the performance dimension when admitted by the existing selection rules; the parent retains claim coverage when that dimension is not selected.
- Preserve existing scope, fan-out limits and execution permissions; inspection-only reviewers hand feasible reproduction checks to the parent.
- Behavioral claims need targeted tests; correctness tests alone do not prove performance or model-quality gains.
Bind numerical comparisons to exact baseline/candidate revisions, commands, representative workload/data, software, relevant hardware and settings. Attribute supplied results separately from independent reproduction. Use a predefined practical tolerance, appropriate warmup and accelerator timing, repeated measurements, raw samples, sample counts, summary statistic and variability. Check correctness and material tradeoffs. Explain hardware relevance and limit conclusions to measured workloads/devices.
Shared local CPU/GPU, memory pressure or swapping, I/O contention and thermal/power changes can confound measurements.
- Record relevant observable contention and unavailable observations; never assume isolation.
- Run comparable baseline/candidate samples sequentially in paired, alternating or randomized order; avoid concurrent competing benchmarks or agent-owned heavy checks.
- Bound reruns and retain noisy attempts and exclusion criteria.
- More samples do not remove systematic bias.
- Never stop unrelated processes or change system resource controls without existing authorization.
- If noise or unequal contention could explain the effect, label measurements inconclusive and name the quieter or representative-hardware check needed; do not confirm or refute the claim from that run.
Conclude supported, contradicted or unverified per claim, with provenance, tested scope and whether independent reproduction succeeded. Missing hardware or unresolved noise leaves the claim unverified with prerequisite, owner and next check; feasible unperformed checks remain incomplete. Reliable counterevidence is required for contradiction. Missing verification alone is a coverage limit, not a source defect or grounds for rejection. Preserve each workflow's existing readiness and confidence contract.
Files (ai-rig)
-
templates
-
brief-challenger.md 722 B
Loading… -
brief-doc-scribe.md 1.2 KB
Loading… -
brief-linting-expert.md 353 B
Loading… -
brief-perf-optimizer.md 754 B
Loading… -
brief-qa-specialist.md 2 KB
Loading… -
brief-security-augmentation.md 1.1 KB
Loading… -
brief-solution-architect.md 963 B
Loading… -
brief-sw-engineer.md 4.6 KB
Loading… -
consolidator-prompt.md 14.5 KB
Loading… -
review-checklist.md 4.5 KB
Loading… -
review-report.md 4.2 KB
Loading…
-
-
SKILL.md 82.1 KB
--- name: review description: 'Multi-agent code review of local Python files, directories, or the current git diff covering architecture, tests, performance, docs, lint, security, and API design. Scope: Python source files in local working tree. Python-file-free targets (pure JS/TS/Go/Rust projects) are out of scope. TRIGGER when: user asks to review local Python files, a directory, or the current git diff/working-tree changes, with no GitHub PR number involved; phrases: "review this", "review my changes", "code review this diff", "review src/foo.py". SKIP when: input is a bare GitHub PR/issue number (use `/oss:review <PR#>`, requires oss plugin); user wants the Codex-native tiered `$code-review` workflow (codex-rig plugin, JSON artifact + specialist fan-out) — different toolchain; implementation work (use `/develop:fix` or `/develop:feature`); non-Python-only projects.' argument-hint: '[python-file|dir] [--no-challenge] [--challenge] [--codemap] [--no-codemap] [--worktree] [--full] [--keep "<items>"]' allowed-tools: Read, Write, Bash, Grep, Glob, Agent, Skill, TaskList, TaskCreate, TaskUpdate, AskUserQuestion, EnterWorktree, ExitWorktree disable-model-invocation: true effort: high --- <objective> Comprehensive code review of local files or working-tree diff. Spawns specialized sub-agents in parallel, consolidates findings into structured feedback with severity levels. NOT for: - GitHub PR review (use `/oss:review <PR#>` (requires oss plugin)) - GitHub thread analysis or PR reply drafting (use `/oss:analyse <PR#>` (requires oss plugin)) - implementation (use `/develop:feature` or `/develop:fix`) - `.claude/` config changes (use `/foundry:manage` (requires foundry plugin) or `/foundry:audit` (requires foundry plugin)) - non-Python-only projects (zero Python source files — pure JS/TS/Go/Rust) — review toolchain assumes Python/pytest - Python test-only targets where diff contains only test files (no `src/` or top-level `.py` source outside `tests/`) — review is uninformative Polyglot projects with Python source review Python files only. </objective> ## Improvement claim evidence Assess every material improvement claimed in the request, PR title/body or reviewed documentation, including claims without supplied benchmarks. - Record each claim, its scope and evidence in the existing review report. - Include the relevant claims, supplied evidence and this measurement protocol in reviewer context; the parent reconciles claim dispositions in the final report even when a specialist is omitted. - Route performance claims to the performance dimension when admitted by the existing selection rules; the parent retains claim coverage when that dimension is not selected. - Preserve existing scope, fan-out limits and execution permissions; inspection-only reviewers hand feasible reproduction checks to the parent. - Behavioral claims need targeted tests; correctness tests alone do not prove performance or model-quality gains. Bind numerical comparisons to exact baseline/candidate revisions, commands, representative workload/data, software, relevant hardware and settings. Attribute supplied results separately from independent reproduction. Use a predefined practical tolerance, appropriate warmup and accelerator timing, repeated measurements, raw samples, sample counts, summary statistic and variability. Check correctness and material tradeoffs. Explain hardware relevance and limit conclusions to measured workloads/devices. Shared local CPU/GPU, memory pressure or swapping, I/O contention and thermal/power changes can confound measurements. - Record relevant observable contention and unavailable observations; never assume isolation. - Run comparable baseline/candidate samples sequentially in paired, alternating or randomized order; avoid concurrent competing benchmarks or agent-owned heavy checks. - Bound reruns and retain noisy attempts and exclusion criteria. - More samples do not remove systematic bias. - Never stop unrelated processes or change system resource controls without existing authorization. - If noise or unequal contention could explain the effect, label measurements inconclusive and name the quieter or representative-hardware check needed; do not confirm or refute the claim from that run. Conclude supported, contradicted or unverified per claim, with provenance, tested scope and whether independent reproduction succeeded. Missing hardware or unresolved noise leaves the claim unverified with prerequisite, owner and next check; feasible unperformed checks remain incomplete. Reliable counterevidence is required for contradiction. Missing verification alone is a coverage limit, not a source defect or grounds for rejection. Preserve each workflow's existing readiness and confidence contract. <inputs> - **$ARGUMENTS**: optional file path or directory to review. - Path given: review those files - Omitted: review current git diff (`git diff HEAD` — staged + unstaged vs HEAD; with `--worktree`, the last commit `HEAD~1..HEAD`) - **Scope**: Python source only. Non-Python file (YAML, JSON, shell script, etc.) → state out of scope, suggest appropriate tool. No findings. - `--no-challenge`: skip adversarial review (challenger runs by default) - `--challenge`: accepted for compatibility, no effect — challenger runs on every diff size unless `--no-challenge` - `--full`: run **every** dimension classification preselected, instead of only the `FANOUT_MAX` most relevant. Never widens preselection — a dimension the FIX/CHORE/impact-tier rules ruled out stays out. **Not free**: each extra agent costs ~120,851 tok fixed overhead however little work it does. Default stays capped; pass this when depth matters more than cost. - `--codemap`: strict mode — stop and report if codemap not installed (on by default when installed; use `--no-codemap` to opt out) **PR#/filename disambiguation gate** (its block runs in §Flag parsing, right after the flag block — BEFORE Worktree isolation and Step 1): valid PR# is positive integer (optional leading `#`) with no extension and no existing file at that path. - Filenames that look like numbers (e.g. `42.py`) must NOT trigger PR mode. - `dev_parse_args.py` classifies the flag-stripped target, so `42 --full` still counts, and writes the bare number or empty to the `dev-review-pr-number` sentinel; the gate block reads it, checks oss through the install record and prints `OSS_AVAILABLE=` and `PR_NUMBER=`. - "Proceed to Step 1" below = continue the workflow: Worktree isolation, then Step 1. `$OSS_AVAILABLE` is `skip` → proceed to Step 1 normally (path / diff / dir mode). `$OSS_AVAILABLE` is `true` → call `AskUserQuestion` ONCE with BOTH questions in the same call (a second sequential window costs another human-idle round trip): - Q1: "Looks like you passed a PR/issue number. Did you mean to run `/oss:review $ARGUMENTS` (requires oss plugin) to review that PR?" Options: (a) "Yes — launch `/oss:review $ARGUMENTS`" · (b) "No — review local code". - Q2: "If reviewing local code: provide the file path or directory (free text; skip if Q1 = Yes)". Answer handling: - On (a): call `Skill(skill="oss:review", args="<PR_NUMBER>")` with the bare number the gate block printed (never the flags passed beside it), ignore Q2, then stop — do not enter Step 1. - On (b): persist the Q2 response as the review target (block below), proceed to Step 1 (Q2 empty → ask once more for the path). Persist block for Q2 (shared by both branches) — substitute `<Q2 path>` with the user's answer; it replaces the PR number in the clean-args sentinel Step 1 re-reads: ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" Q2_PATH='<Q2 path>' case "$Q2_PATH" in *'<'*'>'*|"") echo "! BLOCKED — Q2 path unsubstituted"; exit 1;; esac echo "$Q2_PATH" > "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" ``` `$OSS_AVAILABLE` is `false` → call `AskUserQuestion` ONCE with BOTH questions — Q1: "Looks like you passed a PR/issue number, but oss plugin not installed — `/oss:review` unavailable. Review local code instead?" Options: (a) "Yes — review local code" · (b) "I need oss plugin". Q2: "If reviewing local code: provide the file path or directory (free text; skip if Q1 = b)". On (a): persist the Q2 response with the block above, proceed to Step 1 (Q2 empty → ask once more). On (b): inform user: install with `claude plugin install oss@borda-ai-rig`, then stop — do not enter Step 1. </inputs> <constants> ```text FANOUT_MAX=FANOUT_CAP # use the runtime cap printed by §Flag parsing; that block owns the numeric default # cap counts dimension spawn units only; real default lineup = up to 3 # dimension units + challenger + bridge co-review + consolidator # (+ up to 3 cross-validation verifiers when criticals exist) # --full runs ALL preselected units instead — no numeric cap AGENT_CALL_BUDGET=55 # target tool-calls per agent; past ~60 they stall without returning an envelope CHALLENGE_ENABLED=true # set to false via --no-challenge CHALLENGE_FORCED=false # set to true via --challenge — no-op kept for saved invocations; challenger runs at any diff size CODEMAP_ENABLED=auto # on by default if codemap installed + index found; --no-codemap = off; --codemap = strict (stop if not installed) ``` </constants> <compaction> - Key boundary: end of Step 3 — parallel review-agent fan-out outputs collected, before Step 5 consolidation. - Second boundary: end of Step 5 — consolidated report written, before Step 6 follow-up. - Third boundary: immediately before the Step 6 follow-up gate — the idle window; refresh makes a mid-wait `/compact` lossless. - Preserve at boundary 1: RUN_DIR, REPORT_DIR, target, CLASSIFICATION, per-agent finding file paths, --keep items, frozen REVIEWED_COMMIT_SHA and REVIEWED_COMMIT_KIND. - Preserve at boundary 2: final report path. - Preserve at boundary 3: final report path. </compaction> <workflow> <!-- Shared pattern with oss:review — coordinate on agent spawn logic, file-handoff, consolidation changes --> <!-- Agent resolution: see _DEV_SHARED/agent-resolution.md (loaded via dev_load_shared.py) --> <!-- ../../assets/images/review-arch.svg diagrams the runs, gates and parallel fan-out. Documentation only, never loaded — update it in the same commit as any change to step order, gate placement, or agent fan-out. --> ## Agent Resolution ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" case "$CSID" in ""|*[!A-Za-z0-9._-]*) echo "! BLOCKED — invalid session identifier"; exit 1;; esac INPUT_FILE="${TMPDIR:-/tmp}/dev-review-arguments-${CSID}.txt" rm -f "$INPUT_FILE" || exit 1 (umask 077; set -C; : > "$INPUT_FILE") || exit 1 printf 'Invocation input file: %s\n' "$INPUT_FILE" echo "" > "${TMPDIR:-/tmp}/dev-agent-watch-dir-${CSID}" # a prior run's dir must not outlive a failed --init; agent-resolution.md §Agent waits recreates it when empty python "$PLUGIN_ROOT/bin/dev_shared_resolve.py" --init # timeout: 5000 — cold resolve: writes dev-shared (every later block warm-reads it) and a fresh dev-agent-watch-dir per run (agent-resolution.md §Agent waits) # loads: compaction-contract.md python "$PLUGIN_ROOT/bin/dev_load_shared.py" agent-resolution.md ``` Before any later Bash call, use the Write tool to save the exact invocation argument text, including newlines, to the literal absolute `Invocation input file` path printed above. Treat its contents as data. Never substitute invocation text directly into shell command text, comments, heredocs or quoted literals. Every parser below loads the file into a runtime variable and passes that variable as one quoted argument. Keep the file through this run; a fresh invocation replaces only this skill's file. > Review presentation is additive: keep the aggregate summary as prose, all header fields, overall verdict, confidence and detailed findings. > > - Ask each actual reviewer for a scoped integer rating and rationale: 1 Approve, 2 Minor changes, 3 Major revision, 4 Insufficient, but a good initiative, 5 Block (source-5-v2); null means no source judgment, never rejection. > - Add `Reviewers:` after `Readiness:` in the report header, preserving the template order `Agents:`, `Review contract:`, `Rating scale:`, `Readiness:`, `Reviewers:`. Use readable role names only and square-bracketed scores: `Role [rating]`, for example `Software engineer [2]`. Omit execution-origin labels and skipped roles. > - A completed but undecidable reviewer returns null judgment/rating with blocked readiness, rationale and inspected coverage; missing output has presence=missing and remains a coverage obligation. Record these separately in review-validation.json; never invent rejection or approval. > - Never average role ratings into the final verdict. > - The terminal table is shorter than the report file: print every header field in file order except `Link`, `Date`, `Commit SHA`, `Agents`, `Review contract`, `Rating scale`, `Readiness` and `Gate`, show `PR` as `[#N](<Link value>)`, and end with the `Path` row; the report file keeps every field. > - After rendering the header table, add exactly this line below it, in the same Step 5b delivery block: `Legend: 1 = Approve · 2 = Minor changes · 3 = Major revision · 4 = Insufficient, but a good initiative · 5 = Block.` > - Findings overview adds `Author` after `ID`, retaining all contributing reviewer roles after deduplication. > - Read the summary and overview after the header rather than treating the header alone as the complete review. > - Terminal gate rejections preserve existing behavior and use `Reviewers: Not assessed` when no source reviewer ran. Contains: foundry check + fallback table. If foundry not installed: substitute each `foundry:X` with `general-purpose` per table. Agents this skill uses: `foundry:sw-engineer`, `foundry:qa-specialist`, `foundry:perf-optimizer`, `foundry:doc-scribe`, `foundry:linting-expert`, `foundry:solution-architect`, `foundry:challenger`. **Task hygiene** — task tools may be deferred; load before first use: `ToolSearch(query="select:TaskList,TaskCreate,TaskUpdate,TaskGet", max_results=4)`. Call `TaskList` first and triage each task it returns: `completed` if work clearly done, `deleted` if orphaned, keep `in_progress` only if genuinely continuing. Never spend a turn on bookkeeping alone — every `TaskCreate`/`TaskUpdate` ships in the same response as the next substantive tool call; one exception, `TaskUpdate(completed)` immediately before a long output block (`rules/task-lifecycle.md`). After Step 1 completes (scope and `TARGET` known), create these tasks **before any agent spawns** (in order, all at once): - **"Step 1: Identify scope"** — mark `in_progress` at Step 1 start; mark `completed` when `TARGET` and `SCOPE` set and Python file check passes - **"Step 2: Codex co-review"** — create before Step 2 (skip task if Codex unavailable); mark `in_progress` before Codex spawn; mark `completed` when codex seed extracted (or timed out) - **"Step 3: Spawn review agents"** — mark `in_progress` before agents launch; mark `completed` when all agent output files collected (or health-monitoring cutoff reached) - **"Step 4: Cross-validate critical findings"** — mark `in_progress` before verifier spawns; `completed` when all verdicts received; **skip task creation when no critical/blocking findings exist after Step 3** - **"Step 5: Consolidate findings"** — mark `in_progress` before spawning consolidator; `completed` when consolidator returns its JSON envelope (Write to `review-report.md` done) — **do NOT mark completed for the terminal print, that's a separate task below** - **"Step 5b: Print report header"** — created **blockedBy** "Step 5: Consolidate findings"; mark `in_progress` immediately after the consolidator returns. Read the report and build the header table and question summary now; keep it `in_progress` through the question. Mark `completed` only in the response that delivers the table in the final reply after the answer (or on a no-question path), beside the last tool calls immediately before that output, never merely when queued/intended. - Consolidator's JSON envelope is a routing signal for the orchestrator, never a substitute for reading `$REPORT_DIR/review-report.md` and rendering its header. - **The follow-up `AskUserQuestion` must not fire until the current report has been read and its header table and plain summary are built** — the dedicated task tracks final delivery separately; issuing the question does not complete it. ## Flag parsing Strip flags from `$ARGUMENTS` before using as path: ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" INPUT_FILE="${TMPDIR:-/tmp}/dev-review-arguments-${CSID}.txt" [ -f "$INPUT_FILE" ] && [ ! -L "$INPUT_FILE" ] && [ -O "$INPUT_FILE" ] || { echo "! BLOCKED — invocation input missing or untrusted; Write the arguments to the printed Invocation input file first"; exit 1; } ARGUMENT_BLOB=$(cat "$INPUT_FILE" && printf x) || exit 1 ARGUMENT_BLOB=${ARGUMENT_BLOB%x} # preserve trailing newlines without evaluating the text python "$PLUGIN_ROOT/bin/extract-keep-flag.py" dev-review "$ARGUMENT_BLOB" # timeout: 5000 — parses --keep, clears stale contract python "$PLUGIN_ROOT/bin/dev_parse_args.py" --skill review --write-files "$ARGUMENT_BLOB" # writes ${TMPDIR:-/tmp}/dev-review-{no-challenge,codemap,clean-args,pr-number}-${CSID} + legacy paths IFS= read -r REVIEW_ARGS < "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" 2>/dev/null || REVIEW_ARGS="" # strip --keep so it doesn't leak into find/git diff target path REVIEW_ARGS=$(echo "$REVIEW_ARGS" | sed -E 's/ *--keep +"[^"]+"//' | xargs 2>/dev/null || echo "$REVIEW_ARGS") IFS= read -r CHALLENGE_ENABLED < "${TMPDIR:-/tmp}/dev-review-challenge-enabled-${CSID}" 2>/dev/null || CHALLENGE_ENABLED="true" IFS= read -r CHALLENGE_FORCED < "${TMPDIR:-/tmp}/dev-review-challenge-forced-${CSID}" 2>/dev/null || CHALLENGE_FORCED="false" # --challenge: no-op, challenger always runs # fail-safe impact default — codemap block overrides with review_impact_tier.py verdict; codemap off keeps FULL echo "FULL · impact unknown: codemap unavailable" > "${TMPDIR:-/tmp}/dev-review-impact-${CSID}" IFS= read -r CODEMAP_RAW < "${TMPDIR:-/tmp}/dev-review-codemap-${CSID}" 2>/dev/null || CODEMAP_RAW="auto" IFS= read -r FANOUT_FULL < "${TMPDIR:-/tmp}/dev-review-fanout-full-${CSID}" 2>/dev/null || FANOUT_FULL="false" FANOUT_CAP=3 # single numeric default for FANOUT_MAX [ "$FANOUT_FULL" = "true" ] && FANOUT_CAP=0 # 0 = no cap: all preselected dimensions echo "REVIEW_ARGS=$REVIEW_ARGS CHALLENGE_ENABLED=$CHALLENGE_ENABLED FANOUT_CAP=$FANOUT_CAP" # prose below branches on these — shell state dies with the call ``` PR#/filename disambiguation gate — reads the classified sentinel, never the raw arguments; branch on the printed values per `<inputs>`: ```bash # timeout: 5000 PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r PR_NUMBER < "${TMPDIR:-/tmp}/dev-review-pr-number-${CSID}" 2>/dev/null || PR_NUMBER="" if [ -n "$PR_NUMBER" ]; then echo "PR number detected — checking oss plugin availability" OSS_ROOT=$(python "$PLUGIN_ROOT/bin/get_plugin_install_path.py" borda-ai-rig oss 2>/dev/null) || OSS_ROOT="" # install record, never cache glob — orphaned version dir ≠ installed [ -n "$OSS_ROOT" ] && [ -f "$OSS_ROOT/skills/review/SKILL.md" ] && OSS_AVAILABLE=true || OSS_AVAILABLE=false else OSS_AVAILABLE=skip fi echo "OSS_AVAILABLE=$OSS_AVAILABLE PR_NUMBER=$PR_NUMBER" # <inputs> prose branches on these — shell state dies with the call ``` **Unsupported flag check** — after all supported flags extracted, scan `$ARGUMENTS` for remaining `--<token>` tokens not in the supported list below. Found → invoke `AskUserQuestion` with question text `` ! Unknown flag(s): `--<token>`. Supported: `--no-challenge`, `--challenge`, `--codemap`, `--no-codemap`, `--worktree`, `--full`, `--keep`. `` — (a) **Abort** (stop, re-invoke with correct flags) · (b) **Continue ignoring** (skip unknown flags, proceed). On Abort: stop. ## Worktree isolation > loads: worktree-isolation.md `--worktree` set → run review in an isolated git worktree so no dimension agent can accidentally mutate main sources — **before** Step 1. ```bash # timeout: 5000 PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r WORKTREE_ENABLED < "${TMPDIR:-/tmp}/dev-review-worktree-${CSID}" 2>/dev/null; [ "$WORKTREE_ENABLED" = "true" ] || WORKTREE_ENABLED=false printf '%s\n' review > "${TMPDIR:-/tmp}/dev-worktree-skill-${CSID}" IFS= read -r REVIEW_ARGS < "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" 2>/dev/null || REVIEW_ARGS="" if [ "$WORKTREE_ENABLED" = "true" ] && [ -z "$REVIEW_ARGS" ]; then WORKTREE_STATUS=$(git status --porcelain --untracked-files=normal) || exit 1 [ -z "$WORKTREE_STATUS" ] || { echo "! BLOCKED — --worktree without a path would omit uncommitted changes; rerun without --worktree to review them, or pass an explicit committed path."; exit 1; } fi if [ "$WORKTREE_ENABLED" = "true" ]; then python "$PLUGIN_ROOT/bin/dev_load_shared.py" worktree-isolation.md; fi ``` `WORKTREE_ENABLED=true` → follow §Enter (base off HEAD, `EnterWorktree(path=…)`). **Read-only skill** — obey §Deliverable: - `$RUN_DIR` handoffs stay under the active development run directory, or the worktree's `.developments/` for standalone reviews, but `$REPORT_DIR` (the review report) is written to the **main tree** (`$_ORIG_ROOT`, wired at Step 2) so its printed path + follow-up gate stay valid. - Reviews committed HEAD state — uncommitted working-tree changes aren't visible, so the default target (no path given) is the last commit (`HEAD~1..HEAD`), matching Agent 0's pre-change ref; pass a path to review other committed files. Else skip — run in main tree (doc not loaded). ```bash # CODEMAP_RAW → true/false; strict exits on unavailability # timeout: 5000 PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" CODEMAP_ENABLED=$(python "$PLUGIN_ROOT/bin/dev_codemap_gate.py" review) || exit 1 # codemap: integrated-via-shared python "$PLUGIN_ROOT/bin/dev_load_shared.py" codemap-gates.md ``` > loads: codemap-gates.md Follow Gate A and Gate B. Use `$REVIEW_ARGS` (not `$ARGUMENTS`) as path for rest of workflow. ## Step 1: Identify scope Capture the target repository's full Git HEAD once, before source inspection. A file target uses its containing directory; a directory target uses itself; diff mode uses the current directory. This identifies the working-tree base for path/diff reviews; it never claims dirty files equal a clean commit. Keep this frozen value through consolidation and compaction, even if HEAD later moves. Non-Git directories and unborn repositories retain an explicit unavailable reason. ```bash # timeout: 5000 export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r REVIEW_ARGS < "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" 2>/dev/null || REVIEW_ARGS="" REVIEW_SOURCE_DIR="." if [ -d "$REVIEW_ARGS" ]; then REVIEW_SOURCE_DIR="$REVIEW_ARGS"; elif [ -f "$REVIEW_ARGS" ]; then REVIEW_SOURCE_DIR=$(dirname -- "$REVIEW_ARGS"); fi REVIEWED_COMMIT_SHA=$(git -C "$REVIEW_SOURCE_DIR" rev-parse --verify HEAD 2>/dev/null) || REVIEWED_COMMIT_SHA="unavailable (non-Git directory or unborn HEAD)" REVIEWED_COMMIT_KIND="working-tree base; reviewed files may include uncommitted changes" IFS= read -r WORKTREE_ENABLED < "${TMPDIR:-/tmp}/dev-review-worktree-${CSID}" 2>/dev/null || WORKTREE_ENABLED=false if [ "$WORKTREE_ENABLED" = "true" ] && [ -z "$REVIEW_ARGS" ]; then REVIEWED_COMMIT_KIND="committed worktree source; reviewed range HEAD~1..HEAD"; fi printf '%s\n' "$REVIEWED_COMMIT_SHA" > "${TMPDIR:-/tmp}/dev-review-commit-sha-${CSID}" printf '%s\n' "$REVIEWED_COMMIT_KIND" > "${TMPDIR:-/tmp}/dev-review-commit-kind-${CSID}" printf 'Commit SHA: %s (%s)\n' "$REVIEWED_COMMIT_SHA" "$REVIEWED_COMMIT_KIND" ``` Scope + non-Python impact check + Python filter in ONE pass — a single `git diff` capture feeds TARGET, the report-header warnings, and the early exit (previously eight diff invocations across three blocks): ```bash # timeout: 5000 PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r REVIEW_ARGS < "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" 2>/dev/null || REVIEW_ARGS="" # re-derive — bash resets between calls IFS= read -r WORKTREE_ENABLED < "${TMPDIR:-/tmp}/dev-review-worktree-${CSID}" 2>/dev/null || WORKTREE_ENABLED=false COMMITTED=""; [ "$WORKTREE_ENABLED" = "true" ] && COMMITTED="--committed" # fresh worktree: working-tree diff is empty, the change is the last commit python "$PLUGIN_ROOT/bin/resolve_review_target.py" $COMMITTED -- "$REVIEW_ARGS" || exit 1 ``` Any `⚠` line printed above: include in report header regardless of whether Python files exist. No Python files → `resolve_review_target.py` prints `! Diff contains non-Python files only.`; a nonexistent path prints `! Review target not found: <path>`; either exits 1 and the `|| exit 1` stops Step 1 there — do not continue. ### Scope pre-check Before spawning agents, classify diff: - Count files changed, lines added/removed, new classes/modules introduced - Classify: **FIX** (corrects wrong behavior), **REFACTOR** (same behavior restructured), **FEATURE** (new public API or capability), **CHORE** (config/deps, no logic), **MIXED** — classify by intent, not file count - **Complexity smell**: 8+ files changed → note in report header Persist the classification decision for compaction-safe reuse in later steps and the boundary-1 contract. Closed set, no shell variable — run the ONE block below matching the classification just made: ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" echo "FIX" > "${TMPDIR:-/tmp}/dev-review-classification-${CSID}" ``` ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" echo "REFACTOR" > "${TMPDIR:-/tmp}/dev-review-classification-${CSID}" ``` ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" echo "FEATURE" > "${TMPDIR:-/tmp}/dev-review-classification-${CSID}" ``` ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" echo "CHORE" > "${TMPDIR:-/tmp}/dev-review-classification-${CSID}" ``` ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" echo "MIXED" > "${TMPDIR:-/tmp}/dev-review-classification-${CSID}" ``` Skip optional agents by classification: - FIX → **only when `IMPACT_TIER=LIGHT`** (see Impact tier below; `FULL` keeps both): skip Agent 3 (perf-optimizer) and Agent 6 (solution-architect), unless diff changes an already-exported public function's signature (added/removed/renamed params, new flags) — then Agent 6 still runs per its own trigger (Agent 1's "API-consistency audit" subsection already checks the surface; Agent 6 adds design-quality/backward-compat judgment) - REFACTOR → skip Agent 6 (solution-architect), same exception — an already-exported public function's signature change still fires Agent 6 - CHORE (config/deps, no logic) → skip Agent 2 (qa-specialist), Agent 3 (perf-optimizer), Agent 6 (solution-architect); keep Agent 1 (sw-engineer), Agent 4 (doc-scribe), Agent 5 (linting-expert). No logic = no test-gap, perf, or architecture surface — same saving pattern as `oss:review`'s DOCS_TYPING/TESTS_CI pre-classification (requires oss plugin). - FEATURE/MIXED → spawn all agents, plus Agent 0 (blind-solve) when a matching `.plans/active/*.md` exists — see §Agent 0 below - **Challenger at any diff size** — Agent 7 runs on every classification and every diff size; only `--no-challenge` (`CHALLENGE_ENABLED=false`) disables it. Small diff ≠ low risk: few lines in a private helper on the main path can break the main user story. **Impact tier** — review depth follows the code path a change sits on, never line or file count. `review_impact_tier.py` (codemap `diff-impact` + `fn-blast`, run in the codemap block below) prints `FULL` or `LIGHT` plus reason: - `FULL` — any changed symbol, public or private, reaches a public function outside tests/leaf modules (main path), or a changed main-path module has ≥5 importers, or a module-level main-path change. **Unknown impact (codemap off, query failed, unmapped file) = `FULL`.** - `LIGHT` — every change and every transitive caller stays in tests, leaf modules (`viz`, `plot`, `examples`, `docs`, `notebooks`), or uncalled private code. `conftest.py`, `docs/conf.py`, setup/release/build entrypoints and `scripts/` are always `FULL`. The Step 2 codemap-copy block prints `IMPACT_TIER=` and `IMPACT=` — apply the FIX skip above from that value (codemap runs after classification). Report the `IMPACT=` line in the review header as `Impact:`. Create the review run directory before pre-flight, including when Codemap is disabled. Reuse an active feature/fix/refactor run root when present; standalone reviews use `.developments/`, matching the run-artifact fence. ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M-%SZ) RUN_BASE="" for _RUN_SKILL in feature fix refactor; do IFS= read -r RUN_BASE 2>/dev/null < "${TMPDIR:-/tmp}/dev-${_RUN_SKILL}-dev-dir-${CSID}" || : [ -z "$RUN_BASE" ] || break done RUN_DIR="${RUN_BASE:-.developments}/review/$TIMESTAMP" mkdir -p "$RUN_DIR" || exit 1 # timeout: 5000 # persisted for agents — hand-retyping drops leading dot (stray developments/review/ dirs) echo "$RUN_DIR" > "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" ``` ### Structural context + review pre-flight (codemap-py — only if `CODEMAP_ENABLED=true`) **Skip entire section if `CODEMAP_ENABLED=false`** — sets `codemap_available=false` for downstream agent prompts; agents fall back to file reads. Extended scan for changed modules — runs v5 pre-flight queries per module, persists structured output to `$RUN_DIR/codemap-context.md`, and sets `codemap_available` flag for Step 3 agent spawns: Before this block: 1. Enumerate the review target's Python files (the explicit file/directory contents, or the Step 1 diff's files). 2. Convert only those paths to dotted modules relative to the target project root: strip leading `./`, `src/` and `.py`, replace `/` with `.`, and map `.__init__` to its package. 3. Use the Write tool to save the space-separated module names to `${TMPDIR:-/tmp}/dev-review-target-modules-${CSID}` with resolved sentinel path, replacing any prior run's list. Unmappable targets get an empty list and file-read fallback. Path/directory and committed worktree reviews keep `FULL`: working-tree `diff-impact` does not measure those targets. ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r CODEMAP_CURRENCY 2>/dev/null < "${TMPDIR:-/tmp}/dev-codemap-currency-${CSID}" || CODEMAP_CURRENCY="no_index" if [ "$CODEMAP_CURRENCY" = "stale" ]; then export SCAN_NO_AUTOBUILD=1; fi codemap_available=false IFS= read -r CODEMAP_ENABLED 2>/dev/null < "${TMPDIR:-/tmp}/dev-review-codemap-enabled-${CSID}" || CODEMAP_ENABLED="false" IFS= read -r REVIEW_ARGS < "${TMPDIR:-/tmp}/dev-review-clean-args-${CSID}" 2>/dev/null || REVIEW_ARGS="" IFS= read -r WORKTREE_ENABLED < "${TMPDIR:-/tmp}/dev-review-worktree-${CSID}" 2>/dev/null || WORKTREE_ENABLED=false TARGET_MODULES="" IFS= read -r TARGET_MODULES < "${TMPDIR:-/tmp}/dev-review-target-modules-${CSID}" 2>/dev/null || : if [ -n "$REVIEW_ARGS" ] || [ "$WORKTREE_ENABLED" = "true" ]; then echo "FULL · impact unknown: review target is not the working-tree diff" > "${TMPDIR:-/tmp}/dev-review-impact-${CSID}" fi if [ -z "$TARGET_MODULES" ]; then CODEMAP_ENABLED=false; echo "⚠ target modules unavailable — use file reads and FULL impact"; fi if [ "$CODEMAP_ENABLED" = "true" ]; then codemap_available=true # RUN_DIR made before pre-flight — stage here, copy in Step 2. codemap-py on PATH guaranteed (codemap_resolve.py confirmed) CODEMAP_CONTEXT_STAGE="${TMPDIR:-/tmp}/dev-review-codemap-context.md-${CSID}" IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR="" [ -n "$RUN_DIR" ] || { echo "! BLOCKED — review run directory missing; re-run run-directory setup"; exit 1; } BATCH_REQ="$RUN_DIR/dev-review-codemap-batch.json-${CSID}" # explicit target modules prevent unrelated dirty files from selecting structural context python "$PLUGIN_ROOT/bin/build_codemap_batch.py" "$BATCH_REQ" --modules "$TARGET_MODULES" || exit 1 # timeout: 5000 { echo "## Structural Context (codemap-py)" echo echo "### Batched query results (one shared coverage block)" codemap-py query --timeout 20 batch "$BATCH_REQ" 2>/dev/null if [ -z "$REVIEW_ARGS" ] && [ "$WORKTREE_ENABLED" != "true" ]; then echo echo "### Change-set blast radius (diff-impact)" # fn-level context batch can't give: fn-rdeps per symbol (line-range, methods), unioned test-impact, risk tiers _DIFF_IMPACT_JSON=$(codemap-py query --timeout 15 diff-impact 2>/dev/null) printf '%s\n' "$_DIFF_IMPACT_JSON" # review depth from code path, not diff size — overrides Step 0's fail-safe FULL default; stdout to sentinel, not stage printf '%s\n' "$_DIFF_IMPACT_JSON" | python "$PLUGIN_ROOT/bin/review_impact_tier.py" > "${TMPDIR:-/tmp}/dev-review-impact-${CSID}" 2>/dev/null # timeout: 300000 — batch + diff-impact + ≤12 tier fn-blast queries fi } > "$CODEMAP_CONTEXT_STAGE" fi echo "$codemap_available" > "${TMPDIR:-/tmp}/dev-review-codemap-available-${CSID}" ``` Codemap context propagation in Step 3: - `codemap_available=true` → copy `$CODEMAP_CONTEXT_STAGE` to `$RUN_DIR/codemap-context.md` once in Step 2, reusing the directory created before pre-flight. Each dimension spawn prompt gets a literal block holding only ITS slice of the batch results (the whole block in every prompt re-bills every query result to consumers that never read it; results for skipped agents injected nowhere): - qa unit → `uncovered` + `mock-rdeps` entries - doc unit → `undocumented` + `xrefs --broken` entries - sw-engineer → `rdeps` + `central` + `diff-impact` Entries whose only consumer was skipped by classification aren't injected anywhere: ```text ## Structural Context (codemap-py, codemap_available=true) <this agent's slice of $RUN_DIR/codemap-context.md> Read this section first. The payload contains a `batch` array: each entry has `cmd`, `ok`, an ordinal `index`, and `result`. Each child's `result.index` describes its own scope and completeness; the outer `index` is only a conservative summary. Retain child metadata when slicing results for agents. For successful entries passing the reuse gate, skip only equivalent structural retrieval. A valid empty list is not a failed query; failed or unjoinable children remain explicit gaps. Source and test reads for specific findings remain required. > Reuse gate: reuse a supplied answer only for the same project, current index, target, query and flags; skip its duplicate pre-flight call. Require success and direction-complete metadata. For batch children require `ok: true` and inspect `result.index`; `ok: false` is a failure, never an empty answer. Missing metadata, `stale`, root mismatch, degraded or incomplete results need targeted fallback. Use legacy `exhaustive: true` only when `query_complete` is absent. A valid empty list settles that scoped query; truncation does not enumerate all matches. Necessary source-body reads, test-quality checks, dynamic behavior and required independent verification remain allowed. **Query choice inheritance**: the orchestrator supplies the invocation’s exact enabled/currency sentinel paths in this prompt. Before every fresh shell that queries Codemap or runs a querying helper, reload those files; disabled means no queries, stale means `export SCAN_NO_AUTOBUILD=1` before the command. Retain an inherited freeze. This also applies to fallback and impact/test-selection helpers. **Bounded call budget**: symbol not covered by the batch above → up to 3 additional `codemap-py query` calls this review pass. **Hard stop on `query_complete: true`** (legacy `exhaustive: true` only when `query_complete` is absent): a result passing the reuse gate is final for its direction — no follow-up Grep/Read/query to re-confirm it. Per-agent priority (skip redundant reads for symbols the listed query already covers): - qa-specialist (Agent 2): `uncovered` + `mock-rdeps` first - doc-scribe (Agent 4): `undocumented` + `xrefs --broken` first - sw-engineer (Agent 1): `rdeps` first (importers per changed module) - challenger (Agent 7): unchanged — always reads source directly ``` - `codemap_available=false` → omit block; agents proceed with current file-read behaviour. > Per-agent consumption guidance kept in sync with `$_DEV_SHARED/codemap-context.md` §Review-pipeline injection — update both on change. Tier annotation for Agent 1 (sw-engineer) only: label each module's `imported_by` count — **high risk** (>20), **moderate** (5–20), **low** (\<5). Agent 1 uses this to prioritize: high `imported_by` modules warrant deeper scrutiny on API compatibility, error handling, behavioural correctness — downstream callers outside diff otherwise invisible. ## Step 2: Codex co-review Reload the run directory, check Codex availability, and materialize codemap context into the run directory: ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR="" [ -n "$RUN_DIR" ] || { echo "! BLOCKED — review run directory missing; re-run run-directory setup"; exit 1; } TIMESTAMP=$(basename -- "$RUN_DIR") # REPORT_DIR: orig-root sentinel (worktree §Enter) or pwd — stays reachable outside worktree. RUN_DIR stays under its run root. IFS= read -r _REPORT_BASE < "${TMPDIR:-/tmp}/dev-review-orig-root-${CSID}" 2>/dev/null || _REPORT_BASE="$(pwd)" [ -n "$_REPORT_BASE" ] || _REPORT_BASE="$(pwd)" REPORT_DIR="$_REPORT_BASE/.reports/develop-review/$TIMESTAMP" if command -v cygpath >/dev/null 2>&1; then REPORT_DIR=$(cygpath -m -- "$REPORT_DIR") || exit $?; fi mkdir -p "$REPORT_DIR" # timeout: 5000 echo "$REPORT_DIR" > "${TMPDIR:-/tmp}/dev-review-report-dir-${CSID}" # persist for contract-write REPORT_DIR_LITERAL="$REPORT_DIR" CODEX_STATUS=$(python "$PLUGIN_ROOT/bin/check_bridge.py" --status 2>/dev/null || echo "absent") # timeout: 5000 [ "$CODEX_STATUS" = "available" ] && echo "bridge@borda-ai-rig available" || echo "⚠ bridge@borda-ai-rig is ${CODEX_STATUS} — skipping co-review" IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR="" # round-trip the sentinel agents self-resolve from [ -n "$RUN_DIR" ] || { echo "! BLOCKED — run-dir sentinel empty; refusing to copy codemap context to a root-relative path"; exit 1; } IFS= read -r codemap_available < "${TMPDIR:-/tmp}/dev-review-codemap-available-${CSID}" 2>/dev/null || codemap_available="false" if [ "$codemap_available" = "true" ] && [ -f "${TMPDIR:-/tmp}/dev-review-codemap-context.md-${CSID}" ]; then cp "${TMPDIR:-/tmp}/dev-review-codemap-context.md-${CSID}" "$RUN_DIR/codemap-context.md" fi # review depth by code path — gates FIX perf+arch skip; missing sentinel = FULL IFS= read -r IMPACT_LINE < "${TMPDIR:-/tmp}/dev-review-impact-${CSID}" 2>/dev/null || IMPACT_LINE="FULL · impact unknown" echo "IMPACT_TIER=${IMPACT_LINE%% *}" echo "IMPACT=$IMPACT_LINE" ``` If Codex available: ```bash export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR="" # re-derive — bash resets between calls [ -n "$RUN_DIR" ] || { echo "! BLOCKED — run-dir sentinel empty; refusing to write a root-relative codex-out path"; exit 1; } CODEX_OUT="$RUN_DIR/codex.md" echo "$CODEX_OUT" > "${TMPDIR:-/tmp}/dev-review-codex-out-${CSID}" # Step 6 re-reads — bash state lost ``` ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" python "$PLUGIN_ROOT/bin/dev_load_shared.py" codex-prepass.md # timeout: 5000 ``` Use the loaded `codex-prepass.md` for the **skip/run criteria only** (formatting-only skip, availability check) — do NOT use its dispatch line as the call: its args name no output path, so `$RUN_DIR/codex.md` would never be written and Step 6 would silently skip. Dispatch — substitute `<TARGET>` with its resolved literal value before the call: `Skill(skill="bridge:review", args="--timeout-seconds 230 Read-only adversarial review of <TARGET>. Look for bugs, missed edge cases, incorrect logic, and inconsistencies with existing code patterns. Report findings with file:line locations; do not apply fixes.")` (requires `bridge@borda-ai-rig`). Note: with `--timeout-seconds 230`, `bridge:review` uses its synchronous foreground route and blocks until it returns. Its Write tool is limited to its own scratch task file; it returns findings inline in its response envelope and does not write `$RUN_DIR/codex.md`. No background health-monitoring/liveness-probe protocol applies. After `Skill(skill="bridge:review", ...)` returns, the orchestrator itself writes `$RUN_DIR/codex.md` from the returned envelope's `.findings`/`.verdict`/`.transcript_path` fields. Quota-blocked co-review (a `blocked` or `timeout` result): - First Read the incident file its `incident` field names. - Its `fault` is `quota-exhausted` (peer out of credits, never retried by the bridge) → write `codex-blocked:quota` as the first line of `codex.md`. - A null `incident`, an unreadable file or any other `fault` (`rate-limited`, `capacity`, …) keeps today's record. - Never decide from verdict or blockers text, which a model-authored `blocked` result can copy. After `$RUN_DIR/codex.md` is written (or skipped/blocked), extract compact seed list (≤10 items, `[{"loc":"file:line","note":"..."}]`) to inject into agent prompts in Step 3 as pre-flagged issues to verify or dismiss. Codex skipped, timed out, or found nothing → proceed with empty seed. **Cap-disclosure**: count total Codex findings before truncating. If ≥10, surface in consolidated report header: ```text Codex: first 10 items seeded to review agents; full list in $RUN_DIR/codex.md (N total) — review codex.md directly for complete coverage. ``` Pass notice through to consolidator (Step 5) so it appears in final report header, not just terminal scratch. ### Matched plan claim and Agent 0 — blind-solve (FEATURE/MIXED diff with a matching plan only, general-purpose) Anti-anchoring pre-step: before any agent reads the diff, spawn a standalone agent that derives its own **blueprint-level** solution to the problem the change solves — approach + key data structures + edge cases, not full implementation. Bounded: ~10 tool calls, output ≤1 page. Isolation-motivated spawn, not work displacement — the blind agent must not share the orchestrator's context, so the "under ~73 calls → inline" rule does not apply; it still pays the fixed per-spawn overhead, hence the double gate below. For every classification, inspect `.plans/active/*.md` with the Read tool. - Match only exact repository-relative paths listed in the plan's **Affected files** section against the review target's files; normalize `./` and path separators, never match stems or free-text mentions. A path/directory review uses its own files, not unrelated dirty files. - Exactly one matching plan → use the Write tool to persist its resolved path to `${TMPDIR:-/tmp}/dev-review-plan-${CSID}`. - None or multiple matches → overwrite that sentinel with an empty line and record the missing/ambiguous claim. - Agent 1 receives `PLAN_CLAIM=<resolved matched-plan path>` when present, for every classification; omit the binding otherwise. - A matched plan remains an author's claim, never contract evidence. Problem statement for Agent 0 = that matching plan file, nothing else. A local diff has no PR body; the last commit message describes the *previous* change when the target is the working tree, so it is never used. Only FEATURE/MIXED diff reviews run the block below — path/directory targets have no change baseline and skip blind-solve. No diff content is read: ```bash # timeout: 10000 export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR="" [ -n "$RUN_DIR" ] || { echo "! BLOCKED — run-dir sentinel empty; refusing to write blind-solve input to a root-relative path"; exit 1; } IFS= read -r WORKTREE_ENABLED < "${TMPDIR:-/tmp}/dev-review-worktree-${CSID}" 2>/dev/null || WORKTREE_ENABLED=false # pre-change ref: working-tree diff → HEAD is untouched; --worktree reviews committed HEAD → parent is the pre-change state if [ "$WORKTREE_ENABLED" = "true" ]; then PRE_REF=HEAD~1; CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null); else PRE_REF=HEAD; CHANGED=$(git diff --name-only HEAD 2>/dev/null); fi PLAN="" IFS= read -r PLAN < "${TMPDIR:-/tmp}/dev-review-plan-${CSID}" 2>/dev/null || : if [ -n "$PLAN" ]; then { echo "## Plan: $PLAN"; sed -n '1,120p' "$PLAN"; echo; echo "## Changed files (names only)"; printf '%s\n' $CHANGED; echo; echo "PRE_REF=$PRE_REF"; } > "$RUN_DIR/blind-solve-input.md" echo "blind-solve input: $RUN_DIR/blind-solve-input.md plan=$PLAN pre-ref=$PRE_REF" else echo "blind-solve: skipped — no unambiguous .plans/active/*.md Affected files match" fi ``` `blind-solve: skipped` → no spawn; note the skip in the report header. Otherwise spawn with the contents of `$RUN_DIR/blind-solve-input.md` verbatim, then: - "Your only source for pre-change code is `git show <PRE_REF>:<path>` for files listed above. Never use Read, `cat`, `git diff`, or any working-tree path — the working tree contains the change under review. Sketch your own solution to the stated problem — approach, key data structures/functions, edge cases — in ≤1 page. Do not write full code." - Write to `$RUN_DIR/blind-solve.md`, return `{"status":"done","file":"$RUN_DIR/blind-solve.md","confidence":0.N}`. Skip Agent 0 when classification is FIX/REFACTOR/CHORE (no fresh problem to solve blind) or target is a path/directory — checked before the block above runs; plan matching and the Agent 1 claim binding still apply. Launch in the same batch as the Step 3 spawn units — it needs no diff, nothing blocks it. Not a `FANOUT_MAX` unit — never counted against the cap, never ranked out, not part of any merged spawn unit. ## Step 3: Spawn sub-agents in parallel **Spawn-count gate — apply before spawning anything.** Each agent costs ~120,851 tok fixed overhead regardless of how little work it does (~73 tool-calls' worth), plus ~12.0 s/call. Rules, all mandatory: Three stages, in order — never collapse them: 1. **Classification preselection** (always): the FIX (at `IMPACT_TIER=LIGHT`) / CHORE skips above decide which dimensions are *relevant at all*. Agent 1 always survives because intended behavior applies to every review target. Any other dimension with no target file in its territory is out here and never comes back, at any flag. 2. **Unit grouping** (always): fold the survivors into spawn units per §Merged spawn units below — Agents 3+6 share one spawn, Agents 4+5 share one spawn, Agents 1 and 2 stay standalone. A unit exists when at least one of its dimensions survived stage 1; its prompt lists only the surviving dimensions' brief files. 3. **Relevance ranking** (default only): Agent 1 is never ranked out; reserve its unit within the cap, then rank the other units by evidence — target files and lines in their dimensions' territory, what the classification implies, what the structural context flagged (a merged unit ranks by its strongest surviving dimension) — and fill the remaining `FANOUT_MAX - 1` slots. With `--full` (`FANOUT_CAP=0`) skip this stage and spawn every unit of stage 2. - More work → give each agent more, never add agents. - **Spawn the fewest that keep each near `AGENT_CALL_BUDGET`** — not the most the cap allows. Small diff → merge surviving units into fewer spawns, **never zero**. - **Diff size never licenses inline review.** ~73-call inline rule covers work-displacement spawns only; review specialists are role-isolated (own system prompt, independent eyes), so it does not apply here. Small diff ≠ low risk: few-line change on hot path often riskiest. Orchestrator never substitutes itself for a unit that survived stages 1–3. - **Merge before you split**: two dimensions whose files overlap go to one agent, not two — the fixed pairs below are the floor, not the ceiling. - Every spawn prompt states the budget, requires an envelope even on exhaustion — `partial: true` plus what was finished. - Dimensions dropped by the cap are listed in the report; never silently skipped. ### Merged spawn units (shared pattern with oss:review — each spawn costs ~120,851 tok fixed overhead, so paired dimensions share one spawn) - **Agents 3+6 = ONE `foundry:perf-optimizer` spawn** covering Performance + Architecture/API design — spawn when either dimension survives classification preselection; prompt lists only the surviving dimensions' brief files (e.g. FIX with a public-signature change spawns this unit with only the Agent-6 dimension active). (this merged spawn is explicitly authorized to also cover architecture/SOLID review; its own NOT-for line does not apply to this dispatch) - **Agents 4+5 = ONE `foundry:doc-scribe` spawn** covering Documentation + Linting — same rule. (this merged spawn is explicitly authorized to also cover linting; its own NOT-for line does not apply to this dispatch) - Agents 1 (sw-engineer, incl. security augmentation), 2 (qa-specialist), 7 (challenger) stay standalone spawns. - A merged spawn writes **one file per covered dimension**, each with its OWN full sections + Confidence block — never blended: `perf-optimizer.md` + `solution-architect.md`, or `doc-scribe.md` + `linting-expert.md`. Downstream contracts (consolidator filename list, Step-4 cross-validation "same type as origin", report sections) key on those files, stay unchanged. - Merged-spawn envelope = JSON array, one element per dimension file, same per-element schema as the standard envelope. Element absent from the array ⇒ that dimension gets the ⏱ marker — never silently omitted. **File-based handoff** — load the protocol, then resolve the develop:review checklist path (version-agnostic) and the dimension-briefs directory (`$REVIEW_CHECKLIST` rules follow the preamble and pre-expansion rule below): ```bash PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" python "$PLUGIN_ROOT/bin/dev_load_shared.py" file-handoff-protocol.md # timeout: 5000 # loads: the brief-*.md files in the loop — each child cats only its own; parent passes the directory path only _DIMENSION_BRIEFS="$PLUGIN_ROOT/skills/review/templates" for _B in brief-sw-engineer.md brief-qa-specialist.md brief-perf-optimizer.md brief-doc-scribe.md brief-linting-expert.md brief-security-augmentation.md brief-solution-architect.md brief-challenger.md; do [ -f "$_DIMENSION_BRIEFS/$_B" ] || { echo "! BLOCKED — dimension brief $_B missing; restore/reinstall this develop version before spawning review agents"; exit 1; } done echo "Dimension briefs: $_DIMENSION_BRIEFS" REVIEW_CHECKLIST="$_DIMENSION_BRIEFS/review-checklist.md" # develop's own copy — never read from the oss plugin if [ -f "$REVIEW_CHECKLIST" ]; then echo "Checklist: $REVIEW_CHECKLIST" else echo "⚠ review checklist unavailable — review will proceed without severity anchors; restore/reinstall this develop version for full coverage" REVIEW_CHECKLIST="" fi ``` Run directory created before pre-flight and reloaded in Step 2 (`$RUN_DIR`). <!-- $REPORT_DIR pre-expanded into $REPORT_DIR_LITERAL — substitute literal vars in Agent spawn prompt strings. Run-dir is the exception: agents self-resolve it (see run-dir preamble below), never hand-substituted. --> ### Run-dir preamble (canonical) Place this in every agent spawn prompt (Agents 0–7, Step 4 verifiers and the Step 5 consolidator) as the paragraph **after** prompt line 1 — line 1 is the delta task line (dimension + target, ≤12 words, delta first; `agent-spawn.md`), never this shared boilerplate: > "First run Bash `CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"; IFS= read -r RUN_DIR < "${TMPDIR:-/tmp}/dev-review-run-dir-${CSID}" 2>/dev/null || RUN_DIR=""` to obtain the exact run-dir path. Use `$RUN_DIR` verbatim for every handoff file you read or write — never retype the path literally (the leading `.` in `.developments` is easy to drop, scattering output into a stray `developments/` dir)." > > "Read-only review: no source edits, no fixers, no dependency installation, no writes outside `$RUN_DIR`; direct all tool caches and temporary output there. Only the consolidator may additionally write the prescribed report and sidecars under `REPORT_DIR_LITERAL`. Do not execute reviewed code, examples or tests. Existing static analyzers and dependency audits may run without fixes, with caches under `$RUN_DIR`, within existing authorization; unavailable or incompatible checks remain explicit coverage gaps. Task tracking: do NOT call TaskCreate or TaskUpdate." Inside agent prompt strings, leave `$RUN_DIR` literal — agent resolves it via preamble. Orchestrator must NOT hand-substitute run-dir path. ### $VAR_LITERAL pre-expansion rule (canonical) Any OTHER shell variable inserted into an Agent spawn prompt string — `$REPORT_DIR_LITERAL`, `$REVIEW_CHECKLIST`, `$DATE`, `$_REVIEW_TEMPLATE` — must be substituted with its literal resolved value **before** building the Agent call. Bare variable name inside a quoted Agent prompt will NOT expand — spawned agent receives literal dollar-sign text, causing path mismatches. Resolve each to its value first; never pass a bare `$VAR` name. (`$RUN_DIR` is the deliberate exception above — agents self-resolve it.) Pass the resolved `$REVIEW_CHECKLIST` path (printed by the File-based handoff block above) as a `REVIEW_CHECKLIST=<resolved path>` binding line in Agent 1's spawn prompt and in the consolidator's. **Empty → omit that binding line from Agent 1's prompt entirely** — don't pass empty path. For Agent 1, also read the Step 2 matched-plan sentinel and pass its nonempty resolved path as `PLAN_CLAIM=<resolved matched-plan path>` alongside `REVIEW_CHECKLIST`; omit that binding if no unambiguous match exists. Agent 1 loads the claim itself. **Visible-degradation rule** — `$REVIEW_CHECKLIST` empty → print `⚠ REVIEW_CHECKLIST is empty — review scope undefined` at TOP of review output (before Findings), and consolidator prompt (Step 5) **must** insert into report header (YAML `---` block or first line before Findings): "Review checklist not applied (review-checklist.md missing from this develop install) — severity anchors may be inconsistent." Silent degradation hides the gap from reviewers, makes severity drift invisible. **Finding evidence standard — applies to every agent, every finding** (tiers, source independence and citation tracing per `quality-gates.md` §Evidence Grounding): - Every finding must cite specific `file:line` from the target source (changed lines in diff mode) as primary evidence — "I know this typically causes issues" without a target citation isn't a valid finding - Claims referencing external standards (OWASP, PEP, language spec, CVE) must cite the specific authoritative document — official spec, CVE entry, PEP text; a blog post or Stack Overflow answer referencing the standard is Tier 2 only - Only Tier 2 available, distinct-origin count < 3, no experiment run → downgrade finding to LOW or drop it; never raise MEDIUM/HIGH/CRITICAL on Tier 2 alone Launch spawn units simultaneously with Agent tool (security augmentation folded into Agent 1 — not separate spawn; Agent 6 optional; Agents 3+6 and 4+5 launch as merged units per §Merged spawn units; Agent 0 blind-solve joins this batch on FEATURE/MIXED, outside the cap). Every agent prompt opens with its delta task line, carries the [run-dir preamble (canonical)](#run-dir-preamble-canonical) next, and ends with: > "Write your FULL findings (all sections, Confidence block) to `$RUN_DIR/<agent-name>.md` using the Write tool — where `<agent-name>` is e.g. `sw-engineer`, `qa-specialist`, `perf-optimizer`, `doc-scribe`, `linting-expert`, `solution-architect`. Include your scoped source_outcome, source_rating (source-5-v2 integer 1–5 or null when undecidable), rationale, readiness (complete/blocked/incomplete), readiness_reason and inspected coverage (paths and checks, including unavailable checks). Then return to the caller ONLY a compact JSON envelope on your final line — nothing else after it (a merged unit returns the JSON array of §Merged spawn units instead, one such object per dimension file): `{\"status\":\"done\",\"findings\":N,\"severity\":{\"critical\":0,\"high\":1,\"medium\":2,\"low\":0},\"file\":\"$RUN_DIR/<agent-name>.md\",\"confidence\":0.88,\"source_outcome\":\"MINOR_EDITS\",\"source_rating\":2,\"rationale\":\"<scoped judgment basis>\",\"readiness\":\"complete\",\"readiness_reason\":\"<completed checks or verification limits>\",\"coverage\":[\"<inspected path/check>\"]}`. Replace example judgments with your actual scoped assessment." **Codemap-py context preamble (substituted by orchestrator)**: rehydrate `IFS= read -r codemap_available < "${TMPDIR:-/tmp}/dev-review-codemap-available-${CSID}" 2>/dev/null || codemap_available=false`. - When `codemap_available=true`, each dimension spawn prompt is prefixed with its `## Structural Context (codemap-py, codemap_available=true)` slice from `$RUN_DIR/codemap-context.md` per the per-agent slicing rules in Step 1. - Agents must read that block first and skip redundant Grep/Read on symbols already covered by codemap output. - Block absent → fall back to current file-read behaviour. - Challenger (Agent 7) unchanged. **Dimension briefs** — each dimension's full instructions live in its own file under `templates/` (directory printed above as `Dimension briefs: …`): - Agent 1 → `brief-sw-engineer.md` (with its API-consistency audit and error-path table) - Agent 2 → `brief-qa-specialist.md` - Agent 3 → `brief-perf-optimizer.md` - Agent 4 → `brief-doc-scribe.md` - Agent 5 → `brief-linting-expert.md` - Security augmentation → `brief-security-augmentation.md` - Agent 6 → `brief-solution-architect.md` - Agent 7 → `brief-challenger.md` Do NOT cat, Read or inline them into orchestrator context or the Agent prom
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.