Skip to content
Development
Skill

/code-reviewer

Multi-agent code review system. Spawns 3 parallel reviewers (security, logic, performance) with inline self-critique. Use when saying 'review code', 'code review', 'audit code', 'review PR', 'review changes', 'check code quality'.

From plugin
specweave
15651 skills20 agents73 commands
Install
$ npx -y skills add anton-abyzov/specweave --skill code-reviewer --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/code-reviewer

Context preview

The summary Claude sees to decide when to auto-load this skill.

Multi-agent code review system. Spawns 3 parallel reviewers (security, logic, performance) with inline self-critique. Use when saying 'review code', 'code review', 'audit code', 'review PR', 'review changes', 'check code quality'.

SKILL.md

code-reviewer.SKILL.md
description: "Multi-agent code review system. Spawns 3 parallel reviewers (security, logic, performance) with inline self-critique. Use when saying 'review code', 'code review', 'audit code', 'review PR', 'review changes', 'check code quality'."
version: 1.0.0
argument-hint: "[--pr N] [--changes] [--increment NNNN] [--cross-repo] [--full-fanout] [path]"
context: fork
model: opus

Code Reviewer

**Parallel multi-agent code review with 3 core reviewers (security, logic, performance) and inline self-critique.**

Default path spawns **3 reviewer agents** (security, logic, performance) that analyze code simultaneously. Each reviewer re-reads its own findings before emitting, validates evidence claims, and rates confidence 1–5. The 3-reviewer default balances coverage with token cost for typical reviews.

**`--full-fanout`** restores the 8-reviewer + 10-validator path for maximum coverage at higher token cost. Reach for it on pre-release audits, large refactors, or security-sensitive PRs where thoroughness beats cost.

Tool-Use Rationale

  • **Read**: Load spec.md, rubric.md, CLAUDE.md, and the files under review so reviewers share identical context.
  • **Grep**: Locate call sites, try/catch patterns, and AC markers across the touched files.
  • **Bash**: Run `gh pr diff`, `git diff`, and `find` to build the file list and extract PR metadata.

Model Configuration

**Default effort**: `xhigh` — recommended for all code-review tasks per Opus 4.7 conventions. **Opt-in max**: `--effort max` enables maximum effort with a warning: "max effort risks overthinking on straightforward problems." **Legacy mode**: Set `quality.thinkingBudget: "legacy"` in config to pass a fixed `thinking` parameter (for pre-4.7 models only).

Prompt Caching

`sw:code-reviewer` uses Anthropic's ephemeral prompt caching so the shared context (project rules, active spec, rubric) is reused across the parallel reviewer fan-out and between fix-loop iterations. This is especially impactful during `sw:done`, where the fix loop can invoke code-reviewer up to 5 times per closure.

**Files cached by default** (via `static-context-loader`):

  • `CLAUDE.md` (project root)
  • `.specweave/config.json`
  • The active increment's `spec.md`
  • The active increment's `rubric.md` (if present)

**Cache window**: 5-minute TTL (Anthropic's `cache_control: { type: "ephemeral" }` breakpoint). Successive reviewer spawns that share this prefix read from cache.

**Extending the list**: Add paths to `cache.staticContextFiles` in `.specweave/config.json`:

{
  "cache": {
    "staticContextFiles": [
      "CLAUDE.md",
      ".specweave/config.json",
      ".specweave/docs/internal/architecture/adr/ADR-001-something.md"
    ]
  }
}

**Disable caching**: Set `cache.staticContextFiles: []` in `.specweave/config.json`. Reviewer agents will still run, but without the shared prefix cache.

See `.specweave/docs/internal/specs/config-reference.md` and `opus-47-migration.md` for the full caching setup.

MANDATORY: Orchestrator Identity

**You are an ORCHESTRATOR. You do NOT review code yourself.**

  • ALWAYS create a team and spawn reviewer agents via Task()
  • NEVER read code and produce findings directly — that's what the reviewer agents do
  • Your job: detect scope, gate-check, route reviewers, validate findings, aggregate results, produce report

---

0. Scope Detection

Parse arguments to determine WHAT to review.

Argument Parsing

| Argument | Scope | How to Get Diff | |----------|-------|-----------------| | `--pr N` | Review PR #N | `gh pr diff N` | | `--changes` | Uncommitted + staged changes | `git diff HEAD` | | `--increment NNNN` | Changes from increment NNNN | `git diff` on files touched by increment | | `--cross-repo` | All repos in umbrella | Per-repo `git diff` (see Section 5) | | `path/to/dir` | Specific directory/file | Read files directly | | *(no args)* | Auto-detect (see below) | Varies |

Auto-Detection (no arguments)

# 1. Check for open PR on current branch
PR_NUM=$(gh pr view --json number -q '.number' 2>/dev/null)
if [ -n "$PR_NUM" ]; then
  SCOPE="pr"
  REVIEW_TARGET="$PR_NUM"
fi

# 2. Check for uncommitted changes
if [ -z "$SCOPE" ]; then
  CHANGES=$(git diff --stat HEAD 2>/dev/null)
  if [ -n "$CHANGES" ]; then
    SCOPE="changes"
    REVIEW_TARGET="uncommitted changes"
  fi
fi

# 3. Check for active increment
if [ -z "$SCOPE" ]; then
  ACTIVE=$(find .specweave/increments -maxdepth 2 -name "metadata.json" \
    -exec grep -l '"active"' {} \; 2>/dev/null | head -1)
  if [ -n "$ACTIVE" ]; then
    SCOPE="increment"
    REVIEW_TARGET=$(dirname "$ACTIVE")
  fi
fi

# 4. Fall back to whole project
if [ -z "$SCOPE" ]; then
  SCOPE="project"
  REVIEW_TARGET="."
fi

Build File List

Once scope is determined, build the list of files to review:

case "$SCOPE" in
  pr)       FILES=$(gh pr diff "$REVIEW_TARGET" --name-only) ;;
  changes)  FILES=$(git diff --name-only HEAD) ;;
  increment) FILES=$(git log --name-only --pretty=format: -- "$REVIEW_TARGET") ;;
  project)  FILES=$(find src -type f -name "*.ts" -o -name "*.tsx" -o -name "*.js" 2>/dev/null) ;;
esac

Extract PR Context

When scope is `pr`, extract metadata for reviewer agents:

if [ "$SCOPE" = "pr" ]; then
  PR_TITLE=$(gh pr view "$REVIEW_TARGET" --json title -q '.title')
  PR_DESCRIPTION=$(gh pr view "$REVIEW_TARGET" --json body -q '.body')
fi

These values replace `[PR_TITLE]` and `[PR_DESCRIPTION]` placeholders in agent prompts. For non-PR scopes, placeholders are replaced with empty strings.

---

0.5 Gate Check

Before spawning reviewers, verify the review is worth running. Pass `--force` to bypass.

PR Scope

if [ "$SCOPE" = "pr" ]; then
  PR_STATE=$(gh pr view "$REVIEW_TARGET" --json state -q '.state')
  [ "$PR_STATE" = "MERGED" ] || [ "$PR_STATE" = "CLOSED" ] && echo "SKIP: PR is $PR_STATE" && exit 0

  IS_DRAFT=$(gh pr view "$REVIEW_TARGET" --json isDraft -q '.isDraft')
  [ "$IS_DRAFT" = "
Read more
Ships withspecweave

Spec-first AI development: describe a feature → AI creates spec + plan + tasks, builds autonomously, syncs to GitHub/JIRA. Domain-expert skills for PM, Architect, Frontend, QA learn your patterns permanently. Claude Code, Codex, Cursor, Copilot & more.

Get the whole plugin