code-review
npx skills add https://github.com/nokonoko1203/claude-code-settings --skill code-review
Agent 安装分布
Skill 文档
Code Review Skill
Comprehensive code review skill that combines PR review, self-review, and quality checks.
Usage
/code-review # Self-review: current branch vs main
/code-review <branch> # Self-review: current branch vs specified branch
/code-review pr <number> # PR review: review the specified PR
The argument is available as $ARGUMENTS.
Argument Parsing
$ARGUMENTS parsing:
- Empty â Self-review mode (base=main)
- "pr <number>" â PR review mode (use gh pr diff)
- Otherwise â Self-review mode (base=specified branch)
Review Process
IMPORTANT: Use Serena MCP extensively to analyze code efficiently while minimizing token consumption.
CRITICAL: Before starting any code review, you MUST read and understand the implementation guidelines:
- Read
@~/.claude/templates/frontend-implementation-guidelines.mdfor frontend code reviews - Read
@~/.claude/templates/backend-implementation-guidelines.mdfor backend code reviews - Apply the specific principles from these guidelines during your review
Step 1: Get Changes
For Self-Review (no args or branch name):
# Get current branch name
git branch --show-current
# Determine base branch (use main if $ARGUMENTS is empty, otherwise use $ARGUMENTS)
BASE_BRANCH=${ARGUMENTS:-main}
# Get list of changed files
git diff $BASE_BRANCH...HEAD --name-status
# Get commit history
git log $BASE_BRANCH..HEAD --oneline
# Get detailed diff
git diff $BASE_BRANCH...HEAD
For PR Review (pr <number>):
# Get PR information
gh pr view <number>
# Get PR diff
gh pr diff <number>
Step 2: Quality Check (All Files)
Perform quality checks on all changed files before detailed review:
Code Quality:
- Detect unused code (variables, parameters, functions, classes)
- Detect commented-out code blocks
- Detect unreachable code branches
Comment Quality:
- Detect progress/completion declarations (“implemented”, “done”, etc.)
- Detect date or version references in comments
Detection Methods:
- Use
mcp__serena__get_symbols_overviewto get symbol list - Use
mcp__serena__find_referencing_symbolsto check reference count (0 = unused candidate) - Use
Grepfor pattern matching:/\/\/.*?(å®è£ æ¸ã¿|done|å®äº|implemented)/i/\/\/.*?\d{4}[-\/]\d{1,2}[-\/]\d{1,2}/- Consecutive commented-out lines (3+ lines)
Step 3: Read Implementation Guidelines
Based on file extensions in the changes:
.ts,.tsx,.js,.jsx,.vue,.svelteâ Read frontend guidelines.py,.go,.java,.rs,.csâ Read backend guidelines- Both present â Read both guidelines
Step 4: Analyze Each Change
For each changed file:
- Get symbol overview: Use
mcp__serena__get_symbols_overview - Identify changed symbols: Use
mcp__serena__find_symbolfor details - Get original code: Use
git show <base-branch>:path/to/file - Check impact: Use
mcp__serena__find_referencing_symbols - Review related tests: Check test file changes
Step 5: Impact Analysis
Use find_referencing_symbols to investigate indirect impacts:
- Direct impact: List changed functions, APIs, screens
- Indirect impact: Identify callers/callees
- Breaking change risks: Type changes, return value changes, exception changes, state management changes, DB schema changes, cache changes
Step 6: Generate Review Report
Save the review results to .tmp/code-review-<branch-or-pr>.md
Output Format
Write the review in Japanese using the following format:
# ã³ã¼ãã¬ãã¥ã¼: <ãã©ã³ãå ã¾ã㯠PRçªå·>
## æ¦è¦
[夿´ã®ç®çã¨ç¯å²ã®è¦ç´]
---
## Quality Checkçµæ
### æªä½¿ç¨ã³ã¼ãã®æ¤åº
| ãã¡ã¤ã« | è¡ | ç¨®é¡ | 詳細 |
|----------|-----|------|------|
| path/to/file.ts | 42 | æªä½¿ç¨å¤æ° | `unusedVar` |
### ä¸é©åãªã³ã¡ã³ãã®æ¤åº
| ãã¡ã¤ã« | è¡ | å
容 |
|----------|-----|------|
| path/to/file.ts | 15 | "å®è£
æ¸ã¿" |
ï¼åé¡ãªããã°ãåé¡ãªããã¨è¨è¼ï¼
---
## ä¿®æ£1: [ä¿®æ£ã®æ¦è¦ã¿ã¤ãã«]
### èæ¯ã»å®è£
ã®æå³
[ä¿®æ£ãå¿
è¦ã«ãªã£ãèæ¯ã¨ããã®ã¢ããã¼ããé¸ãã çç±]
### ãã¡ã¤ã«ã¨é¢æ°
- **ãã¡ã¤ã«**: `path/to/file.ts`
- **颿°**: `functionName(args): returnType`
### 夿´å
容
```diff
- // ä¿®æ£å
+ // ä¿®æ£å¾
妥彿§è©ä¾¡
| è¦³ç¹ | è©ä¾¡ | 詳細 |
|---|---|---|
| ç®ç | OK / Needs Review / Problem | 説æ |
| ãã¸ã㯠| OK / Needs Review / Problem | 説æ |
| ã¨ã©ã¼ãã³ããªã³ã° | OK / Needs Review / Problem | 説æ |
| äºææ§ | OK / Needs Review / Problem | 説æ |
| ããã©ã¼ãã³ã¹ | OK / Needs Review / Problem | 説æ |
ãã¹ãã®æç¡
| ãã¹ãã±ã¼ã¹ | ç¶æ | ãã¡ã¤ã« |
|---|---|---|
| [ãã¹ãã®èª¬æ] | Yes / No | path/to/test.ts |
æ¸å¿µäºé
- [æ¸å¿µç¹ãããã°è¨è¼ããªããã°ããªãã]
ï¼ä¿®æ£ãã¨ã«ç¹°ãè¿ãï¼
æ³¢åç¯å²åæ
ç´æ¥å½±é¿
- [夿´ããã颿°ãAPIãç»é¢ã®ãªã¹ã]
鿥影é¿
- [find_referencing_symbolsã§æ¤åºããå¼ã³åºãå /å ]
ç ´å£ç夿´ã®å¯è½æ§
- å夿´
- æ»ãå¤å¤æ´
- ä¾å¤å¤æ´
- ç¶æ 管ç夿´
- DBã¹ãã¼ã夿´
- ãã£ãã·ã¥å¤æ´
ä¸ç¢ºå®æ§ï¼æ¨æ¸¬ç®æï¼
- [調æ»ãå®å ¨ã§ãªãé¨åãæ¨æ¸¬ã«åºã¥ãçºè¦]
è½ã¨ãç©´ãã§ãã¯ãªã¹ã
ã»ãã¥ãªãã£
- èªå¯ãã§ãã¯
- å ¥åããªãã¼ã·ã§ã³
- ãã°åºåï¼æ©å¯æ å ±æ¼æ´©ãªãï¼
- ã·ã¼ã¯ã¬ãã管ç
ããã©ã¼ãã³ã¹
- N+1ã¯ã¨ãª
- ã¡ã¢ãªä½¿ç¨é
- åæI/O
- ãã£ãã·ã¥æ¦ç¥
ä¾å¤å¦ç
- ãªãã©ã¤ãã¸ãã¯
- å¤é¨I/Oã¿ã¤ã ã¢ã¦ã
äºææ§
- å ¬éAPI
- ã¤ãã³ã
- ãã¼ã¿ãã¼ã¹ã¹ãã¼ã
追å ãã¹ããã¹ãã±ã¼ã¹
å¿ é
- [追å å¿ é ã®ãã¹ã]
æ¨å¥¨
- [ããã¨è¯ããã¹ã]
ã¨ãã¸ã±ã¼ã¹
- [ãã¹ããã¹ãã¨ãã¸ã±ã¼ã¹]
å®è£ ã¬ã¤ãã©ã¤ã³æºæ æ§
Frontendï¼è©²å½ããå ´åï¼
| åå | æºæ | ã³ã¡ã³ã |
|---|---|---|
| 1. é¢å¿ã®åé¢ï¼ã«ã¹ã¿ã ããã¯ï¼ | â/â³/à | |
| 2. ã¨ã©ã¼ãã³ããªã³ã° | â/â³/à | |
| 3. ãã¼ãã£ã³ã°ç¶æ 管ç | â/â³/à | |
| 4. ã¡ã¢åã«ããããã©ã¼ãã³ã¹æé©å | â/â³/à | |
| 5. TypeScriptåå®å ¨æ§ | â/â³/à | |
| 6. ã³ã³ãã¼ãã³ãåè§£ | â/â³/à | |
| 7. 宣è¨çUIãã¶ã¤ã³ | â/â³/à | |
| 8. éä¸ãã¼ã¿ç®¡ç | â/â³/à | |
| 9. 宿°ã®å¤é¨å | â/â³/à | |
| 10. Props Drillingåé¿ | â/â³/Ã |
Backendï¼è©²å½ããå ´åï¼
| åå | æºæ | ã³ã¡ã³ã |
|---|---|---|
| 1. ã¬ã¤ã¤ã¼ãã¢ã¼ããã¯ã㣠| â/â³/à | |
| 2. Resultåã¨ã©ã¼ãã³ããªã³ã° | â/â³/à | |
| 3. å ¥åããªãã¼ã·ã§ã³ | â/â³/à | |
| 4. ä¾åæ§æ³¨å ¥ | â/â³/à | |
| 5. ãã©ã³ã¶ã¯ã·ã§ã³ç®¡ç | â/â³/à | |
| 6. èªè¨¼ã»èªå¯ | â/â³/à | |
| 7. ä¸è²«ããAPIè¨è¨ | â/â³/à | |
| 8. ããã©ã¼ãã³ã¹æé©å | â/â³/à | |
| 9. ã»ãã¥ãªãã£ãã¤ãã¶ã¤ã³ | â/â³/à | |
| 10. å¯è¦³æ¸¬æ§ | â/â³/à | |
| 11. ä¿¡é ¼æ§ãã¿ã¼ã³ | â/â³/à | |
| 12. ã¹ã±ã¼ã©ããªã㣠| â/â³/à |
ã¬ãã¥ã¼ã³ã¡ã³ã
è¯ãç¹
- [ä»ã®éçºè ãå¦ã¹ãåªããè¨è¨ã»å®è£ ã®ã¿è¨è¼]
æ¹åç¹ã»ç¢ºèªç¹
- [å ·ä½çãªæ¹åææ¡]
夿´ãã¡ã¤ã«ä¸è¦§
| ãã¡ã¤ã« | 夿´ç¨®å¥ | 夿´å 容 |
|---|---|---|
| path/to/file1.ts | Modified | 夿´å 容ã®è¦ç´ |
| path/to/file2.ts | Added | 夿´å 容ã®è¦ç´ |
çµè«
[å ¨ä½çãªè©ä¾¡ã¨ããã¼ã¸å¯å¦ã®å¤æææ]
---
## Review Guidelines
### Important Guidelines for Writing Comments
- **Inline Comment Structure:**
- **Lead with conclusion:** Use a one-line summary of the main point
- **Reasoning and suggestions:** After the conclusion, provide detailed explanation
- **Focus on issues:** Focus on specific improvements like bug fixes, potential bugs, or readability issues
- **Regarding Positive Feedback:**
- **Be selective:** Only mention exceptional design choices or innovative implementations
- **Summarize positives:** Consolidate overall positive aspects in the summary section
### Review Perspectives
**[MANDATORY] Implementation Guidelines Compliance**
**For Frontend Code (`@~/.claude/templates/frontend-implementation-guidelines.md`):**
- **Principle 1**: Separation of Concerns Through Custom Hooks
- **Principle 2**: Comprehensive Error Handling with ErrorScreen components
- **Principle 3**: Loading State Management with LoadingScreen components
- **Principle 4**: Performance Optimization Through Memoization
- **Principle 5**: Type Safety with TypeScript
- **Principle 6**: Component Decomposition
- **Principle 7**: Declarative UI Design
- **Principle 8**: Centralized Data Management
- **Principle 9**: Externalization of Constants
- **Principle 10**: Avoiding Props Drilling
**For Backend Code (`@~/.claude/templates/backend-implementation-guidelines.md`):**
- **Principle 1**: Layered Architecture with Clear Boundaries
- **Principle 2**: Result-Based Error Handling and Logging
- **Principle 3**: Input Validation and Type Safety
- **Principle 4**: Dependency Injection for Testability
- **Principle 5**: Transaction Management
- **Principle 6**: Authentication and Authorization
- **Principle 7**: Consistent API Design
- **Principle 8**: Performance Optimization
- **Principle 9**: Security by Design
- **Principle 10**: Observable and Debuggable
- **Principle 11**: Reliability Engineering
- **Principle 12**: Scalability and Continuous Learning
### Evaluation Criteria
- **OK**: No issues, properly implemented
- **Needs Review**: Works correctly but needs confirmation or discussion
- **Problem**: Bug, security risk, or design problem
### Additional Notes
- Provide feedback in Japanese
- Give specific and actionable feedback
- Always explicitly state uncertainty - mark speculation clearly
- Use `mcp__serena__find_referencing_symbols` to assess breaking change risks
think super hard