Director Mode フレームワーク:監督のように Claude Code をマスターする
コマンドを打つのを止め、成果を指揮しましょう。AI 開発の方法を根本から変える思考の転換を学びます—マイクロマネジメントから並列エージェントによる戦略的な統率へ。
多くの開発者は Claude Code を高機能なオートコンプリートのように使っています—指示を一つずつ入力し、応答を待ち、すべてのステップを手動で調整しています。これは オペレーターモード (Operator Mode) です。
より良い方法があります。Director Mode は Claude Code を専門部門を持つプロダクションチームとして扱います。あなたは望む成果を定義し、意図を設定し、システムを自律的に動かします—すべての作業を自分でやらずに優れた作品を創り出す監督のように。
このガイドでは、Claude Code の公式機能に基づいた完全な Director Mode フレームワークを解説します。
核心となる哲学
“監督はすべての作業を自分でやらない—チームが共に素晴らしい成果を出す条件を作り出す。”
Director Mode は3つの柱で構成されています:
- 指示よりも意図 - 達成方法ではなく、望む成果を定義する
- 並列エージェント委任 - 同時に動作する専門エージェントを信頼する
- 成果検証 - すべてのステップではなく、結果を検証する
Claude Code のエージェントアーキテクチャを理解する
Director Mode を実装する前に、Claude Code が実際に提供するものを理解しましょう。
Task Tool とサブエージェント
Claude Code の最も強力な機能は Task tool で、専門のサブエージェントを生成します。公式ドキュメント によると:
// Official Task tool syntax
Task({
subagent_type: "Explore", // or "general-purpose"
model: "haiku", // haiku, sonnet, or opus
prompt: `
Explore authentication module (thoroughness: medium).
Find all JWT-related functions and their usage.
`
})
利用可能な subagent_type の値:
| タイプ | 目的 | 最適なモデル |
|---|---|---|
Explore | 高速なコードベースナビゲーションと検索 | Haiku 4.5 |
general-purpose | 複雑な複数ステップのタスク | Sonnet 4.5 |
モデル選択戦略
Claude Code CHANGELOG によると、タスクの複雑さに基づいてモデルを選択します:
**Haiku 4.5** (v2.0.17+)
- 2x faster than Sonnet, 1/3 the cost
- Near-frontier performance with Extended Thinking support
- Ideal for: Explore agents, file searches, pattern matching
**Sonnet 4.5** (default)
- Balanced coding performance
- Extended Thinking support
- Ideal for: Implementation, code review, refactoring
**Opus 4.5** (v2.0.51+)
- Highest intelligence
- Default Thinking Mode enabled (v2.0.67+)
- Use `effort: "high"` for detailed analysis
- Ideal for: Architecture decisions, security audits, complex reasoning
クイックモデル切り替え (v2.0.65+): プロンプト入力中に Option+P(macOS)または Alt+P(Windows/Linux)を押します。
問題:オペレーターモード
典型的な開発者が Claude Code を使う様子を見てみましょう:
User: "Please read the file src/auth.ts"
Claude: [reads file]
User: "Now find the validateToken function"
Claude: [shows function]
User: "Add input validation for the token parameter"
Claude: [makes change]
User: "Now run the tests"
Claude: [runs tests]
これは オペレーターモード です—すべてのアクションをマイクロマネジメントしています。そのコスト:
- シンプルなタスクに 5回以上のやり取り
- 思考とプロンプト間の コンテキストスイッチ
- 並列実行なし—すべてが順次処理
- すべてのステップを覚えておく 認知的負荷
解決策:Director Mode
同じタスクを Director Mode で行うと:
User: "Implement input validation for token handling in our
auth module. Follow our security guidelines and ensure
test coverage."
Claude: [autonomously]
→ Explores codebase structure
→ Identifies all token-related functions
→ Analyzes existing validation patterns
→ Implements validation following project conventions
→ Writes comprehensive tests
→ Validates against security requirements
1つのプロンプト。同じ結果。5倍速い。
3つの柱を実践する
第1の柱:指示よりも意図
オペレーターのアプローチ:
"Read src/api/users.ts, find the createUser function,
add try-catch around the database call, log any errors
using console.error with the prefix '[UserAPI]', then
return a 500 status code."
Director のアプローチ:
"Add proper error handling to the user creation endpoint
following our API error standards."
プロジェクトのエラーハンドリング標準を CLAUDE.md で確立していれば、Claude は以下を把握しています:
- どのロガーを使用するか
- どのエラーフォーマットに従うか
- レスポンスをどう構造化するか
- エラーメッセージに何を含めるか
第2の柱:並列エージェント委任
Claude Code 2.0+ は 並列エージェント実行 をサポートしています。これがゲームチェンジャーです。
タスクを順次実行する代わりに:
Task 1 (30s) → Task 2 (30s) → Task 3 (30s) = 90 seconds total
並列で実行します:
Task 1 (30s) ┐
Task 2 (30s) ├→ 30 seconds total
Task 3 (30s) ┘
実例—コードベースの分析:
"I need to understand how authentication works in this project."
Claude spawns 5 parallel agents:
→ Agent 1 (Explore): Maps auth-related file structure
→ Agent 2 (Grep): Finds all JWT/token references
→ Agent 3 (Read): Analyzes middleware patterns
→ Agent 4 (Grep): Identifies security guidelines
→ Agent 5 (Read): Reviews existing tests
Results synthesized in ~30 seconds instead of 3+ minutes.
第3の柱:プロジェクトブループリント
あなたの CLAUDE.md ファイルはプロジェクトのブループリント(設計図)です。すべての開発を導く指針となる原則を定義します。
# CLAUDE.md - Project Blueprint
## Core Guidelines
- All code changes require corresponding tests
- Use TypeScript strict mode—no `any` types
- Follow the repository's existing patterns
- Security-first: validate all inputs at boundaries
## Autonomous Operations (No confirmation needed)
- Read any project file
- Run tests and linting
- Create/modify files in src/ and tests/
- Create local git branches
## Requires Confirmation
- Push to remote
- Modify environment variables
- Delete files
- Install production dependencies
## Agent Delegation Rules
When encountering these situations:
- Code quality questions → invoke code-reviewer agent
- Security-sensitive code → invoke security-auditor agent
- Performance concerns → run benchmarks before committing
Explore Agent 詳解
Explore agent(v2.1.0 で導入)は、Haiku 4.5 を搭載した最も効率的なコードベースナビゲーションツールです。
徹底度レベル
// Quick - 10-30 seconds (basic search)
Task({
subagent_type: "Explore",
model: "haiku",
prompt: "Explore auth module (thoroughness: quick). Find login handler."
})
// Medium - 30-60 seconds (recommended for most tasks)
Task({
subagent_type: "Explore",
model: "haiku",
prompt: "Explore auth module (thoroughness: medium). Map JWT flow."
})
// Very Thorough - 60-120 seconds (comprehensive analysis)
Task({
subagent_type: "Explore",
model: "haiku",
prompt: "Explore auth module (thoroughness: very thorough). Full security audit."
})
旧方式 vs 新方式
旧方式(5つの手動ステップ):
Agent 1: Glob find *auth*.ts
Agent 2: Grep search "JWT"
Agent 3: Read auth/index.ts
Agent 4: Grep find authenticate() usage
Agent 5: Read test files
新方式(1つの Explore agent):
Task({
subagent_type: "Explore",
model: "haiku",
prompt: `
Explore authentication implementation (thoroughness: medium).
Focus on JWT handling, middleware, and test coverage.
`
})
結果: 同じ情報、5倍速い、コンテキスト使用量が少ない。
組み込みエージェントタイプ
Claude Code は様々なタスク用の専門エージェントを提供します:
| エージェント | 役割 | 最適な用途 |
|---|---|---|
code-reviewer | コード品質分析 | 実装後 |
security-auditor | 脆弱性検出 | 認証/決済の変更 |
test-runner | テスト実行と分析 | コード変更後 |
debugger | 根本原因分析 | エラー発生時 |
refactor-assistant | コード改善 | 複雑さの軽減 |
doc-writer | ドキュメント作成 | API 変更時 |
委任の例:
"Implement the payment integration.
Delegation:
→ security-auditor: Review before merge
→ code-reviewer: Check patterns and quality
→ test-runner: Ensure 80%+ coverage"
自動適用のための Hooks
Director Mode は hooks を使用してガイドラインを自動的に適用します。hooks ドキュメント より:
Stop Hook - 完了の検証
{
"Stop": [{
"matcher": "*",
"hooks": [{
"type": "prompt",
"prompt": "Check if code was modified. If Write/Edit was used, verify tests were run. If no tests ran, block and explain."
}]
}]
}
PreToolUse Hook - 危険な操作のブロック
{
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "prompt",
"prompt": "If command contains 'rm -rf', 'drop', or destructive operations, return 'ask' for user confirmation. Otherwise 'approve'."
}]
}]
}
利用可能な Hook イベント
| イベント | タイミング | ユースケース |
|---|---|---|
PreToolUse | ツール実行前 | 承認/拒否/修正 |
PostToolUse | ツール実行後 | 結果への対応 |
Stop | エージェントが停止を検討 | 完了の検証 |
SessionStart | セッション開始 | コンテキストの読み込み |
SubagentStop | サブエージェント停止 | タスク完了の確認 |
UserPromptSubmit | ユーザーがプロンプトを送信 | コンテキスト追加/検証 |
並列実行パターン
パターン1:分析スウォーム
"Analyze the authentication system.
Launch in parallel:
→ Agent 1 (Explore quick): Map file structure
→ Agent 2 (Explore medium): Find all auth middleware
→ Agent 3 (Grep): Search for JWT patterns
→ Agent 4 (Read): Review existing tests
→ Agent 5 (Grep): Find recent auth changes"
時間比較:
- 順次実行: 5 × 30s = 150 秒
- 並列実行: max(30s) = 30 秒
- 5倍速い
パターン2:分割統治
複数ファイルのリファクタリング用:
"Migrate from REST to GraphQL.
Parallel implementation:
→ Agent 1: Convert users endpoints
→ Agent 2: Convert products endpoints
→ Agent 3: Convert orders endpoints
→ Agent 4: Update shared types
→ Agent 5: Update tests"
パターン3:実装とレビュー
"Build user profile editing.
Phase 1 (parallel):
→ Implementation agent: Build the feature
→ Test agent: Write test cases
→ Doc agent: Draft documentation
Phase 2 (parallel):
→ security-auditor: Security review
→ code-reviewer: Quality check"
実装レベル
レベル1:基本的な Director Mode
指示を成果に変換:
| このように言う代わりに | こう言う |
|---|---|
| ”Add console.log statements to debug…" | "Debug why the user login fails" |
| "Create a new file called X and add…" | "Add a utility for date formatting" |
| "Run npm test and show me failures" | "Ensure all tests pass” |
レベル2:CLAUDE.md ブループリント
以下を網羅する包括的な CLAUDE.md を作成:
- プロジェクトコンテキスト - 技術スタック、構造、コマンド
- 開発標準 - コードスタイル、テスト、ドキュメント
- ワークフローガイドライン - 確認が必要なもの、自律的な操作
- エージェント委任 - どのタスクにどのエージェントを使うか
レベル3:並列エージェントオーケストレーション
"Analyze and refactor the authentication module.
Phase 1 - Analysis (parallel):
→ 3 Explore agents: Map structure, find patterns, check tests
Phase 2 - Implementation (parallel):
→ Multiple agents: One per file
Phase 3 - Review (parallel):
→ code-reviewer + security-auditor + test-runner"
レベル4:完全自律モード
"Implement feature X end-to-end.
Constraints:
- Follow existing patterns
- 80%+ test coverage
- No breaking changes
- Security review required
Freedom to:
- Choose implementation approach
- Structure code as appropriate
- Design tests
Verify before completing:
- All tests pass
- No TypeScript errors
- Documentation updated"
実践例
バグ調査
"Users report 'undefined is not a function' on dashboard.
Investigate in parallel:
→ Explore: Search for error patterns
→ Grep: Find recent dashboard changes
→ Read: Check related components
Then:
- Fix root cause
- Add regression test
- Verify no other occurrences"
機能開発
"Add dark mode to the application.
Constraints:
- Use CSS variables
- Persist preference
- Default to system preference
Delegation:
→ Explore agents: Find all color usage
→ Implementation: Add theme system
→ test-runner: Visual regression tests"
コードレビュー
"Review PR #123 comprehensively.
Parallel review:
→ code-reviewer: Quality and patterns
→ security-auditor: Vulnerabilities
→ test-runner: Coverage analysis
→ Explore agent: Impact assessment
Output: Categorized findings with severity"
マインドセットの転換
| オペレーターマインドセット | Director マインドセット |
|---|---|
| Claude に正確に何をするか指示する | Claude に必要な成果を伝える |
| すべてのステップを分解する | 制約を定義し、Claude に計画させる |
| 各応答を待つ | エージェントを並列で動かす |
| すべてのアクションを確認する | 信頼し、最終結果を検証する |
| トレーニングのようにプロンプトする | 監督のように委任する |
成功の測定
効率性メトリクス
| メトリクス | オペレーターモード | Director Mode |
|---|---|---|
| 機能あたりのプロンプト数 | 15-20 | 3-5 |
| コンテキストスイッチ | 高 | 低 |
| 完了までの時間 | ベースライン | 40-60% 高速 |
| 一貫性 | 変動あり | 高 |
品質指標
Director Mode が機能している場合:
- Claude が最初の試行であなたのスタイルに合ったコードを生成する
- 同じミスを二度修正することがほとんどない
- 並列エージェントがタスクを5倍速く完了する
- レビューが自動的に行われる
今日から始める
1日目: 現在のプロンプトパターンに気づく。ステップバイステップの指示を出していませんか?
1週目:
- 3つのプロンプトを指示から成果に変換する
- 基本的なガイドラインを含む CLAUDE.md を作成する
- 1つの並列 Explore スウォームを試す
1ヶ月目:
- すべてのセクションを含む CLAUDE.md を完成させる
- 自動検証用の hooks を設定する
- すべての適切なタスクで並列エージェントを使用する
- 効率性の改善を測定する
クイックリファレンス
Director Mode プロンプトテンプレート
"[Outcome description]
Constraints:
- [Must-have requirements]
Freedom to:
- [Decisions Claude can make]
Delegation:
- [Which agents should review]
Verify:
- [Completion criteria]"
モデル選択
Explore/Search → haiku (fast, cheap)
Implementation → sonnet (balanced)
Security/Architecture → opus (thorough)
並列実行ルール
Independent tasks → Launch simultaneously
Dependent tasks → Run sequentially
Mixed → Phase approach
Claude Code のワークフローを変革する準備はできましたか?オペレーターから Director への移行は、単なる効率性の問題ではありません—操作のレベルではなく、成果のレベルで働くことなのです。
出典: Claude Code Documentation, Claude Code GitHub, CHANGELOG