Claude Code の Extended Thinking:より深い推論を引き出す
Claude Code の Extended Thinking をマスターしましょう。Thinking Mode を有効にするタイミング、Effort レベルの使い方、複雑な開発タスクのための深い推論の活用方法を解説します。
Extended Thinking(別名「Thinking Mode」)は、Claude が応答する前に複雑な問題をじっくり考える時間を与えます。開発者がコードを書く前にアーキテクチャを検討する時間を取るようなものです。
このガイドでは、Extended Thinking を使用するタイミング、設定方法、そして最大限の効果を発揮するためのパターンを解説します。
Extended Thinking とは?
Extended Thinking により、Claude は以下のことが可能になります:
- 応答前により長く熟考する
- 問題に対する複数のアプローチを検討する
- エッジケースを体系的に推論する
- 複数ステップの実装を徹底的に計画する
┌─────────────────────────────────────────────────────────────┐
│ Normal vs Extended Thinking │
│ │
│ Normal: │
│ ┌────────┐ ┌────────┐ │
│ │ Prompt │ ──► │Response│ │
│ └────────┘ └────────┘ │
│ │
│ Extended Thinking: │
│ ┌────────┐ ┌─────────────────┐ ┌────────┐ │
│ │ Prompt │ ► │ Internal Reason │ ► │Response│ │
│ └────────┘ │ (not visible) │ └────────┘ │
│ └─────────────────┘ │
│ ▲ │
│ │ │
│ Longer, deeper │
│ deliberation │
└─────────────────────────────────────────────────────────────┘
モデルのサポート状況
| モデル | Extended Thinking | デフォルト | 備考 |
|---|---|---|---|
| Opus 4.5 | 対応 | ON(v2.0.67以降) | 最高品質の推論 |
| Sonnet 4.5 | 対応 | OFF | 複雑なタスクで有効化 |
| Haiku 4.5 | 対応 | OFF | Thinking 対応の初の Haiku |
重要なポイント: Opus 4.5 は v2.0.67 以降、デフォルトで Thinking が有効になっています。これは品質が大幅に向上するためです。
Extended Thinking の有効化
Config 経由
/config で Thinking Mode を有効にします:
Thinking Mode: ON
Settings 経由
.claude/settings.json で設定:
{
"model": "opus",
"thinking": true
}
セッション単位
セッション中に切り替え:
"Enable thinking mode for this complex architecture discussion."
クイックモデル切り替え
Option+P(macOS)または Alt+P(Windows/Linux)を押すと、プロンプト入力中にモデルを素早く切り替えられます。
Effort レベル(Opus 4.5 のみ)
Opus 4.5 は Thinking の深さを制御する Effort レベルに対応しています:
| Effort | Thinking 時間 | ユースケース |
|---|---|---|
low | 最小限 | 簡単なタスク、バッチ処理 |
medium | バランス型 | デフォルト、ほとんどのタスク |
high | 最大 | 複雑な分析、アーキテクチャ |
Effort の設定
プロンプト内で指定:
"Analyze this authentication system with high effort.
I need thorough security analysis."
Task tool での指定:
Task({
subagent_type: "general-purpose",
model: "opus",
prompt: `
Effort: high
Analyze the payment integration architecture.
Consider all edge cases and failure modes.
`
})
Extended Thinking を使用するタイミング
アーキテクチャの意思決定
Thinking なし:
"How should we structure our microservices?"
Claude: [Quick response, may miss considerations]
Thinking あり:
"Enable high-effort thinking.
How should we structure our microservices?
Consider: scalability, team structure, data ownership,
deployment complexity, and failure isolation."
Claude: [Thorough analysis of trade-offs]
セキュリティレビュー
"Using Opus with high effort, review the authentication
implementation for vulnerabilities.
Consider: OWASP Top 10, JWT best practices, session
management, rate limiting, and common attack vectors."
複雑なリファクタリング
"Think through how to refactor the legacy payment system
to the new architecture. Consider:
- Backward compatibility
- Database migrations
- API versioning
- Rollback strategy
- Testing approach"
複雑な問題のデバッグ
"This bug only happens in production with high concurrency.
Use extended thinking to analyze potential causes.
Symptoms: [describe symptoms]
Environment: [describe environment]
Recent changes: [describe changes]"
Extended Thinking パターン
パターン 1:アーキテクチャレビュー
"I need to design a new feature. Use extended thinking.
Feature: Real-time notifications
Requirements:
- Support 100K concurrent users
- < 100ms delivery latency
- Support mobile and web
- Handle offline users
Analyze options and recommend architecture."
パターン 2:トレードオフ分析
"Think deeply about this trade-off.
Option A: Monolith with modular structure
Option B: Microservices from start
Context:
- 3-person team
- MVP stage
- Unknown scale requirements
- Limited DevOps experience
Analyze both options with pros, cons, and recommendation."
パターン 3:セキュリティ監査
"Perform a deep security audit with high effort.
Focus areas:
- Authentication and authorization
- Input validation
- Data encryption
- API security
- Dependency vulnerabilities
For each issue found, provide:
- Severity (Critical/High/Medium/Low)
- Description
- Remediation steps
- Code examples"
パターン 4:パフォーマンス調査
"The API is slow under load. Think through potential causes.
Observations:
- Response time increases from 50ms to 2s at 500 RPS
- CPU stays at 30%, memory at 60%
- Database connections spike
- No errors in logs
Analyze potential bottlenecks and suggest investigation steps."
Context への影響
重要: Extended Thinking は Prompt Caching の効率に影響します。
┌─────────────────────────────────────────────────────────────┐
│ Context Usage Comparison │
│ │
│ Normal Mode: │
│ ├── Prompt Cache: Highly effective │
│ ├── Context usage: Predictable │
│ └── Token efficiency: High │
│ │
│ Extended Thinking: │
│ ├── Prompt Cache: Less effective │
│ ├── Context usage: Variable (thinking uses tokens) │
│ └── Token efficiency: Lower (but higher quality) │
│ │
└─────────────────────────────────────────────────────────────┘
推奨事項: Extended Thinking は、日常的なタスクではなく、価値の高い意思決定に選択的に使用してください。
モデル選択ガイド
Haiku 4.5 を使用する場合(Thinking なし)
最適な用途:
- ファイル検索(Explore agent)
- パターンマッチング(Grep)
- シンプルなコード生成
- 一括操作
例:
"Find all uses of deprecated API in the codebase"
Sonnet 4.5 を使用する場合(Thinking は任意)
最適な用途(Thinking なし):
- 標準的な実装
- コードリファクタリング
- テスト作成
- ドキュメント作成
最適な用途(Thinking あり):
- 複雑な実装
- 複数ファイルのリファクタリング
- アーキテクチャに関わる変更
例:
"Implement the user authentication system following
our security patterns. Enable thinking for the token
refresh mechanism design."
Opus 4.5 を使用する場合(Thinking はデフォルト)
最適な用途:
- アーキテクチャの意思決定
- セキュリティ監査
- 複雑なデバッグ
- クリティカルなコードパス
例:
"Review the payment processing implementation.
Use high effort for the transaction handling logic."
Agent での Thinking Mode
Explore Agent(Haiku)
Explore Agent は速度のために Thinking なしで Haiku を使用します:
Task({
subagent_type: "Explore",
model: "haiku",
prompt: "Find authentication patterns (thoroughness: medium)"
})
Thinking 不要 - 純粋な検索と発見のため。
Implementation Agent(Sonnet + Thinking)
複雑な実装には Thinking を有効化:
Task({
subagent_type: "general-purpose",
model: "sonnet",
prompt: `
Enable thinking mode.
Implement OAuth 2.0 with PKCE flow.
Consider:
- State management
- Token storage
- Refresh handling
- Error recovery
`
})
Review Agent(Opus + High Effort)
重要なレビューには Opus と High Effort を使用:
Task({
subagent_type: "general-purpose",
model: "opus",
prompt: `
Effort: high
Security review the payment integration.
Check for:
- PCI compliance issues
- Data exposure risks
- Authentication bypasses
- Rate limiting gaps
`
})
実践的な例
例 1:機能設計
"I need to add collaborative editing to our document app.
Enable extended thinking with high effort.
Constraints:
- Real-time sync (< 100ms)
- Handle offline mode
- Conflict resolution
- Undo/redo support
Analyze:
1. Technology options (CRDT, OT, etc.)
2. Architecture approach
3. Trade-offs of each option
4. Recommended path forward"
例 2:移行計画
"We're migrating from MongoDB to PostgreSQL.
Use Opus with high effort to create a migration plan.
Current state:
- 50 collections
- 10M documents
- 5 services depending on data
- Zero downtime requirement
Deliverables:
1. Migration strategy
2. Schema design
3. Service update plan
4. Rollback strategy
5. Testing approach
6. Timeline estimate"
例 3:デバッグセッション
"Production issue: Intermittent 500 errors on /api/checkout.
Think through this carefully.
Data points:
- Happens ~1% of requests
- No pattern in time of day
- No correlation with request size
- Started after last deploy
- Logs show: 'Connection reset by peer'
Analyze potential causes and investigation steps."
例 4:コードレビュー
"Review this PR with extended thinking.
PR adds: Payment processing with Stripe
Focus areas:
- Error handling completeness
- Idempotency of operations
- State machine correctness
- Webhook handling security
- Test coverage adequacy
Provide detailed feedback with specific line references."
Thinking Mode の設定
プロジェクトレベル
.claude/settings.json で設定:
{
"model": "sonnet",
"thinking": false,
"thinkingConfig": {
"enableForSecurity": true,
"enableForArchitecture": true,
"defaultEffort": "medium"
}
}
タスクごとのトリガー
Thinking の自動有効化を設定:
{
"thinkingTriggers": {
"keywords": ["security", "architecture", "design"],
"paths": ["auth/", "payment/", "admin/"],
"operations": ["create-file", "refactor"]
}
}
コスト対効果の分析
Extended Thinking が効果的な場合
| シナリオ | 時間コスト | 品質向上 | ROI |
|---|---|---|---|
| アーキテクチャの意思決定 | +30秒 | 数ヶ月の手戻りを回避 | 非常に高い |
| セキュリティレビュー | +45秒 | 脆弱性の発見 | 非常に高い |
| 複雑なリファクタリング | +20秒 | より良い設計 | 高い |
| バグ調査 | +15秒 | より迅速な原因特定 | 高い |
| 日常的なコーディング | +10秒 | わずかな改善 | 低い |
スキップすべき場合
- ファイル検索
- パターンマッチング
- シンプルなコード変更
- ドキュメントの更新
- 定型的なテスト
ベストプラクティス
1. Thinking について明示的に指定する
"Enable extended thinking for this security analysis."
以下のようにしない:
"Analyze this code."
2. 豊富なコンテキストを提供する
Extended Thinking はコンテキストがあるとより効果的に機能します:
"Using high-effort thinking, design the caching layer.
Context:
- Current: No caching, 200ms average response
- Goal: <50ms for 80% of requests
- Constraints: Redis available, 5GB memory budget
- Traffic: 10K RPM, 80% reads
Consider cache invalidation, TTL strategies, and
cache stampede prevention."
3. 構造化された出力を要求する
"Think through this architecture decision.
Output format:
1. Options considered (3-5)
2. Evaluation criteria
3. Analysis matrix
4. Recommendation with rationale
5. Risk assessment"
4. Agent と組み合わせる
オーケストレーションには Thinking を使用し、実行には速度を優先:
"Phase 1 (Opus, high effort): Design the migration strategy
Phase 2 (Sonnet, no thinking): Implement each migration step
Phase 3 (Haiku, no thinking): Run tests in parallel"
Thinking 使用状況のモニタリング
Context 使用量の確認
ステータスライン(v2.0.65以降)で Context 使用量を確認できます:
Context: 45% used | Thinking: enabled | Model: opus
セッションに応じた調整
長いセッションでは、Context を節約するために定型的なタスクでは Thinking を無効にすることを検討してください:
"Disable thinking for these routine file updates."
始め方
今日:
- 1 つのアーキテクチャ決定で Thinking を有効にする
- Thinking ありとなしで出力品質を比較する
- 時間差を記録する
今週:
- プロジェクトに適したモデル選択を設定する
- Thinking が有効なタスクを特定する
- 深い推論を活用するプロンプトを作成する
今月:
- チーム向けの Thinking Mode ガイドラインを確立する
- 自動有効化トリガーを設定する
- 意思決定品質への影響を測定する
Extended Thinking は Claude を高速な応答者から思慮深いパートナーへと変えます。重要な意思決定に戦略的に使用すれば、アーキテクチャ決定の質が劇的に向上するのを実感できるでしょう。