Code Review (4-Agent)
Comprehensive code review that dispatches 4 specialized agents in parallel for deep analysis.
Workflow
Phase 1: Preparation
- Detect the review scope:
- If on a feature branch:
git diff $(git merge-base main HEAD)..HEAD
- If PR number provided:
gh pr diff <number>
- Fallback: staged + unstaged changes
- Get list of changed files:
git diff --name-only <range>
- Read all changed files in full (agents need complete context)
Phase 2: Dispatch 4 Agents in Parallel
Launch 4 agents in a single turn:
Agent 1 — Correctness & Logic
- Logic bugs, edge cases, null/undefined risks
- Off-by-one errors, race conditions
- Incorrect error handling, missing return values
- Type mismatches, contract violations
Agent 2 — Security
- Injection vulnerabilities (SQL, XSS, command)
- Auth/authz gaps, missing input validation
- Secrets in code, insecure defaults
- OWASP Top 10 patterns
Agent 3 — Performance
- N+1 queries, unnecessary re-renders
- Missing memoization, expensive computations in loops
- Bundle size impact, large imports
- Memory leaks, unbounded collections
Agent 4 — Style & Maintainability
- Naming clarity, dead code, unused imports
- Overly complex logic (cyclomatic complexity)
- Missing or misleading comments
- DRY violations, code duplication
Each agent outputs findings as:
### [CRITICAL|HIGH|MEDIUM|LOW] Title
**File:** path/to/file:line
**Description:** what's wrong and why
**Suggestion:** how to fix
Phase 3: Unified Report
Collect all 4 agent results and produce a single report:
# Code Review Report
## Summary
- X critical, Y high, Z medium, W low findings
- Overall assessment: APPROVE / REQUEST_CHANGES / COMMENT
## Critical & High Findings
(sorted by severity, then by file)
## Medium & Low Findings
(collapsed or summarized)
## Positive Notes
(good patterns worth highlighting)
Phase 4: Action (optional)
- If user says
/code-review --fix, attempt to auto-fix MEDIUM and LOW findings
- If reviewing a PR, offer to post the review as a GitHub comment
Arguments
/code-review — review current branch changes
/code-review #<number> — review specific PR
/code-review --fix — auto-fix medium/low findings after review
Rules
- NEVER approve code with CRITICAL findings
- Deduplicate findings across agents (same file:line = merge)
- Include positive feedback — don't make it only negative
- If the diff is huge (>2000 lines), split into chunks and review each
- Be strict but fair — only flag real issues, not style preferences
1---2name: code-review3description: Comprehensive code review with 4 parallel agents: correctness/logic, security, performance, style/maintainability. Produces unified severity report (CRITICAL/HIGH/MEDIUM/LOW). Use for thorough PR reviews and pre-merge checks.4license: MIT5---67# Code Review (4-Agent)89Comprehensive code review that dispatches 4 specialized agents in parallel for deep analysis.1011## Workflow1213### Phase 1: Preparation141. Detect the review scope:15 - If on a feature branch: `git diff $(git merge-base main HEAD)..HEAD`16 - If PR number provided: `gh pr diff <number>`17 - Fallback: staged + unstaged changes182. Get list of changed files: `git diff --name-only <range>`193. Read all changed files in full (agents need complete context)2021### Phase 2: Dispatch 4 Agents in Parallel2223Launch 4 agents in a single turn:2425**Agent 1 — Correctness & Logic**26- Logic bugs, edge cases, null/undefined risks27- Off-by-one errors, race conditions28- Incorrect error handling, missing return values29- Type mismatches, contract violations3031**Agent 2 — Security**32- Injection vulnerabilities (SQL, XSS, command)33- Auth/authz gaps, missing input validation34- Secrets in code, insecure defaults35- OWASP Top 10 patterns3637**Agent 3 — Performance**38- N+1 queries, unnecessary re-renders39- Missing memoization, expensive computations in loops40- Bundle size impact, large imports41- Memory leaks, unbounded collections4243**Agent 4 — Style & Maintainability**44- Naming clarity, dead code, unused imports45- Overly complex logic (cyclomatic complexity)46- Missing or misleading comments47- DRY violations, code duplication4849Each agent outputs findings as:50```51### [CRITICAL|HIGH|MEDIUM|LOW] Title52**File:** path/to/file:line53**Description:** what's wrong and why54**Suggestion:** how to fix55```5657### Phase 3: Unified Report5859Collect all 4 agent results and produce a single report:6061```markdown62# Code Review Report6364## Summary65- X critical, Y high, Z medium, W low findings66- Overall assessment: APPROVE / REQUEST_CHANGES / COMMENT6768## Critical & High Findings69(sorted by severity, then by file)7071## Medium & Low Findings72(collapsed or summarized)7374## Positive Notes75(good patterns worth highlighting)76```7778### Phase 4: Action (optional)79- If user says `/code-review --fix`, attempt to auto-fix MEDIUM and LOW findings80- If reviewing a PR, offer to post the review as a GitHub comment8182## Arguments8384- `/code-review` — review current branch changes85- `/code-review #<number>` — review specific PR86- `/code-review --fix` — auto-fix medium/low findings after review8788## Rules8990- NEVER approve code with CRITICAL findings91- Deduplicate findings across agents (same file:line = merge)92- Include positive feedback — don't make it only negative93- If the diff is huge (>2000 lines), split into chunks and review each94- Be strict but fair — only flag real issues, not style preferences