review について
reviewは、ステージ済みの変更、指定ファイル、プルリクエストを調べるコードレビュースキルです。ファイル種別に応じてレビューを振り分け、重要度別に指摘を整理し、重大な問題にはタスクを作成できます。
主な機能
- 01ステージ済み、未コミット、指定変更のレビュー
- 02GitHub CLIによるPR差分の取得
- 03ファイル種別に応じたレビュー振り分け
- 04セキュリティや性能などの重点確認
- 05クイック、通常、詳細なレビュー深度
- 06重大な指摘に対するタスク作成
活用シーン
- 01コミット前のステージ済み変更の確認
- 02ファイルやブランチ差分の調査
- 03GitHubプルリクエストのレビュー
- 04CI/CD向けJSON結果の出力
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ 0xdarkmatter/ claude-mods --skill reviewインストール後、Claude Code で/reviewを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
framework-checks.mdassets/.gitkeepreferences/.gitkeepscripts/.gitkeep詳細
レビュースキル - AI コードレビュー
ステージ済みの変更、特定のファイル、またはプルリクエストを対象に、包括的なコードレビューを実施します。ファイルの種類に応じて関連する -ops スキルを事前に読み込む汎用レビュー担当者に処理を割り当て、重大な問題についてはタスクを自動作成します。
アーキテクチャ
review [target] [--focus] [--depth]
│
├─→ Step 1: Determine Scope
│ ├─ No args → git diff --cached (staged)
│ ├─ --all → git diff HEAD (all uncommitted)
│ ├─ File path → specific file diff
│ └─ --pr N → gh pr diff N
│
├─→ Step 2: Analyze Changes (parallel)
│ ├─ delta for syntax-highlighted diff
│ ├─ difft for semantic diff (structural)
│ ├─ Categorize: logic, style, test, docs, config
│ └─ Identify touched modules/components
│
├─→ Step 3: Load Project Standards
│ ├─ AGENTS.md, CLAUDE.md conventions
│ ├─ .eslintrc, .prettierrc, pyproject.toml
│ ├─ Detect test framework
│ └─ Check CI config for existing linting
│
├─→ Step 4: Route to Reviewers (general-purpose + skill preload)
│ ├─ TypeScript → general-purpose, preload typescript-ops
│ ├─ React/JSX → general-purpose, preload react-ops
│ ├─ Python → general-purpose, preload python-pytest-ops
│ ├─ Go → general-purpose, preload go-ops
│ ├─ Rust → general-purpose, preload rust-ops
│ ├─ Vue → general-purpose, preload vue-ops
│ ├─ SQL/migrations → general-purpose, preload postgres-ops
│ ├─ Cypress/E2E → general-purpose, preload cypress-ops
│ ├─ Cloudflare/Workers → general-purpose, preload cloudflare-ops
│ ├─ Shell/bash → general-purpose, preload bash-ops
│ ├─ Claude extensions → general-purpose, preload claude-code-ops
│ ├─ Multi-domain → parallel general-purpose dispatch
│ └─ All reviewers preload: security-ops + testing-ops context
│
├─→ Step 5: Generate Review
│ ├─ Severity: CRITICAL / WARNING / SUGGESTION / PRAISE
│ ├─ Line-specific comments (file:line refs)
│ ├─ Suggested fixes as diff blocks
│ └─ Overall verdict: Ready to commit? Y/N
│
└─→ Step 6: Integration
├─ Auto-create tasks (TaskCreate) for CRITICAL issues
├─ Link to /save for tracking
└─ Suggest follow-up: /testgen, /explain
実行手順
ステップ 1:対象範囲の特定
# Default: staged changes
git diff --cached --name-only
# Check if anything is staged
STAGED=$(git diff --cached --name-only | wc -l)
if [ "$STAGED" -eq 0 ]; then
echo "No staged changes. Use --all for uncommitted or specify a file."
git status --short
fi
PR のレビューの場合:
gh pr diff $PR_NUMBER --patch
特定のファイルの場合:
git diff HEAD -- "$FILE"
ベースラインとの比較(--base)の場合:
git diff $BASE_BRANCH...HEAD
ステップ 2:変更の分析
セマンティックな差分分析を実行します(可能な場合は並列で実行します)。
difft を使用する場合(セマンティック):
command -v difft >/dev/null 2>&1 && git difftool --tool=difftastic --no-prompt HEAD~1 || git diff HEAD~1
delta を使用する場合(構文の強調表示):
command -v delta >/dev/null 2>&1 && git diff --cached | delta || git diff --cached
変更を分類する:
git diff --cached --name-only | while read file; do
case "$file" in
*.test.* | *.spec.*) echo "TEST: $file" ;;
*.md | docs/*) echo "DOCS: $file" ;;
*.json | *.yaml | *.toml) echo "CONFIG: $file" ;;
*) echo "CODE: $file" ;;
esac
done
差分の統計情報を取得する:
git diff --cached --stat
ステップ 3:プロジェクトの規約を読み込む
# Claude Code conventions
cat AGENTS.md 2>/dev/null | head -50
cat CLAUDE.md 2>/dev/null | head -50
# Linting configs
cat .eslintrc* 2>/dev/null | head -30
cat .prettierrc* 2>/dev/null
cat pyproject.toml 2>/dev/null | head -30
# Test framework detection
cat package.json 2>/dev/null | jq '.devDependencies | keys | map(select(test("jest|vitest|mocha|cypress|playwright")))' 2>/dev/null
既存の lint 設定を CI で確認する:
cat .github/workflows/*.yml 2>/dev/null | grep -E "eslint|prettier|pylint|ruff" | head -10
ステップ 4:レビュー担当者への割り当て
割り当てはスキル優先で行います。ドメイン知識は -ops スキルにあり、汎用の general-purpose サブエージェントはレビュー前に関連する SKILL.md を読み込みます。
| ファイルパターン | 割り当て先 | 事前読み込み |
|---|---|---|
*.ts | general-purpose | skills/typescript-ops/SKILL.md |
*.tsx | general-purpose | skills/react-ops/SKILL.md + skills/typescript-ops/SKILL.md |
*.vue | general-purpose | skills/vue-ops/SKILL.md + skills/typescript-ops/SKILL.md |
*.py | general-purpose | skills/python-pytest-ops/SKILL.md(ORM の場合は skills/sql-ops/SKILL.md も追加) |
*.go | general-purpose | skills/go-ops/SKILL.md |
*.rs | general-purpose | skills/rust-ops/SKILL.md |
*.sql, migrations/* | general-purpose | skills/postgres-ops/SKILL.md |
agents/*.md, skills/*, commands/* | general-purpose | skills/claude-code-ops/SKILL.md |
*.test.*, *.spec.* | general-purpose | (ファイルの種類に応じたフレームワークスキル) |
*.cy.ts, cypress/* | general-purpose | skills/cypress-ops/SKILL.md + skills/typescript-ops/SKILL.md |
*.spec.ts(Playwright) | general-purpose | skills/playwright-ops/SKILL.md + skills/typescript-ops/SKILL.md |
playwright/*, e2e/* | general-purpose | skills/playwright-ops/SKILL.md + skills/typescript-ops/SKILL.md |
wrangler.toml, workers/* | general-purpose | skills/cloudflare-ops/SKILL.md |
*.sh, *.bash | general-purpose | skills/bash-ops/SKILL.md |
Agent ツールから呼び出す:
Agent tool with subagent_type: "general-purpose" (or surviving specialist from table)
model: "sonnet"
Prompt includes:
- Skill preloading (domain knowledge):
"First, read these files for review context:
- Read: skills/security-ops/references/owasp-top10-a01-a05.md
- Read: skills/security-ops/references/owasp-top10-a06-a10.md
- Read: skills/testing-ops/SKILL.md
- Read: [Preload column for the matched file pattern]"
- Diff content
- Project conventions from AGENTS.md
- Linting config summaries
- Requested focus area
- Request for structured review output
言語固有の事前読み込み(上記の事前読み込みセクションに追加します):
| 言語 | 追加で読み込むスキル | 理由 |
|---|---|---|
| Python | skills/python-pytest-ops/SKILL.md | カバレッジレビューで確認する Python のテストパターン |
| Go | skills/go-ops/SKILL.md | Go の慣用表現、並行処理に関する注意点 |
| Rust | skills/rust-ops/SKILL.md | 所有権のパターン、unsafe のレビュー |
| TypeScript | skills/typescript-ops/SKILL.md | 型安全性のパターン |
ステップ 5:レビューの生成
レビュー担当者は、次の構成でレビューを作成します。
# Code Review: [scope description]
## Summary
| Metric | Value |
|--------|-------|
| Files reviewed | N |
| Lines changed | +X / -Y |
| Issues found | N (X critical, Y warnings) |
## Verdict
**Ready to commit?** Yes / No
[1-2 sentence summary of overall quality]
---
## Critical Issues
### `src/auth/login.ts:42`
**Issue:** SQL injection vulnerability in user input handling
**Risk:** Attacker can execute arbitrary SQL queries
**Fix:**
```diff
- const query = `SELECT * FROM users WHERE id = ${userId}`;
+ const query = `SELECT * FROM users WHERE id = $1`;
+ const result = await db.query(query, [userId]);
警告
src/components/Form.tsx:89
問題: useEffect の依存配列に依存関係が不足しています
提案: userId を依存配列に追加してください
- useEffect(() => { fetchUser(userId) }, []);
+ useEffect(() => { fetchUser(userId) }, [userId]);
提案
[スタイルの改善、任意の拡張]
良い点
[注目すべき優れたパターン]
レビューしたファイル
| ファイル | 変更 | 問題 |
|---|---|---|
src/auth/login.ts | +42/-8 | 重大な問題 1 件 |
### Step 6: Integration
**Auto-create tasks for CRITICAL issues:**
TaskCreate: subject: "Fix: SQL injection in login.ts:42" description: "SQL injection vulnerability found in user input handling." activeForm: "Fixing SQL injection in login.ts:42"
**Link with dependencies for related issues:**
TaskCreate: #1 "Fix SQL injection in login.ts" TaskCreate: #2 "Fix SQL injection in register.ts" TaskUpdate: taskId: "2", addBlockedBy: ["1"]
**After fixing issues:**
TaskUpdate: taskId: "1" status: "completed"
---
## Severity System
| Level | Icon | Meaning | Action | Auto-Task? |
|-------|------|---------|--------|------------|
| CRITICAL | :red_circle: | Security bug, data loss risk, crashes | Must fix before merge | Yes |
| WARNING | :yellow_circle: | Logic issues, performance problems | Should address | No |
| SUGGESTION | :blue_circle: | Style, minor improvements | Optional | No |
| PRAISE | :star: | Good patterns worth noting | Recognition | No |
---
## Focus Modes
| Mode | What It Checks |
|------|----------------|
| `--security` | OWASP top 10, secrets in code, injection, auth issues |
| `--perf` | N+1 queries, unnecessary re-renders, complexity, memory |
| `--types` | Type safety, `any` usage, generics, null handling |
| `--tests` | Coverage gaps, test quality, mocking patterns |
| `--style` | Naming, organization, dead code, comments |
| (default) | All of the above |
---
## Depth Modes
| Mode | Behavior |
|------|----------|
| `--quick` | Surface-level scan, obvious issues only |
| `--normal` | Standard review, all severity levels (default) |
| `--thorough` | Deep analysis, traces data flow, checks edge cases |
---
## Advanced Flags
### `--base <branch>` - Baseline Comparison
Compare changes against a specific branch instead of HEAD:
```bash
/review --base main
/review src/ --base develop --thorough
--json - CI/CD との統合
レビュー結果を JSON で出力します。
{
"summary": {
"files_reviewed": 3,
"lines_changed": { "added": 42, "removed": 8 },
"issues": { "critical": 1, "warning": 2, "suggestion": 1 }
},
"verdict": {
"ready_to_commit": false,
"reason": "1 critical issue requires attention"
},
"issues": [...]
}
CI/CD での使用方法:
- name: Code Review
run: |
claude "/review --json" > review.json
if jq -e '.issues[] | select(.severity == "critical")' review.json; then
exit 1
fi
--fix - 修正を自動適用
提案された修正を自動的に適用します:
- 標準レビューを実行します
- 修正可能な問題ごとに、確認を求めます
- 承認された修正を適用するために Edit ツールを使用します
- 解決済みの問題について TaskUpdate を作成します
非インタラクティブモード:
/review --fix --auto-approve
CLI ツールとの連携
| ツール | 用途 | フォールバック |
|---|---|---|
delta | 構文強調表示付きの差分 | git diff |
difft | 意味的/構造的な差分 | git diff |
gh | GitHub PR の操作 | 手動で差分を確認 |
rg | パターンの検索 | Grep ツール |
jq | JSON 設定の解析 | 手動で読み取り |
グレースフルデグラデーション:
command -v delta >/dev/null 2>&1 && git diff --cached | delta || git diff --cached
連携
| コマンド | 関係 |
|---|---|
/explain | 指摘されたコードを詳しく調査 |
/testgen | 見つかった問題に対するテストを生成 |
/save | レビュー結果をセッション状態に保存 |