code-review について
code-reviewは、コミットやデプロイ前の変更を確認するスキルです。Claude、OpenAI Codex、Google Gemini、または複数エンジンを選べます。レビュー前のADRゲートが設計判断を見つけて文脈に加え、設定に応じて記録を求めます。
主な機能
- 01Claude、Codex、Geminiによる単一または複数エンジンのレビュー
- 02レビュー前のADRと仕様の検出・確認
- 03セキュリティ、性能、設計、テストなどの分析
- 04複数エンジンの指摘の比較と重複排除
- 05pre-commitフックとGitHub Actionsへの対応
活用シーン
- 01コミット前のステージ済み変更のレビュー
- 02マージ前のPull Request確認
- 03CI/CDでのレビュー自動化
- 04セキュリティ重視のコードに複数エンジンを使用
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ alinaqi/ maggy --skill code-reviewインストール後、Claude Code で/code-reviewを入力して読み込まれたか確認します。
同梱ファイルadr-gate.md
詳細
コードレビュー スキル
目的: すべてのコミットとデプロイの前に、必須の安全策として自動コードレビューを実施します。包括的な分析のために、Claude、OpenAI Codex、Google Gemini、または複数のエンジンから選択できます。
サブスキル:
- adr-gate.md — レビュー前のADRと仕様の適用
レビュー前:ADR ゲート(必須)
レビューエンジンが実行される前に、ADR ゲートが自動的に実行されます。
- 分類 — 軽微な変更(誤字、依存関係、テストのみ)はゲートをスキップします
- 検出 —
docs/adr/、_project_specs/、iCPG ReasonNodes、Git 履歴をスキャンし、関連するADRと仕様を探します - 適用 — 軽微でない変更にADRが見つからない場合:
- 対話型(デフォルト):Git 履歴からADRの草案を作成し、ユーザーに確認を求めます
- 無人実行(CI):
Status: proposedとして記述し、続行します - 厳格:ADRが存在するまでレビューをブロックします
- 注入 — 検出したADRと仕様を、アーキテクチャのコンテキストとしてレビュープロンプトに渡します
ADR 準拠レビュー項目
標準の7つのレビューカテゴリに追加されます。
| カテゴリ | チェック内容 |
|---|---|
| ADR 準拠 | 変更が文書化された決定に準拠しているか、文書化されていないアーキテクチャの変更がないか |
| 指摘事項 | 重大度 |
|---|---|
| 変更が承認済みADRに矛盾する | Critical |
| アーキテクチャ上の決定がどのADRにも記載されていない | High |
| ADRが存在するが古くなっている | Medium |
| ADRの意図からわずかに逸脱している | Low |
プロトコル全体、リバースエンジニアリングのルール、設定については、adr-gate.md を参照してください。
レビューエンジンの選択
/code-review の実行時に、ユーザーは好みのレビューエンジンを選択できます。
┌─────────────────────────────────────────────────────────────────┐
│ CODE REVIEW - Choose Your Engine │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ○ Claude (default) │
│ Built-in, no extra setup, full conversation context │
│ │
│ ○ OpenAI Codex CLI │
│ GPT-5.2-Codex specialized for code review, 88% detection │
│ Requires: npm install -g @openai/codex │
│ │
│ ○ Google Gemini CLI │
│ Gemini 2.5 Pro with 1M token context, free tier available │
│ Requires: npm install -g @google/gemini-cli │
│ │
│ ○ Dual Engine (any two) │
│ Run two engines, compare findings, catch more issues │
│ │
│ ○ All Three (maximum coverage) │
│ Run Claude + Codex + Gemini for critical/security code │
│ │
└─────────────────────────────────────────────────────────────────┘
エンジンの比較
| 項目 | Claude | Codex | Gemini | マルチエンジン |
|---|---|---|---|---|
| セットアップ | 不要 | npm + OpenAI API | npm + Google アカウント | すべてのセットアップ |
| 速度 | 高速 | 高速 | 高速 | 2~3倍の時間 |
| コンテキスト | 会話 | レビューごとに新規 | 1M トークン | 該当なし |
| 検出精度 | 良好 | 88%(最高) | SWE-Bench で 63.8% | 組み合わせ |
| 無料枠 | 該当なし | 制限あり | 1,000/日 | 条件による |
| 最適な用途 | 簡易レビュー | 高精度が必要な場合 | 大規模なコードベース | 重要なコード |
デフォルトエンジンの設定
# ~/.claude/settings.toml or project CLAUDE.md
[code-review]
default_engine = "claude" # Options: claude, codex, gemini, dual, all
使用例
# Use default engine
/code-review
# Explicitly choose engine
/code-review --engine claude
/code-review --engine codex
/code-review --engine gemini
# Dual engine (pick any two)
/code-review --engine claude,codex
/code-review --engine claude,gemini
/code-review --engine codex,gemini
# All three engines
/code-review --engine all
# Quick shortcuts
/code-review # Uses default
/code-review --codex # Use Codex
/code-review --gemini # Use Gemini
/code-review --all # All three engines
マルチエンジンの出力
複数のエンジンを使用する場合、指摘事項を比較して重複を排除します。
デュアルエンジンの例
┌─────────────────────────────────────────────────────────────────┐
│ CODE REVIEW RESULTS - DUAL ENGINE (Claude + Codex) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ✅ AGREED (Found by both): │
│ 🔴 SQL injection in auth.ts:45 │
│ 🟡 Missing error handling in api.ts:112 │
│ │
│ 🔷 CLAUDE ONLY: │
│ 🟠 Potential race condition in worker.ts:89 │
│ 🟢 Consider extracting helper function │
│ │
│ 🔶 CODEX ONLY: │
│ 🟠 Memory leak - unclosed stream in upload.ts:34 │
│ 🟡 N+1 query pattern in orders.ts:156 │
│ │
├─────────────────────────────────────────────────────────────────┤
│ SUMMARY │
│ Agreed: 2 | Claude only: 2 | Codex only: 2 │
│ Critical: 1 | High: 2 | Medium: 2 | Low: 1 │
│ Status: ❌ BLOCKED - Fix critical/high issues │
└─────────────────────────────────────────────────────────────────┘
トリプルエンジンの例(3つすべて)
┌─────────────────────────────────────────────────────────────────┐
│ CODE REVIEW RESULTS - TRIPLE ENGINE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ✅ UNANIMOUS (All 3 found): │
│ 🔴 SQL injection in auth.ts:45 │
│ │
│ ✅ MAJORITY (2 of 3 found): │
│ 🟠 Memory leak - unclosed stream in upload.ts:34 (Codex+Gemini)│
│ 🟡 Missing error handling in api.ts:112 (Claude+Codex) │
│ │
│ 🔷 CLAUDE ONLY: │
│ 🟠 Potential race condition in worker.ts:89 │
│ │
│ 🔶 CODEX ONLY: │
│ 🟡 N+1 query pattern in orders.ts:156 │
│ │
│ 🟢 GEMINI ONLY: │
│ 🟡 Consider using batch API for better performance │
│ 🟢 Type could be more specific in types.ts:23 │
│ │
├─────────────────────────────────────────────────────────────────┤
│ SUMMARY │
│ Unanimous: 1 | Majority: 2 | Single: 5 │
│ Critical: 1 | High: 2 | Medium: 3 | Low: 2 │
│ Status: ❌ BLOCKED - Fix critical/high issues │
└─────────────────────────────────────────────────────────────────┘
各モードの使用場面
| モード | 使用場面 |
|---|---|
| 単一(Claude) | 迅速な作業中レビュー、調査 |
| 単一(Codex) | CI/CD の自動化、高精度が必要な場合 |
| 単一(Gemini) | 大規模なコードベース(100ファイル以上)、無料枠 |
| デュアル | 重要なPR、マージ前のレビュー |
| トリプル(すべて) | セキュリティ上重要なコード、決済システム、認証 |
基本方針
┌─────────────────────────────────────────────────────────────────┐
│ CODE REVIEW IS NON-NEGOTIABLE │
│ ───────────────────────────────────────────────────────────── │
│ │
│ Every commit must pass code review. │
│ Every PR must be reviewed before merge. │
│ Every deployment must include review sign-off. │
│ │
│ AI catches what humans miss. Humans catch what AI misses. │
│ Together: fewer bugs, cleaner code, better security. │
├─────────────────────────────────────────────────────────────────┤
│ INVOKE: /code-review │
│ PLUGIN: code-review@claude-plugins-official │
└─────────────────────────────────────────────────────────────────┘
コードレビューを実施するタイミング
必須のレビュータイミング
| トリガー | アクション | コマンド |
|---|---|---|
| コミット前 | ステージ済みの変更をレビュー | /code-review |
| PR 前 | ベースとの差分をすべてレビュー | /code-review |
| マージ前 | PR の最終レビュー | /code-review |
| デプロイ前 | デプロイの差分をレビュー | /code-review |
自動統合
すべてのコミット前にコードレビューを自動実行します。
┌─────────────────────────────────────────────────────────────────┐
│ COMMIT WORKFLOW │
│ ───────────────────────────────────────────────────────────── │
│ │
│ 1. Write code │
│ 2. Run tests (TDD - must pass) │
│ 3. Run /code-review ← MANDATORY │
│ 4. Address critical/high issues │
│ 5. Commit │
│ 6. Push │
│ │
│ Skip step 3? ❌ NO COMMIT ALLOWED │
└─────────────────────────────────────────────────────────────────┘
コードレビュー プラグインの使用
基本的な使い方
# Review current changes
/code-review
# Review specific files
/code-review src/auth/*.ts
# Review a PR
/code-review --pr 123
# Review with specific focus
/code-review --focus security
/code-review --focus performance
/code-review --focus architecture
レビューカテゴリ
コードレビュー プラグインでは、次の項目を分析します。
| カテゴリ | チェック内容 |
|---|---|
| セキュリティ | 脆弱性、インジェクションのリスク、認証の問題、シークレット |
| パフォーマンス | N+1 クエリ、メモリリーク、非効率なアルゴリズム |
| アーキテクチャ | デザインパターン、SOLID 原則、結合度 |
| コード品質 | 可読性、複雑さ、重複 |
| ベストプラクティス | 言語の慣用表現、フレームワークの規約 |
| テスト | カバレッジの不足、テストの品質、エッジケース |
| ドキュメント | 不足しているドキュメント、古くなったコメント |
重大度レベル
| レベル | 必要な対応 | コミット可能? |
|---|---|---|
| 🔴 致命的 | 直ちに修正する必要があります | ❌ いいえ |
| 🟠 高 | コミット前に修正する必要があります | ❌ いいえ |
| 🟡 中 | 早めに修正します。コミット可能です | ✅ はい |
| 🟢 低 | できれば修正します | ✅ はい |
| ℹ️ 情報 | 提案のみです | ✅ はい |
コミット前フックとの統合
コミット前フックをインストールする
#!/bin/bash
# .git/hooks/pre-commit
echo "🔍 Running code review..."
# Run Claude code review on staged files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|py|go|rs)$')
if [ -n "$STAGED_FILES" ]; then
# Invoke code review (requires claude CLI)
claude --print "/code-review $STAGED_FILES" > /tmp/code-review-result.txt 2>&1
# Check for critical/high issues
if grep -q "🔴\|Critical\|🟠\|High" /tmp/code-review-result.txt; then
echo "❌ Code review found critical/high issues:"
cat /tmp/code-review-result.txt
echo ""
echo "Fix these issues before committing."
exit 1
fi
echo "✅ Code review passed"
fi
exit 0
フックを実行可能にする
chmod +x .git/hooks/pre-commit
Codex CLI のセットアップ(Codex/両方のモード向け)
Codex モードまたは両方のモードを使用する場合は、Codex CLI をインストールします。
# Prerequisites: Node.js 22+
node --version # Must be 22+
# Install Codex CLI
npm install -g @openai/codex
# Authenticate (choose one):
# Option 1: ChatGPT subscription (Plus, Pro, Team, Enterprise)
codex # Follow prompts to sign in
# Option 2: API key
export OPENAI_API_KEY=sk-proj-...
インストールを確認する
# Check Codex is installed
codex --version
# Test review
codex
> /review
Codex の詳細なドキュメントについては、codex-review.md スキルを参照してください。
Gemini CLI のセットアップ(Gemini/マルチエンジンモード向け)
Gemini モードまたはマルチエンジンモードを使用する場合は、Gemini CLI をインストールします。
# Prerequisites: Node.js 20+
node --version # Must be 20+
# Install Gemini CLI
npm install -g @google/gemini-cli
# Or via Homebrew (macOS)
brew install gemini-cli
# Install Code Review extension
gemini extensions install https://github.com/gemini-cli-extensions/code-review
認証する
# Option 1: Google Account (recommended, 1000 req/day free)
gemini # Follow browser login prompts
# Option 2: API key (100 req/day free)
export GEMINI_API_KEY="your-key-from-aistudio.google.com"
インストールを確認する
# Check Gemini is installed
gemini --version
# List extensions
gemini extensions list
# Test review
gemini
> /code-review
Gemini の詳細なドキュメントについては、gemini-review.md スキルを参照してください。
CI/CD との統合
GitHub Actions - Claude のみ
# .github/workflows/code-review.yml
name: Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
run: |
echo "files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Run Claude Code Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
npx @anthropic-ai/claude-code --print "/code-review ${{ steps.changed-files.outputs.files }}" > review.md
- name: Post Review Comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## 🔍 Claude Code Review\n\n${review}`
});
- name: Check for Critical Issues
run: |
if grep -q "Critical\|🔴" review.md; then
echo "❌ Critical issues found"
exit 1
fi
GitHub Actions - Codex のみ
# .github/workflows/codex-review.yml
name: Codex Code Review
on:
pull_request:
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Codex Review
uses: openai/codex-action@main
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
model: gpt-5.2-codex
safety_strategy: drop-sudo
GitHub Actions - 両方のエンジン
# .github/workflows/dual-review.yml
name: Dual Code Review
on:
pull_request:
jobs:
claude-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Claude Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
npx @anthropic-ai/claude-code --print "/code-review" > claude-review.md
- uses: actions/upload-artifact@v4
with:
name: claude-review
path: claude-review.md
codex-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Codex
run: npm install -g @openai/codex
- name: Codex Review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
codex exec --full-auto --sandbox read-only \
--output-last-message codex-review.md \
"Review this code for bugs, security issues, and quality problems"
- uses: actions/upload-artifact@v4
with:
name: codex-review
path: codex-review.md
combine-reviews:
needs: [claude-review, codex-review]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Combine Reviews
run: |
echo "## 🔍 Dual Code Review Results" > combined-review.md
echo "" >> combined-review.md
echo "### Claude Findings" >> combined-review.md
cat claude-review/claude-review.md >> combined-review.md
echo "" >> combined-review.md
echo "### Codex Findings" >> combined-review.md
cat codex-review/codex-review.md >> combined-review.md
- name: Post Combined Review
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('combined-review.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: review
});
GitHub Actions - Gemini のみ
# .github/workflows/gemini-review.yml
name: Gemini Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Gemini CLI
run: npm install -g @google/gemini-cli
- name: Run Review
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
# Get diff
git diff origin/${{ github.base_ref }}...HEAD > diff.txt
# Run Gemini review
gemini -p "Review this pull request diff for bugs, security issues, and code quality problems. Be specific about file names and line numbers.
$(cat diff.txt)" > review.md
- name: Post Review Comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## 🤖 Gemini Code Review\n\n${review}`
});
- name: Check for Critical Issues
run: |
if grep -qi "critical\|security vulnerability\|injection" review.md; then
echo "❌ Critical issues found"
exit 1
fi
GitHub Actions - 3 つすべてのエンジン
# .github/workflows/triple-review.yml
name: Triple Engine Code Review
on:
pull_request:
jobs:
claude-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Claude Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
npx @anthropic-ai/claude-code --print "/code-review" > claude-review.md
- uses: actions/upload-artifact@v4
with:
name: claude-review
path: claude-review.md
codex-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Codex
run: npm install -g @openai/codex
- name: Codex Review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
codex exec --full-auto --sandbox read-only \
--output-last-message codex-review.md \
"Review this code for bugs, security issues, and quality problems"
- uses: actions/upload-artifact@v4
with:
name: codex-review
path: codex-review.md
gemini-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Gemini CLI
run: npm install -g @google/gemini-cli
- name: Gemini Review
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
git diff origin/${{ github.base_ref }}...HEAD > diff.txt
gemini -p "Review this code diff for bugs, security, and quality issues:
$(cat diff.txt)" > gemini-review.md
- uses: actions/upload-artifact@v4
with:
name: gemini-review
path: gemini-review.md
combine-reviews:
needs: [claude-review, codex-review, gemini-review]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Combine Reviews
run: |
echo "## 🔍 Triple Engine Code Review Results" > combined-review.md
echo "" >> combined-review.md
echo "### 🟣 Claude Findings" >> combined-review.md
cat claude-review/claude-review.md >> combined-review.md
echo "" >> combined-review.md
echo "---" >> combined-review.md
echo "### 🟢 Codex Findings" >> combined-review.md
cat codex-review/codex-review.md >> combined-review.md
echo "" >> combined-review.md
echo "---" >> combined-review.md
echo "### 🔵 Gemini Findings" >> combined-review.md
cat gemini-review/gemini-review.md >> combined-review.md
- name: Post Combined Review
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('combined-review.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: review
});
- name: Check Critical Issues
run: |
# Fail if any engine found critical issues
if grep -qi "critical\|🔴" combined-review.md; then
echo "❌ Critical issues found by at least one engine"
exit 1
fi
レビューチェックリスト
コミットの前に毎回確認する項目
- ステージされた変更に対して
/code-reviewを実行する - 致命的(🔴)な問題がない
- 高(🟠)の問題がない
- セキュリティ上の懸念に対処している
- パフォーマンス上の問題を検討している
PR の前に毎回確認する項目
- すべての変更を完全にコードレビューする
- 致命的/高の問題をすべて解決している
- 新機能のテストを追加している
- 必要に応じてドキュメントを更新している
デプロイの前に毎回確認する項目
- デプロイ差分の最終レビューを行う
- セキュリティスキャンに合格している
- 新たな脆弱性が入り込んでいない
- ロールバック計画を文書化している
よくあるレビュー指摘事項
セキュリティ上の問題(必ず修正)
| 問題 | 例 | 修正方法 |
|---|---|---|
| SQL インジェクション | query = f"SELECT * FROM users WHERE id = {id}" | パラメーター化クエリを使用する |
| XSS | innerHTML = userInput | サニタイズするか、textContent を使用する |
| コード内のシークレット | apiKey = "sk-xxx" | 環境変数を使用する |
| 認証の欠如 | 保護されていないエンドポイント | 認証ミドルウェアを追加する |
| 安全でない暗号化 | パスワードに MD5/SHA1 を使用 | bcrypt/argon2 を使用する |
パフォーマンス上の問題(修正推奨)
| 問題 | 例 | 修正方法 |
|---|---|---|
| N+1 クエリ | ループ内で個別にクエリを実行 | バッチ処理/イーガーローディングを使用する |
| メモリーリーク | 接続を閉じていない | コネクションプーリングを使用する |
| インデックスの欠如 | クエリが遅い | データベースのインデックスを追加する |
| 大きなペイロード | 使用しないフィールドを取得している | 必要なフィールドのみを選択する |
| ページネーションがない | すべてのレコードを読み込む | ページネーションを実装する |
コード品質(できれば修正)
| 問題 | 例 | 修正方法 |
|---|---|---|
| 長すぎる関数 | 100 行以上 | 小さな関数に分割する |
| 深いネスト | 5 レベル以上 | 早期リターンを使い、メソッドを抽出する |
| マジックナンバー | if (status === 3) | 名前付き定数を使用する |
| コードの重複 | コピー&ペーストされたブロック | 共通関数を抽出する |
| 型の欠如 | あらゆる箇所で any を使用 | 適切な TypeScript 型を追加する |
レビュー後:意思決定の抽出
レビューの完了後、アーキテクチャ上の決定を自動的に抽出します。
- レビューで新たなアーキテクチャ上の選択が指摘された場合 →
docs/adr/に ADR を作成するよう促す - レビューで新しいパターンが承認された場合 →
_project_specs/session/decisions.mdに記録する - レビューで ADR との乖離が見つかった場合 → ADR の更新または置き換えを指摘する
### Auto-Log Entry (decisions.md)
- [YYYY-MM-DD] **[Review Finding]**: Brief description
- Source: Code review of [PR/commit]
- ADR: Created/Updated ADR-NNNN
- Impact: What changed
TDD ワークフローとの統合
┌─────────────────────────────────────────────────────────────────┐
│ TDD + CODE REVIEW WORKFLOW │
│ ───────────────────────────────────────────────────────────── │
│ │
│ 1. RED: Write failing tests │
│ 2. GREEN: Write code to pass tests │
│ 3. REFACTOR: Clean up code │
│ 4. REVIEW: Run /code-review ← NEW STEP │
│ 5. FIX: Address critical/high issues │
│ 6. VALIDATE: Lint + TypeCheck + Coverage │
│ 7. COMMIT: Only after review passes │
│ │
│ Review catches what tests miss: │
│ - Security vulnerabilities │
│ - Performance issues │
│ - Architecture problems │
│ - Code maintainability │
└─────────────────────────────────────────────────────────────────┘
レビューへの対応テンプレート
コードレビューで問題が見つかった場合は、次のように対応します。
## Code Review Results
### 🔴 Critical Issues (Must Fix)
1. **SQL Injection in userController.ts:45**
- Issue: User input directly interpolated into query
- Fix: Use parameterized query
- Code: `db.query('SELECT * FROM users WHERE id = $1', [userId])`
### 🟠 High Issues (Should Fix)
1. **Missing authentication on /api/admin endpoints**
- Issue: Admin routes accessible without auth
- Fix: Add auth middleware
### 🟡 Medium Issues (Fix Soon)
1. **N+1 query in getOrders function**
- Consider eager loading or batch query
### 🟢 Low Issues (Nice to Have)
1. **Consider extracting validation logic to separate file**
### ✅ Strengths
- Good test coverage
- Clear function names
- Proper error handling
### 📊 Summary
- Critical: 1 | High: 1 | Medium: 1 | Low: 1
- **Status: ❌ BLOCKED** - Fix critical/high issues before commit
Claude への指示
コードレビューを実施するタイミング
Claude はコードレビューを自動的に提案または実行します。
- 機能の実装完了後 → 「コミット前にコードレビューを実行します」
- PR の作成前 → 「すべての変更に対してコードレビューを実行します」
- ユーザーが「commit」と言ったとき → 「まず変更をレビューします」
- バグの修正後 → 「問題がないか修正内容をレビューします」
レビューの重点領域
変更の種類に基づいて、レビューの優先度を決めます。
| 変更の種類 | 重点領域 |
|---|---|
| 認証/セキュリティコード | セキュリティ、入力検証、暗号化 |
| データベースコード | SQL インジェクション、N+1、トランザクション |
| API エンドポイント | 認証、レート制限、検証 |
| フロントエンドコード | XSS、状態管理、パフォーマンス |
| インフラストラクチャ | シークレット、権限、ロギング |
クイックリファレンス
コマンド
# Basic review
/code-review
# Review specific files
/code-review src/auth.ts src/users.ts
# Review with focus
/code-review --focus security
# Review PR
/code-review --pr 123
重要度別の対応
🔴 Critical → STOP. Fix now. No commit.
🟠 High → STOP. Fix now. No commit.
🟡 Medium → Note it. Fix soon. Can commit.
🟢 Low → Optional. Nice to have.
ℹ️ Info → FYI only.
ワークフロー
Code → Test → Review → Fix → Commit → Push → PR → Review → Merge → Deploy
↑ ↑ ↑
/code-review /code-review /code-review