spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / code-review / README.md
256 lines · 7.3 KBPreviewCodeRaw
1# Code Review Plugin
2
3Automated code review for pull requests using multiple specialized agents with confidence-based scoring to filter false positives.
4
5## Overview
6
7The Code Review Plugin automates pull request review by launching multiple agents in parallel to independently audit changes from different perspectives. It uses confidence scoring to filter out false positives, ensuring only high-quality, actionable feedback is posted.
8
9## Commands
10
11### `/code-review`
12
13Performs automated code review on a pull request using multiple specialized agents.
14
15**What it does:**
161. Checks if review is needed (skips closed, draft, trivial, or already-reviewed PRs)
172. Gathers relevant CLAUDE.md guideline files from the repository
183. Summarizes the pull request changes
194. Launches 4 parallel agents to independently review:
20 - **Agents #1 & #2**: Audit for CLAUDE.md compliance
21 - **Agent #3**: Scan for obvious bugs in changes
22 - **Agent #4**: Analyze git blame/history for context-based issues
235. Scores each issue 0-100 for confidence level
246. Filters out issues below 80 confidence threshold
257. Posts review comment with high-confidence issues only
26
27**Usage:**
28```bash
29/code-review
30```
31
32**Example workflow:**
33```bash
34# On a PR branch, run:
35/code-review
36
37# Claude will:
38# - Launch 4 review agents in parallel
39# - Score each issue for confidence
40# - Post comment with issues ≥80 confidence
41# - Skip posting if no high-confidence issues found
42```
43
44**Features:**
45- Multiple independent agents for comprehensive review
46- Confidence-based scoring reduces false positives (threshold: 80)
47- CLAUDE.md compliance checking with explicit guideline verification
48- Bug detection focused on changes (not pre-existing issues)
49- Historical context analysis via git blame
50- Automatic skipping of closed, draft, or already-reviewed PRs
51- Links directly to code with full SHA and line ranges
52
53**Review comment format:**
54```markdown
55## Code review
56
57Found 3 issues:
58
591. Missing error handling for OAuth callback (CLAUDE.md says "Always handle OAuth errors")
60
61https://github.com/owner/repo/blob/abc123.../src/auth.ts#L67-L72
62
632. Memory leak: OAuth state not cleaned up (bug due to missing cleanup in finally block)
64
65https://github.com/owner/repo/blob/abc123.../src/auth.ts#L88-L95
66
673. Inconsistent naming pattern (src/conventions/CLAUDE.md says "Use camelCase for functions")
68
69https://github.com/owner/repo/blob/abc123.../src/utils.ts#L23-L28
70```
71
72**Confidence scoring:**
73- **0**: Not confident, false positive
74- **25**: Somewhat confident, might be real
75- **50**: Moderately confident, real but minor
76- **75**: Highly confident, real and important
77- **100**: Absolutely certain, definitely real
78
79**False positives filtered:**
80- Pre-existing issues not introduced in PR
81- Code that looks like a bug but isn't
82- Pedantic nitpicks
83- Issues linters will catch
84- General quality issues (unless in CLAUDE.md)
85- Issues with lint ignore comments
86
87## Installation
88
89This plugin is included in the Claude Code repository. The command is automatically available when using Claude Code.
90
91### Building the MCP server
92
93To build the GitHub tools MCP server:
94
95```bash
96cd plugins/code-review/github-tools
97bun install
98bun run build
99```
100
101## Best Practices
102
103### Using `/code-review`
104- Maintain clear CLAUDE.md files for better compliance checking
105- Trust the 80+ confidence threshold - false positives are filtered
106- Run on all non-trivial pull requests
107- Review agent findings as a starting point for human review
108- Update CLAUDE.md based on recurring review patterns
109
110### When to use
111- All pull requests with meaningful changes
112- PRs touching critical code paths
113- PRs from multiple contributors
114- PRs where guideline compliance matters
115
116### When not to use
117- Closed or draft PRs (automatically skipped anyway)
118- Trivial automated PRs (automatically skipped)
119- Urgent hotfixes requiring immediate merge
120- PRs already reviewed (automatically skipped)
121
122## Workflow Integration
123
124### Standard PR review workflow:
125```bash
126# Create PR with changes
127/code-review
128
129# Review the automated feedback
130# Make any necessary fixes
131# Merge when ready
132```
133
134### As part of CI/CD:
135```bash
136# Trigger on PR creation or update
137# Automatically posts review comments
138# Skip if review already exists
139```
140
141## Requirements
142
143- Git repository with GitHub integration
144- GitHub CLI (`gh`) installed and authenticated
145- CLAUDE.md files (optional but recommended for guideline checking)
146
147## Troubleshooting
148
149### Review takes too long
150
151**Issue**: Agents are slow on large PRs
152
153**Solution**:
154- Normal for large changes - agents run in parallel
155- 4 independent agents ensure thoroughness
156- Consider splitting large PRs into smaller ones
157
158### Too many false positives
159
160**Issue**: Review flags issues that aren't real
161
162**Solution**:
163- Default threshold is 80 (already filters most false positives)
164- Make CLAUDE.md more specific about what matters
165- Consider if the flagged issue is actually valid
166
167### No review comment posted
168
169**Issue**: `/code-review` runs but no comment appears
170
171**Solution**:
172Check if:
173- PR is closed (reviews skipped)
174- PR is draft (reviews skipped)
175- PR is trivial/automated (reviews skipped)
176- PR already has review (reviews skipped)
177- No issues scored ≥80 (no comment needed)
178
179### Link formatting broken
180
181**Issue**: Code links don't render correctly in GitHub
182
183**Solution**:
184Links must follow this exact format:
185```
186https://github.com/owner/repo/blob/[full-sha]/path/file.ext#L[start]-L[end]
187```
188- Must use full SHA (not abbreviated)
189- Must use `#L` notation
190- Must include line range with at least 1 line of context
191
192### GitHub CLI not working
193
194**Issue**: `gh` commands fail
195
196**Solution**:
197- Install GitHub CLI: `brew install gh` (macOS) or see [GitHub CLI installation](https://cli.github.com/)
198- Authenticate: `gh auth login`
199- Verify repository has GitHub remote
200
201## Tips
202
203- **Write specific CLAUDE.md files**: Clear guidelines = better reviews
204- **Include context in PRs**: Helps agents understand intent
205- **Use confidence scores**: Issues ≥80 are usually correct
206- **Iterate on guidelines**: Update CLAUDE.md based on patterns
207- **Review automatically**: Set up as part of PR workflow
208- **Trust the filtering**: Threshold prevents noise
209
210## Configuration
211
212### Adjusting confidence threshold
213
214The default threshold is 80. To adjust, modify the command file at `commands/code-review.md`:
215```markdown
216Filter out any issues with a score less than 80.
217```
218
219Change `80` to your preferred threshold (0-100).
220
221### Customizing review focus
222
223Edit `commands/code-review.md` to add or modify agent tasks:
224- Add security-focused agents
225- Add performance analysis agents
226- Add accessibility checking agents
227- Add documentation quality checks
228
229## Technical Details
230
231### Agent architecture
232- **2x CLAUDE.md compliance agents**: Redundancy for guideline checks
233- **1x bug detector**: Focused on obvious bugs in changes only
234- **1x history analyzer**: Context from git blame and history
235- **Nx confidence scorers**: One per issue for independent scoring
236
237### Scoring system
238- Each issue independently scored 0-100
239- Scoring considers evidence strength and verification
240- Threshold (default 80) filters low-confidence issues
241- For CLAUDE.md issues: verifies guideline explicitly mentions it
242
243### GitHub integration
244Uses `gh` CLI for:
245- Viewing PR details and diffs
246- Fetching repository data
247- Reading git blame and history
248- Posting review comments
249
250## Author
251
252Boris Cherny (boris@anthropic.com)
253
254## Version
255
2561.0.0