Code Review — Automated Multi-Agent PR Review
Multi-Agent Code Review Pipeline
Launches 4+ parallel specialized agents with confidence scoring to review pull requests. Validates code changes against CLAUDE.md guidelines, detects bugs with Opus-powered analysis, and provides structured feedback with actionable recommendations.
✅ Multi-Agent📋 CLAUDE.md Compliance🐛 Bug Detection📊 Confidence ≥80
📚 What is this & why does it exist?
Code Review automates the PR review process by deploying multiple specialized AI agents in parallel. Rather than a single-pass review, it uses a pipeline approach: two agents check CLAUDE.md compliance, one Opus-powered agent hunts for subtle bugs, and one examines git history for context. Results are aggregated with confidence scores, and only findings above the 80% threshold are surfaced. This mimics how a senior engineering team reviews code — multiple perspectives, each with domain expertise.
💡 Real-world analogy
Imagine a code review meeting with four specialists sitting around a table: a style guide enforcer who checks every line against the team's conventions, a second enforcer who catches what the first missed, a seasoned debugger who has an instinct for subtle logic errors, and a historian who remembers why every past decision was made. They each review independently, then combine notes — only sharing findings they're confident about. That's exactly what this plugin orchestrates, but with AI agents instead of humans.
Architecture
flowchart TB
subgraph Input["Step 1: Input Validation"]
CMD["/code-review --comment"] --> VAL["Validate PR/Branch"]
VAL --> DIFF["Extract Diff"]
end
subgraph Context["Step 2: Context Gathering"]
DIFF --> CLAUDE_MD["Load CLAUDE.md"]
DIFF --> GIT_LOG["Load Git History"]
DIFF --> FILES["Load Changed Files"]
end
subgraph Parallel["Step 3: Parallel Agent Review"]
CLAUDE_MD --> CA1["Agent: CLAUDE.md
Compliance #1"]
CLAUDE_MD --> CA2["Agent: CLAUDE.md
Compliance #2"]
FILES --> BUG["Agent: Bug Detection
(Opus)"]
GIT_LOG --> HIST["Agent: History
Context"]
end
subgraph Validation["Step 4: Result Validation"]
CA1 --> AGG["Aggregate Results"]
CA2 --> AGG
BUG --> AGG
HIST --> AGG
AGG --> FILTER{"Confidence
≥ 80%?"}
FILTER -->|Yes| KEEP["Keep Finding"]
FILTER -->|No| DROP["Discard"]
end
subgraph Output["Step 5: Output"]
KEEP --> FORMAT["Format Report"]
FORMAT --> COMMENT{"--comment
flag?"}
COMMENT -->|Yes| PR_COMMENT["Post PR Comment"]
COMMENT -->|No| TERMINAL["Terminal Output"]
end
Agent Specifications
📋 CLAUDE.md Compliance Agent (x2)
Two independent agents check every changed line against project-specific CLAUDE.md guidelines. Running two instances catches inconsistencies that a single pass might miss. Each produces findings with confidence scores.
- Model: Sonnet (fast, cost-effective)
- Focus: Style, naming, patterns, banned APIs
- Output: List of violations with line numbers
🐛 Bug Detection Agent (Opus)
Uses the most capable model (Opus) to hunt for subtle logic errors, race conditions, null pointer risks, off-by-one errors, and security vulnerabilities. Expensive but high-value.
- Model: Opus (maximum reasoning)
- Focus: Logic bugs, security, edge cases
- Output: Bug reports with severity and fix suggestions
📚 History Context Agent
Examines git log, blame data, and related PRs to understand why the code being changed was written the way it was. Flags changes that may break implicit contracts or revert intentional decisions.
- Model: Sonnet
- Focus: Context, intent preservation, regressions
- Output: Context warnings and decision history
✅ Parallel Validators
Additional lightweight validators that run alongside the main agents: import sorting, test coverage delta, TODO/FIXME scanning, and dependency version checks.
- Model: Haiku (fast checks)
- Focus: Mechanical validations
- Output: Pass/fail checklist items
Review Pipeline
sequenceDiagram
participant Dev as Developer
participant Cmd as /code-review
participant Val as Validator
participant CM as CLAUDE.md Agents
participant Bug as Bug Agent (Opus)
participant Hist as History Agent
participant Agg as Aggregator
Dev->>Cmd: /code-review --comment
Cmd->>Val: Step 1: Validate PR exists
Val-->>Cmd: PR #42 validated
Cmd->>Cmd: Step 2: Extract diff + context
par Step 3: Parallel Review
Cmd->>CM: CLAUDE.md check (agent 1)
Cmd->>CM: CLAUDE.md check (agent 2)
Cmd->>Bug: Deep bug analysis
Cmd->>Hist: History context scan
end
CM-->>Agg: 3 findings (90%, 85%, 72%)
CM-->>Agg: 2 findings (88%, 65%)
Bug-->>Agg: 1 critical bug (95%)
Hist-->>Agg: 1 context warning (82%)
Agg->>Agg: Step 4: Filter confidence ≥ 80%
Note over Agg: Kept: 5 findings
Dropped: 2 (below threshold)
Agg->>Cmd: Step 5: Formatted report
Cmd->>Dev: Posted as PR comment
Command Reference
| Command | Description | Arguments |
|---|---|---|
/code-review | Runs the full multi-agent review pipeline on the current PR or branch diff. Outputs a structured report to the terminal by default. | --comment post as PR comment, --branch <name> review specific branch, --threshold <n> confidence threshold (default 80) |
Key Components
| Component | File | Role |
|---|---|---|
code-review | commands/code-review.md | Main command orchestrating the review pipeline |
agent-configs | agents/review-agents.md | Configuration for all 4+ review agents |
plugin.json | .claude-plugin/plugin.json | Plugin manifest with agent and command registration |
Confidence Scoring
Each agent assigns a confidence score (0–100) to every finding. The aggregator applies these rules:
| Score Range | Action | Label |
|---|---|---|
90–100 | Always surfaced, highlighted | Critical |
80–89 | Surfaced in report | Suggestion |
60–79 | Discarded (below threshold) | Low Confidence |
0–59 | Silently dropped | — |
Interactions
| Module | Interface | Data Exchanged |
|---|---|---|
| Git / GitHub CLI | PR diff extraction | Changed files, commit history, PR metadata |
| CLAUDE.md | File read | Project-specific coding guidelines and rules |
| Claude Code Agent System | Parallel agent spawning | Agent configs, prompts, and collected results |
| GitHub API | PR comment posting | Formatted review comment (when --comment flag used) |
Directory Map
Source tree for Code Review
code-review/
├── .claude-plugin/plugin.json ← Plugin manifest
├── commands/
│ └── code-review.md ← Review pipeline orchestrator
└── agents/
└── review-agents.md ← Agent configurations (4+ agents)
Configuration Reference
| Parameter | Default | Description |
|---|---|---|
confidence_threshold | 80 | Minimum confidence score to surface a finding |
bug_agent_model | opus | Model for the bug detection agent |
compliance_agents | 2 | Number of parallel CLAUDE.md compliance agents |
auto_comment | false | Automatically post PR comment without --comment flag |
max_diff_lines | 5000 | Maximum diff size before chunked review |
include_validators | true | Run lightweight parallel validators alongside agents |