claudify-agent 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/QUICK-REFERENCE.md +213 -213
- package/.claude/cost-dashboard.md +162 -162
- package/.claude/docs/COST-OPTIMIZATION.md +402 -403
- package/.claude/docs/MCP-INTEGRATION-GUIDE.md +348 -348
- package/.claude/docs/PLAN-MODE-OPTIMIZATION.md +835 -836
- package/.claude/hooks/auto-learning-review.ts +200 -195
- package/.claude/hooks/auto-lint-fix.ts +60 -104
- package/.claude/hooks/auto-security-review.ts +314 -354
- package/.claude/hooks/auto-validate.ts +249 -348
- package/.claude/hooks/lib/claude-hook.ts +168 -0
- package/.claude/hooks/plan-quality-tracker.ts +598 -719
- package/.claude/rules/anti-patterns.md +22 -22
- package/.claude/rules/context-tier-1.md +41 -41
- package/.claude/rules/context-tier-2.md +285 -285
- package/.claude/rules/general.md +25 -25
- package/.claude/rules/mcp-auto-use.md +46 -46
- package/.claude/rules/parallel-exploration-auto.md +30 -31
- package/.claude/rules/plan-mode-execution.md +289 -289
- package/.claude/rules/plan-mode-research.md +34 -34
- package/.claude/rules/plan-mode-structure.md +166 -166
- package/.claude/rules/plan-mode-validation.md +129 -130
- package/.claude/rules/security-critical.md +19 -19
- package/.claude/rules/tool-auto-selection.md +45 -45
- package/.claude/rules/tool-strategy.md +22 -22
- package/.claude/scripts/security-scan.js +1 -1
- package/.claude/security-dashboard.md +142 -142
- package/.claude/settings.json +50 -0
- package/.claude/skills/debug-optimizer/SKILL.md +420 -399
- package/.claude/skills/learning-loop/SKILL.md +313 -308
- package/.claude/skills/mcp-mastery/SKILL.md +218 -214
- package/.claude/skills/nextjs-guide/SKILL.md +687 -687
- package/.claude/skills/parallel-exploration/SKILL.md +197 -193
- package/.claude/skills/plan-mode-mastery/SKILL.md +268 -263
- package/.claude/skills/python-guide/SKILL.md +822 -822
- package/.claude/skills/react-guide/SKILL.md +762 -762
- package/.claude/skills/{security.md → security-guide/SKILL.md} +10 -0
- package/.claude/skills/solidity-guide/SKILL.md +5 -0
- package/.claude/skills/tool-selection/SKILL.md +433 -428
- package/.claude/skills/vite-guide/SKILL.md +445 -445
- package/CLAUDE.md +1 -0
- package/README.md +74 -35
- package/README.vi.md +106 -0
- package/bin/cli.js +13 -4
- package/package.json +9 -1
- package/.claude/skills/debug-optimizer.md +0 -12
- package/.claude/skills/nextjs.md +0 -13
- package/.claude/skills/react.md +0 -12
|
@@ -1,836 +1,835 @@
|
|
|
1
|
-
# Plan Mode Optimization Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This guide documents the comprehensive optimization of
|
|
6
|
-
|
|
7
|
-
**Status**: ✅ **Implemented**
|
|
8
|
-
**Files Created**: 10 files (4 rules, 2 skills, 3 hooks, 1 config)
|
|
9
|
-
**Impact**: 60-70% faster completion, 70-80% fewer revisions
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Problem Statement
|
|
14
|
-
|
|
15
|
-
### Current State (Before Optimization)
|
|
16
|
-
|
|
17
|
-
Plan Mode provides:
|
|
18
|
-
- Structured implementation plans
|
|
19
|
-
- File lists (create/modify)
|
|
20
|
-
- Implementation steps
|
|
21
|
-
- Testing strategy
|
|
22
|
-
- Time estimates
|
|
23
|
-
|
|
24
|
-
### Missing Automatic Optimizations
|
|
25
|
-
|
|
26
|
-
1. **Tool Selection Not Automated**
|
|
27
|
-
- No automatic
|
|
28
|
-
- No automatic subagent exploration
|
|
29
|
-
- No proactive
|
|
30
|
-
- Manual
|
|
31
|
-
|
|
32
|
-
2. **No Pre-Plan Research**
|
|
33
|
-
- Plans created without understanding existing patterns
|
|
34
|
-
- No automatic file relationship mapping
|
|
35
|
-
- No code health assessment
|
|
36
|
-
|
|
37
|
-
3. **No Validation**
|
|
38
|
-
- No feasibility checking before presentation
|
|
39
|
-
- No tool availability verification
|
|
40
|
-
- No dependency analysis
|
|
41
|
-
|
|
42
|
-
4. **No Learning Loop**
|
|
43
|
-
- No plan accuracy tracking
|
|
44
|
-
- No adaptation based on success/failure
|
|
45
|
-
- No pattern recognition
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## Solution: 4-Phase Automatic Workflow
|
|
50
|
-
|
|
51
|
-
```mermaid
|
|
52
|
-
flowchart TD
|
|
53
|
-
A[User Request] --> B[Phase 1: Pre-Plan Research]
|
|
54
|
-
B --> C[Phase 2: Plan Creation]
|
|
55
|
-
C --> D[Phase 3: Plan Validation]
|
|
56
|
-
D --> E[Phase 4: Execution Monitoring]
|
|
57
|
-
|
|
58
|
-
B --> B1[
|
|
59
|
-
B --> B2[
|
|
60
|
-
B --> B3[
|
|
61
|
-
|
|
62
|
-
C --> C1[CreatePlan Tool]
|
|
63
|
-
C --> C2[
|
|
64
|
-
|
|
65
|
-
D --> D1[Feasibility Check]
|
|
66
|
-
D --> D2[Tool Availability]
|
|
67
|
-
|
|
68
|
-
E --> E1[TodoWrite Tracking]
|
|
69
|
-
E --> E2[Adaptive Re-plan]
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## Implementation Files
|
|
75
|
-
|
|
76
|
-
### Rules (`.
|
|
77
|
-
|
|
78
|
-
#### 1. plan-mode-research.md
|
|
79
|
-
|
|
80
|
-
**Purpose**: Automatic pre-plan research workflow
|
|
81
|
-
|
|
82
|
-
**Key Features**:
|
|
83
|
-
-
|
|
84
|
-
- Parallel
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
|
|
88
|
-
**When Loaded**: Always in Plan Mode
|
|
89
|
-
|
|
90
|
-
**Example**:
|
|
91
|
-
```markdown
|
|
92
|
-
User: "Add user dashboard"
|
|
93
|
-
|
|
94
|
-
Agent automatically:
|
|
95
|
-
1.
|
|
96
|
-
2.
|
|
97
|
-
- "Find API route patterns"
|
|
98
|
-
- "Find component patterns"
|
|
99
|
-
3.
|
|
100
|
-
4.
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
#### 2. plan-mode-structure.md
|
|
106
|
-
|
|
107
|
-
**Purpose**: Enhanced plan structure with tool strategy
|
|
108
|
-
|
|
109
|
-
**Key Features**:
|
|
110
|
-
- Required plan sections (7 total)
|
|
111
|
-
- Tool-aware step definitions
|
|
112
|
-
- Risk mitigation strategies
|
|
113
|
-
- Quality gates
|
|
114
|
-
|
|
115
|
-
**Plan Structure**:
|
|
116
|
-
```markdown
|
|
117
|
-
## Summary (1-2 sentences)
|
|
118
|
-
|
|
119
|
-
## Files to Create/Modify
|
|
120
|
-
- path/to/file.ts - Purpose
|
|
121
|
-
- Pattern: Follow @[file]
|
|
122
|
-
- Tools: Use [tool] for [operation]
|
|
123
|
-
|
|
124
|
-
## Implementation Steps
|
|
125
|
-
1. [Step]
|
|
126
|
-
- Tool: [Specific tool]
|
|
127
|
-
- Success: [Verifiable metric]
|
|
128
|
-
|
|
129
|
-
## Tool Strategy
|
|
130
|
-
- Exploration: [Tools]
|
|
131
|
-
- Implementation: [Tools]
|
|
132
|
-
- Validation: [Tools]
|
|
133
|
-
|
|
134
|
-
## Risk Mitigation
|
|
135
|
-
- Fallback strategies
|
|
136
|
-
- Checkpoint locations
|
|
137
|
-
|
|
138
|
-
## Estimated Time (with 20% buffer)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
#### 3. plan-mode-validation.md
|
|
144
|
-
|
|
145
|
-
**Purpose**: Automatic plan feasibility validation
|
|
146
|
-
|
|
147
|
-
**Key Features**:
|
|
148
|
-
- Feasibility check via subagent
|
|
149
|
-
- Dependency analysis
|
|
150
|
-
- Risk assessment
|
|
151
|
-
- Tool availability verification
|
|
152
|
-
|
|
153
|
-
**Validation Checklist**:
|
|
154
|
-
- [ ] All files accessible
|
|
155
|
-
- [ ] No circular dependencies
|
|
156
|
-
- [ ] Time estimates realistic
|
|
157
|
-
- [ ] Tools available
|
|
158
|
-
- [ ] Step ordering correct
|
|
159
|
-
- [ ] Risks flagged
|
|
160
|
-
- [ ] Fallbacks defined
|
|
161
|
-
|
|
162
|
-
**Validation Subagent**:
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
description="Validate implementation plan"
|
|
166
|
-
prompt="Review this plan for feasibility:
|
|
167
|
-
1. Check file accessibility
|
|
168
|
-
2. Verify tool availability
|
|
169
|
-
3. Estimate time accuracy
|
|
170
|
-
4. Identify blockers
|
|
171
|
-
5. Suggest improvements
|
|
172
|
-
|
|
173
|
-
Return: Pass/Fail + issues"
|
|
174
|
-
subagent_type="
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
- `/plan-mode-
|
|
213
|
-
- `/plan-mode-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
├─
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
Tier
|
|
278
|
-
Tier
|
|
279
|
-
Tier
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- `
|
|
307
|
-
- `
|
|
308
|
-
- `
|
|
309
|
-
- `
|
|
310
|
-
- `
|
|
311
|
-
- `
|
|
312
|
-
- `
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
[Plan Tracker]
|
|
322
|
-
[Plan Tracker]
|
|
323
|
-
|
|
324
|
-
-
|
|
325
|
-
-
|
|
326
|
-
-
|
|
327
|
-
|
|
328
|
-
[Plan Tracker] MCP tools
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
"
|
|
359
|
-
"
|
|
360
|
-
}
|
|
361
|
-
]
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
**
|
|
367
|
-
-
|
|
368
|
-
-
|
|
369
|
-
-
|
|
370
|
-
-
|
|
371
|
-
-
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## Usage Examples
|
|
376
|
-
|
|
377
|
-
### Example 1: Simple Feature
|
|
378
|
-
|
|
379
|
-
**User**: "Add login button to header"
|
|
380
|
-
|
|
381
|
-
**Optimized Plan Mode Workflow**:
|
|
382
|
-
|
|
383
|
-
```
|
|
384
|
-
Phase 1: Research (1 min)
|
|
385
|
-
-
|
|
386
|
-
-
|
|
387
|
-
|
|
388
|
-
Phase 2: Plan (30 sec)
|
|
389
|
-
## Summary
|
|
390
|
-
Add login button following existing button patterns.
|
|
391
|
-
|
|
392
|
-
## Files to Modify
|
|
393
|
-
- components/Header.tsx
|
|
394
|
-
- Pattern: Follow @components/Button.tsx
|
|
395
|
-
- Tools:
|
|
396
|
-
|
|
397
|
-
## Steps
|
|
398
|
-
1. Find button patterns (
|
|
399
|
-
2. Add button (
|
|
400
|
-
3. Verify (
|
|
401
|
-
|
|
402
|
-
## Time: 10 minutes
|
|
403
|
-
|
|
404
|
-
Phase 3: Validation (30 sec)
|
|
405
|
-
-
|
|
406
|
-
- Result: PASS
|
|
407
|
-
|
|
408
|
-
Phase 4: Execution
|
|
409
|
-
✅ Step 1:
|
|
410
|
-
✅ Step 2:
|
|
411
|
-
✅ Step 3:
|
|
412
|
-
Complete in 8 minutes
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
### Example 2: Complex Feature
|
|
418
|
-
|
|
419
|
-
**User**: "Add user dashboard"
|
|
420
|
-
|
|
421
|
-
**Optimized Plan Mode Workflow**:
|
|
422
|
-
|
|
423
|
-
```
|
|
424
|
-
Phase 1: Research (3 min)
|
|
425
|
-
-
|
|
426
|
-
-
|
|
427
|
-
- "Find page patterns"
|
|
428
|
-
- "Find component patterns"
|
|
429
|
-
- "Find API patterns"
|
|
430
|
-
-
|
|
431
|
-
-
|
|
432
|
-
|
|
433
|
-
Phase 2: Plan (2 min)
|
|
434
|
-
## Summary
|
|
435
|
-
Create dashboard with stats, activity feed, settings.
|
|
436
|
-
|
|
437
|
-
## Files to Create
|
|
438
|
-
- app/dashboard/page.tsx (pattern: @app/profile/page.tsx)
|
|
439
|
-
- components/dashboard/StatsCard.tsx
|
|
440
|
-
- app/api/dashboard/stats/route.ts
|
|
441
|
-
|
|
442
|
-
## Tool Strategy
|
|
443
|
-
- Exploration:
|
|
444
|
-
- Implementation: Write,
|
|
445
|
-
- Validation:
|
|
446
|
-
|
|
447
|
-
## Risk Mitigation
|
|
448
|
-
- Checkpoint before API changes
|
|
449
|
-
- Fallback: Mock data if API delayed
|
|
450
|
-
|
|
451
|
-
## Time: 45 minutes
|
|
452
|
-
|
|
453
|
-
Phase 3: Validation (1 min)
|
|
454
|
-
-
|
|
455
|
-
- Warning: API dependency
|
|
456
|
-
- Result: PASS with caveats
|
|
457
|
-
|
|
458
|
-
Phase 4: Execution
|
|
459
|
-
✅ Research phase complete
|
|
460
|
-
✅ API endpoint created
|
|
461
|
-
📸 Checkpoint created
|
|
462
|
-
✅ Dashboard page created
|
|
463
|
-
✅ Components created
|
|
464
|
-
⚠️ Tests failing →
|
|
465
|
-
✅ Tests passing
|
|
466
|
-
Complete in 52 minutes
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
---
|
|
470
|
-
|
|
471
|
-
### Example 3: Complex Refactor
|
|
472
|
-
|
|
473
|
-
**User**: "Migrate authentication from JWT to sessions"
|
|
474
|
-
|
|
475
|
-
**Optimized Plan Mode Workflow**:
|
|
476
|
-
|
|
477
|
-
```
|
|
478
|
-
Phase 1: Research (3 min)
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
- "Find JWT validation"
|
|
482
|
-
- "Find session management"
|
|
483
|
-
- "Find OAuth integrations"
|
|
484
|
-
- "Find password hashing"
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
|
|
488
|
-
Phase 2: Plan (3 min)
|
|
489
|
-
## Summary
|
|
490
|
-
Migrate from JWT to sessions with zero downtime.
|
|
491
|
-
|
|
492
|
-
## Files to Modify (8 files)
|
|
493
|
-
- src/auth/validateToken.ts → sessions
|
|
494
|
-
- src/auth/middleware.ts → session middleware
|
|
495
|
-
- app/api/auth/login/route.ts → session creation
|
|
496
|
-
- ... (5 more files)
|
|
497
|
-
|
|
498
|
-
## Checkpoints (3)
|
|
499
|
-
1. Before database changes
|
|
500
|
-
2. Before middleware changes
|
|
501
|
-
3. Before removing JWT code
|
|
502
|
-
|
|
503
|
-
## Risk Mitigation
|
|
504
|
-
- Rollback plan: Keep JWT until tests pass
|
|
505
|
-
- Fallback: Hybrid auth during transition
|
|
506
|
-
- Monitoring: Auth failure rate tracking
|
|
507
|
-
|
|
508
|
-
## Time: 3 hours
|
|
509
|
-
|
|
510
|
-
Phase 3: Validation (1 min)
|
|
511
|
-
-
|
|
512
|
-
- Warning: High risk, breaking change
|
|
513
|
-
- Suggestion: Phased rollout
|
|
514
|
-
- Result: PASS with warnings
|
|
515
|
-
|
|
516
|
-
Phase 4: Execution
|
|
517
|
-
✅ Phase 1: Research complete
|
|
518
|
-
✅ Phase 2: Dependencies added
|
|
519
|
-
📸 Checkpoint 1 created
|
|
520
|
-
✅ Phase 3: Database migrated
|
|
521
|
-
📸 Checkpoint 2 created
|
|
522
|
-
✅ Phase 4: Middleware updated
|
|
523
|
-
⚠️ Tests failing (auth edge case)
|
|
524
|
-
→
|
|
525
|
-
✅ Tests passing
|
|
526
|
-
📸 Checkpoint 3 created
|
|
527
|
-
✅ Phase 5: JWT code removed
|
|
528
|
-
Complete in 3.5 hours
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
---
|
|
532
|
-
|
|
533
|
-
## Performance Metrics
|
|
534
|
-
|
|
535
|
-
### Before Optimization
|
|
536
|
-
|
|
537
|
-
| Metric | Value |
|
|
538
|
-
|--------|-------|
|
|
539
|
-
| Plan accuracy | ~60% |
|
|
540
|
-
| Time variance | ±50% |
|
|
541
|
-
| Revisions needed | 2-3 |
|
|
542
|
-
| Tool usage | Manual |
|
|
543
|
-
| Blocker frequency | 30% |
|
|
544
|
-
|
|
545
|
-
### After Optimization (Projected)
|
|
546
|
-
|
|
547
|
-
| Metric | Target | Improvement |
|
|
548
|
-
|--------|--------|-------------|
|
|
549
|
-
| Plan accuracy | >85% | +25% |
|
|
550
|
-
| Time variance | ±20% | -30% |
|
|
551
|
-
| Revisions needed | 0-1 | -60% |
|
|
552
|
-
| Tool usage | Automatic | +100% |
|
|
553
|
-
| Blocker frequency | <10% | -20% |
|
|
554
|
-
|
|
555
|
-
### Overall Impact
|
|
556
|
-
|
|
557
|
-
- **60-70% faster** completion (vs no planning)
|
|
558
|
-
- **70-80% fewer** revisions
|
|
559
|
-
- **40-50% reduction** in blockers
|
|
560
|
-
- **20-30% more accurate** time estimates
|
|
561
|
-
- **2-4 hours saved** per week per developer
|
|
562
|
-
|
|
563
|
-
---
|
|
564
|
-
|
|
565
|
-
## Best Practices
|
|
566
|
-
|
|
567
|
-
### 1. Always Research First
|
|
568
|
-
|
|
569
|
-
**Bad**: "I'll create a plan immediately"
|
|
570
|
-
**Good**: "Let me research existing patterns first"
|
|
571
|
-
|
|
572
|
-
Research phase should:
|
|
573
|
-
- Use
|
|
574
|
-
- Launch parallel subagents
|
|
575
|
-
- Check code health with
|
|
576
|
-
- Batch questions with
|
|
577
|
-
|
|
578
|
-
### 2. Validate Before Presenting
|
|
579
|
-
|
|
580
|
-
**Bad**: Present plan without checking
|
|
581
|
-
**Good**: Validate feasibility first
|
|
582
|
-
|
|
583
|
-
Validation should:
|
|
584
|
-
- Use subagent for review
|
|
585
|
-
- Check file accessibility
|
|
586
|
-
- Verify tool availability
|
|
587
|
-
- Flag risks explicitly
|
|
588
|
-
|
|
589
|
-
### 3. Track Progress Religiously
|
|
590
|
-
|
|
591
|
-
**Bad**: Work without updating todos
|
|
592
|
-
**Good**: Update after each step
|
|
593
|
-
|
|
594
|
-
Tracking should:
|
|
595
|
-
- Create todos automatically
|
|
596
|
-
- Update immediately
|
|
597
|
-
- One task in_progress at a time
|
|
598
|
-
- Report blockers early
|
|
599
|
-
|
|
600
|
-
### 4. Iterate When Stuck
|
|
601
|
-
|
|
602
|
-
**Bad**: Give up after first failure
|
|
603
|
-
**Good**: Use
|
|
604
|
-
|
|
605
|
-
Iteration should:
|
|
606
|
-
- Run tests → identify failures
|
|
607
|
-
- Fix code → run again
|
|
608
|
-
- Update scratchpad
|
|
609
|
-
- Report BLOCKED if stuck
|
|
610
|
-
|
|
611
|
-
### 5. Adapt When Needed
|
|
612
|
-
|
|
613
|
-
**Bad**: Follow failing plan rigidly
|
|
614
|
-
**Good**: Re-plan if >30% deviation
|
|
615
|
-
|
|
616
|
-
Re-planning should:
|
|
617
|
-
- Pause execution
|
|
618
|
-
- Create checkpoint
|
|
619
|
-
- Assess what changed
|
|
620
|
-
- Present updated plan
|
|
621
|
-
- Get approval
|
|
622
|
-
|
|
623
|
-
---
|
|
624
|
-
|
|
625
|
-
## Troubleshooting
|
|
626
|
-
|
|
627
|
-
### Research Taking Too Long
|
|
628
|
-
|
|
629
|
-
**Problem**: >5 minutes in research phase
|
|
630
|
-
|
|
631
|
-
**Solutions**:
|
|
632
|
-
- Time-box to 3 minutes max
|
|
633
|
-
- Use model="
|
|
634
|
-
- Narrow target_directories
|
|
635
|
-
- Accept "good enough" patterns
|
|
636
|
-
|
|
637
|
-
### Validation Failing Repeatedly
|
|
638
|
-
|
|
639
|
-
**Problem**: Plan fails validation multiple times
|
|
640
|
-
|
|
641
|
-
**Solutions**:
|
|
642
|
-
- Simplify the plan
|
|
643
|
-
- Break into smaller phases
|
|
644
|
-
- Add more fallback strategies
|
|
645
|
-
- Revise time estimates
|
|
646
|
-
|
|
647
|
-
### Tests Not Passing
|
|
648
|
-
|
|
649
|
-
**Problem**:
|
|
650
|
-
|
|
651
|
-
**Solutions**:
|
|
652
|
-
- Report BLOCKED with details
|
|
653
|
-
-
|
|
654
|
-
- Re-plan approach
|
|
655
|
-
- Check for missing dependencies
|
|
656
|
-
|
|
657
|
-
### Plan Deviation
|
|
658
|
-
|
|
659
|
-
**Problem**: Execution diverging >30% from plan
|
|
660
|
-
|
|
661
|
-
**Solutions**:
|
|
662
|
-
- Pause immediately
|
|
663
|
-
- Create checkpoint
|
|
664
|
-
- Assess what changed
|
|
665
|
-
- Present updated plan
|
|
666
|
-
- Get approval before continuing
|
|
667
|
-
|
|
668
|
-
---
|
|
669
|
-
|
|
670
|
-
## Maintenance
|
|
671
|
-
|
|
672
|
-
### Weekly Review (First Month)
|
|
673
|
-
|
|
674
|
-
- Review plan accuracy metrics
|
|
675
|
-
- Identify failure patterns
|
|
676
|
-
- Refine rules based on data
|
|
677
|
-
- Update tool selection heuristics
|
|
678
|
-
|
|
679
|
-
### Monthly Review (Ongoing)
|
|
680
|
-
|
|
681
|
-
- Analyze tool usage trends
|
|
682
|
-
- Update best practices
|
|
683
|
-
- Add new tool patterns
|
|
684
|
-
- Refine time estimates
|
|
685
|
-
|
|
686
|
-
### Quarterly Major Update
|
|
687
|
-
|
|
688
|
-
- Major feature additions
|
|
689
|
-
- Architecture improvements
|
|
690
|
-
- Integration with new
|
|
691
|
-
- Community feedback incorporation
|
|
692
|
-
|
|
693
|
-
---
|
|
694
|
-
|
|
695
|
-
## MCP Server Integration (NEW)
|
|
696
|
-
|
|
697
|
-
### Automatic MCP Selection
|
|
698
|
-
|
|
699
|
-
The optimized plan mode now automatically selects and uses MCP servers:
|
|
700
|
-
|
|
701
|
-
**Browser MCP** (
|
|
702
|
-
- Triggered by: UI changes, visual verification needs
|
|
703
|
-
- Automatic actions: Snapshot → Interact → Screenshot → Verify
|
|
704
|
-
- Cost: High → Used only when essential
|
|
705
|
-
|
|
706
|
-
**GitHub MCP** (
|
|
707
|
-
- Triggered by: PR/issue operations, git commands
|
|
708
|
-
- Automatic actions: Fetch → Implement → Create PR
|
|
709
|
-
- Cost: Moderate → Used for all git operations
|
|
710
|
-
|
|
711
|
-
**ESLint MCP** (
|
|
712
|
-
- Triggered by: ALL code changes (automatic)
|
|
713
|
-
- Automatic actions: Lint → Auto-fix → Report
|
|
714
|
-
- Cost: Low → Run after every edit
|
|
715
|
-
|
|
716
|
-
**Context7 MCP** (
|
|
717
|
-
- Triggered by: Library/framework questions
|
|
718
|
-
- Automatic actions: Fetch docs → Apply best practices
|
|
719
|
-
- Cost: Low → Fetch proactively
|
|
720
|
-
|
|
721
|
-
### MCP Usage Metrics
|
|
722
|
-
|
|
723
|
-
Track MCP effectiveness:
|
|
724
|
-
- Usage frequency per MCP
|
|
725
|
-
- Success rate correlation
|
|
726
|
-
- Cost vs benefit analysis
|
|
727
|
-
- Auto-disable underperforming MCPs
|
|
728
|
-
|
|
729
|
-
---
|
|
730
|
-
|
|
731
|
-
## Parallel Exploration Strategy (NEW)
|
|
732
|
-
|
|
733
|
-
### Automatic Subagent Deployment
|
|
734
|
-
|
|
735
|
-
For complex tasks, automatically launch 2-4 parallel subagents:
|
|
736
|
-
|
|
737
|
-
**When**:
|
|
738
|
-
- Task complexity: High (>10 steps)
|
|
739
|
-
- Exploration time: >5 minutes
|
|
740
|
-
- Multiple codebase areas involved
|
|
741
|
-
|
|
742
|
-
**Configuration**:
|
|
743
|
-
```typescript
|
|
744
|
-
|
|
745
|
-
description="Explore [area]"
|
|
746
|
-
model="
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
-
|
|
753
|
-
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
-
|
|
776
|
-
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
-
|
|
781
|
-
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
-
|
|
786
|
-
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
-
|
|
791
|
-
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
-
|
|
799
|
-
-
|
|
800
|
-
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
- `
|
|
810
|
-
- `docs/builtin/
|
|
811
|
-
- `docs/
|
|
812
|
-
-
|
|
813
|
-
- `.
|
|
814
|
-
- `.
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
**
|
|
830
|
-
**
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
**
|
|
836
|
-
**License**: CC BY 4.0 (Share and adapt with attribution)
|
|
1
|
+
# Plan Mode Optimization Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide documents the comprehensive optimization of Claude Code's Plan Mode to automatically improve tool selection and usage when building implementation plans.
|
|
6
|
+
|
|
7
|
+
**Status**: ✅ **Implemented**
|
|
8
|
+
**Files Created**: 10 files (4 rules, 2 skills, 3 hooks, 1 config)
|
|
9
|
+
**Impact**: 60-70% faster completion, 70-80% fewer revisions
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Problem Statement
|
|
14
|
+
|
|
15
|
+
### Current State (Before Optimization)
|
|
16
|
+
|
|
17
|
+
Plan Mode provides:
|
|
18
|
+
- Structured implementation plans
|
|
19
|
+
- File lists (create/modify)
|
|
20
|
+
- Implementation steps
|
|
21
|
+
- Testing strategy
|
|
22
|
+
- Time estimates
|
|
23
|
+
|
|
24
|
+
### Missing Automatic Optimizations
|
|
25
|
+
|
|
26
|
+
1. **Tool Selection Not Automated**
|
|
27
|
+
- No automatic Explore (quick) for patterns
|
|
28
|
+
- No automatic subagent exploration
|
|
29
|
+
- No proactive Lint check checks
|
|
30
|
+
- Manual AskUserQuestion usage
|
|
31
|
+
|
|
32
|
+
2. **No Pre-Plan Research**
|
|
33
|
+
- Plans created without understanding existing patterns
|
|
34
|
+
- No automatic file relationship mapping
|
|
35
|
+
- No code health assessment
|
|
36
|
+
|
|
37
|
+
3. **No Validation**
|
|
38
|
+
- No feasibility checking before presentation
|
|
39
|
+
- No tool availability verification
|
|
40
|
+
- No dependency analysis
|
|
41
|
+
|
|
42
|
+
4. **No Learning Loop**
|
|
43
|
+
- No plan accuracy tracking
|
|
44
|
+
- No adaptation based on success/failure
|
|
45
|
+
- No pattern recognition
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Solution: 4-Phase Automatic Workflow
|
|
50
|
+
|
|
51
|
+
```mermaid
|
|
52
|
+
flowchart TD
|
|
53
|
+
A[User Request] --> B[Phase 1: Pre-Plan Research]
|
|
54
|
+
B --> C[Phase 2: Plan Creation]
|
|
55
|
+
C --> D[Phase 3: Plan Validation]
|
|
56
|
+
D --> E[Phase 4: Execution Monitoring]
|
|
57
|
+
|
|
58
|
+
B --> B1["Explore (quick)"]
|
|
59
|
+
B --> B2[Agent Subagents]
|
|
60
|
+
B --> B3[Lint check]
|
|
61
|
+
|
|
62
|
+
C --> C1[CreatePlan Tool]
|
|
63
|
+
C --> C2[AskUserQuestion]
|
|
64
|
+
|
|
65
|
+
D --> D1[Feasibility Check]
|
|
66
|
+
D --> D2[Tool Availability]
|
|
67
|
+
|
|
68
|
+
E --> E1[TodoWrite Tracking]
|
|
69
|
+
E --> E2[Adaptive Re-plan]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Implementation Files
|
|
75
|
+
|
|
76
|
+
### Rules (`.claude/rules/`)
|
|
77
|
+
|
|
78
|
+
#### 1. plan-mode-research.md
|
|
79
|
+
|
|
80
|
+
**Purpose**: Automatic pre-plan research workflow
|
|
81
|
+
|
|
82
|
+
**Key Features**:
|
|
83
|
+
- Explore (quick) for existing patterns (30s)
|
|
84
|
+
- Parallel Agent subagents for exploration (60s)
|
|
85
|
+
- Lint check for code health check (15s)
|
|
86
|
+
- AskUserQuestion for requirement clarification (batched)
|
|
87
|
+
|
|
88
|
+
**When Loaded**: Always in Plan Mode
|
|
89
|
+
|
|
90
|
+
**Example**:
|
|
91
|
+
```markdown
|
|
92
|
+
User: "Add user dashboard"
|
|
93
|
+
|
|
94
|
+
Agent automatically:
|
|
95
|
+
1. Explore (quick): "How are pages structured?"
|
|
96
|
+
2. Agent (parallel):
|
|
97
|
+
- "Find API route patterns"
|
|
98
|
+
- "Find component patterns"
|
|
99
|
+
3. Lint check: Check current health
|
|
100
|
+
4. AskUserQuestion: "Which widgets needed?" (if unclear)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
#### 2. plan-mode-structure.md
|
|
106
|
+
|
|
107
|
+
**Purpose**: Enhanced plan structure with tool strategy
|
|
108
|
+
|
|
109
|
+
**Key Features**:
|
|
110
|
+
- Required plan sections (7 total)
|
|
111
|
+
- Tool-aware step definitions
|
|
112
|
+
- Risk mitigation strategies
|
|
113
|
+
- Quality gates
|
|
114
|
+
|
|
115
|
+
**Plan Structure**:
|
|
116
|
+
```markdown
|
|
117
|
+
## Summary (1-2 sentences)
|
|
118
|
+
|
|
119
|
+
## Files to Create/Modify
|
|
120
|
+
- path/to/file.ts - Purpose
|
|
121
|
+
- Pattern: Follow @[file]
|
|
122
|
+
- Tools: Use [tool] for [operation]
|
|
123
|
+
|
|
124
|
+
## Implementation Steps
|
|
125
|
+
1. [Step]
|
|
126
|
+
- Tool: [Specific tool]
|
|
127
|
+
- Success: [Verifiable metric]
|
|
128
|
+
|
|
129
|
+
## Tool Strategy
|
|
130
|
+
- Exploration: [Tools]
|
|
131
|
+
- Implementation: [Tools]
|
|
132
|
+
- Validation: [Tools]
|
|
133
|
+
|
|
134
|
+
## Risk Mitigation
|
|
135
|
+
- Fallback strategies
|
|
136
|
+
- Checkpoint locations
|
|
137
|
+
|
|
138
|
+
## Estimated Time (with 20% buffer)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
#### 3. plan-mode-validation.md
|
|
144
|
+
|
|
145
|
+
**Purpose**: Automatic plan feasibility validation
|
|
146
|
+
|
|
147
|
+
**Key Features**:
|
|
148
|
+
- Feasibility check via subagent
|
|
149
|
+
- Dependency analysis
|
|
150
|
+
- Risk assessment
|
|
151
|
+
- Tool availability verification
|
|
152
|
+
|
|
153
|
+
**Validation Checklist**:
|
|
154
|
+
- [ ] All files accessible
|
|
155
|
+
- [ ] No circular dependencies
|
|
156
|
+
- [ ] Time estimates realistic
|
|
157
|
+
- [ ] Tools available
|
|
158
|
+
- [ ] Step ordering correct
|
|
159
|
+
- [ ] Risks flagged
|
|
160
|
+
- [ ] Fallbacks defined
|
|
161
|
+
|
|
162
|
+
**Validation Subagent**:
|
|
163
|
+
```
|
|
164
|
+
Agent:
|
|
165
|
+
description="Validate implementation plan"
|
|
166
|
+
prompt="Review this plan for feasibility:
|
|
167
|
+
1. Check file accessibility
|
|
168
|
+
2. Verify tool availability
|
|
169
|
+
3. Estimate time accuracy
|
|
170
|
+
4. Identify blockers
|
|
171
|
+
5. Suggest improvements
|
|
172
|
+
|
|
173
|
+
Return: Pass/Fail + issues"
|
|
174
|
+
subagent_type="Plan" // read-only architect agent
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
#### 4. plan-mode-execution.md
|
|
180
|
+
|
|
181
|
+
**Purpose**: Progress monitoring and adaptive re-planning
|
|
182
|
+
|
|
183
|
+
**Key Features**:
|
|
184
|
+
- Automatic TodoWrite creation
|
|
185
|
+
- Strategic checkpoint creation
|
|
186
|
+
- Iteration loops (fix-and-retest)
|
|
187
|
+
- Adaptive re-planning (>30% deviation)
|
|
188
|
+
- Quality gates after each step
|
|
189
|
+
|
|
190
|
+
**Checkpoint Triggers**:
|
|
191
|
+
- Large refactors (>5 files)
|
|
192
|
+
- Database changes
|
|
193
|
+
- API contract changes
|
|
194
|
+
- Breaking changes
|
|
195
|
+
- Irreversible operations
|
|
196
|
+
|
|
197
|
+
**Quality Gates**:
|
|
198
|
+
- Lint check after each edit
|
|
199
|
+
- Tests after each phase
|
|
200
|
+
- TodoWrite updated immediately
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
### Skills (`.claude/skills/`)
|
|
205
|
+
|
|
206
|
+
#### 1. plan-mode-mastery/SKILL.md
|
|
207
|
+
|
|
208
|
+
**Purpose**: Complete optimized plan mode workflow
|
|
209
|
+
|
|
210
|
+
**Commands**:
|
|
211
|
+
- `/plan-mode-full`: Complete optimized workflow
|
|
212
|
+
- `/plan-mode-quick`: Standard plan mode (no research)
|
|
213
|
+
- `/plan-mode-validate`: Validate existing plan
|
|
214
|
+
|
|
215
|
+
**Workflow**:
|
|
216
|
+
```
|
|
217
|
+
1. Pre-Plan Research (2-3 min)
|
|
218
|
+
- Explore (quick)
|
|
219
|
+
- Parallel subagents
|
|
220
|
+
- Lint check
|
|
221
|
+
- AskUserQuestion (batch)
|
|
222
|
+
|
|
223
|
+
2. Plan Creation (1-2 min)
|
|
224
|
+
- Enhanced structure
|
|
225
|
+
- Risk assessment
|
|
226
|
+
- Checkpoint strategy
|
|
227
|
+
|
|
228
|
+
3. Plan Validation (1 min)
|
|
229
|
+
- Feasibility subagent
|
|
230
|
+
- Tool availability check
|
|
231
|
+
|
|
232
|
+
4. Execution Monitoring
|
|
233
|
+
- TodoWrite tracking
|
|
234
|
+
- Automatic checkpoints
|
|
235
|
+
- Iteration loops
|
|
236
|
+
- Adaptive re-planning
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
#### 2. tool-selection/SKILL.md
|
|
242
|
+
|
|
243
|
+
**Purpose**: Optimal tool selection decision skill
|
|
244
|
+
|
|
245
|
+
**Decision Trees**:
|
|
246
|
+
|
|
247
|
+
**Finding Code**:
|
|
248
|
+
```
|
|
249
|
+
Know file path?
|
|
250
|
+
├─ Yes → Read
|
|
251
|
+
└─ No
|
|
252
|
+
├─ Exact text? → Grep
|
|
253
|
+
├─ Concept? → Explore (quick)
|
|
254
|
+
└─ Broad exploration? → Agent (Explore)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Modifying Code**:
|
|
258
|
+
```
|
|
259
|
+
New file?
|
|
260
|
+
├─ Yes → Write
|
|
261
|
+
└─ No
|
|
262
|
+
├─ <50 lines? → Edit
|
|
263
|
+
└─ >50 lines → Write (entire file)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Validation**:
|
|
267
|
+
```
|
|
268
|
+
Linting? → Lint check
|
|
269
|
+
Tests? → Bash
|
|
270
|
+
Visual? → Browser/Screenshot
|
|
271
|
+
User approval? → AskUserQuestion
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Tool Cost Hierarchy**:
|
|
275
|
+
```
|
|
276
|
+
Tier 1 (Cheapest): Read, Glob, Grep
|
|
277
|
+
Tier 2 (Moderate): Explore (quick), Edit, Write
|
|
278
|
+
Tier 3 (Higher): Agent, Bash, Lint check
|
|
279
|
+
Tier 4 (Most expensive): Parallel subagents, Browser MCP
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Hooks (`.claude/hooks/`)
|
|
285
|
+
|
|
286
|
+
#### 1. plan-quality-tracker.ts (Consolidated)
|
|
287
|
+
|
|
288
|
+
**Purpose**: Plan metrics tracking, monitoring, and learning
|
|
289
|
+
|
|
290
|
+
**Note**: Consolidated from `plan-mode-monitor.ts` and `plan-quality-tracker.ts` in March 2026 optimization.
|
|
291
|
+
|
|
292
|
+
**Features**:
|
|
293
|
+
- Track iterations (failed tool calls retried in the turn)
|
|
294
|
+
- Real tool usage extraction from the Claude Code transcript (`transcript_path`)
|
|
295
|
+
- Actual plan accuracy calculations
|
|
296
|
+
- Tool efficiency scoring (Tier 1-4)
|
|
297
|
+
- MCP server usage tracking
|
|
298
|
+
- Parallel subagent counting
|
|
299
|
+
- Provide feedback on failures and patterns
|
|
300
|
+
- Suggest improvements based on metrics
|
|
301
|
+
|
|
302
|
+
**Triggers**: `Stop` event
|
|
303
|
+
|
|
304
|
+
**Metrics Tracked**:
|
|
305
|
+
- `plan_accuracy`: % of plan followed (calculated from iterations)
|
|
306
|
+
- `time_variance`: actual vs estimated time
|
|
307
|
+
- `tool_usage`: frequency per tool
|
|
308
|
+
- `iteration_count`: fix-and-retest loops used
|
|
309
|
+
- `blocker_count`: times BLOCKED
|
|
310
|
+
- `tool_efficiency`: ratio of cheap vs expensive tools
|
|
311
|
+
- `mcp_usage`: MCP server frequency
|
|
312
|
+
- `parallel_subagents`: count of parallel subagents used
|
|
313
|
+
|
|
314
|
+
**Storage**: `.claude/plan-metrics.json`
|
|
315
|
+
|
|
316
|
+
**Rolling Averages**: Last 10 plans
|
|
317
|
+
|
|
318
|
+
**Example Output**:
|
|
319
|
+
```
|
|
320
|
+
[Plan Tracker] Processing execution data for session <session_id>...
|
|
321
|
+
[Plan Tracker] ✓ Metrics saved
|
|
322
|
+
[Plan Tracker] Rolling averages (last 10 plans):
|
|
323
|
+
- Accuracy: 82.5%
|
|
324
|
+
- Avg iterations: 1.8
|
|
325
|
+
- Tool efficiency: 75.0
|
|
326
|
+
- Avg parallel subagents: 2.3
|
|
327
|
+
[Plan Tracker] MCP tools used in this session: mcp__claude-in-chrome__navigate, mcp__github__search_issues
|
|
328
|
+
[Plan Tracker] ✓ High accuracy with MCP tools - good tool selection
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
#### 2. settings.json (Claude Code hooks)
|
|
334
|
+
|
|
335
|
+
**Purpose**: Wire all hooks into Claude Code (`.claude/settings.json`)
|
|
336
|
+
|
|
337
|
+
**Configuration**:
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"hooks": {
|
|
341
|
+
"PostToolUse": [
|
|
342
|
+
{
|
|
343
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
344
|
+
"hooks": [{ "type": "command", "command": "npx -y tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-lint-fix.ts\"", "timeout": 90 }]
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"Stop": [
|
|
348
|
+
{
|
|
349
|
+
"hooks": [
|
|
350
|
+
{ "type": "command", "command": "npx -y tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-validate.ts\"", "timeout": 300 },
|
|
351
|
+
{ "type": "command", "command": "npx -y tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-security-review.ts\"", "timeout": 60 },
|
|
352
|
+
{ "type": "command", "command": "npx -y tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/plan-quality-tracker.ts\"", "timeout": 60 }
|
|
353
|
+
]
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
"SessionStart": [
|
|
357
|
+
{
|
|
358
|
+
"matcher": "startup",
|
|
359
|
+
"hooks": [{ "type": "command", "command": "npx -y tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-learning-review.ts\"", "timeout": 60 }]
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**How it works**:
|
|
367
|
+
- Hooks read the Claude Code hook payload from stdin (`session_id`, `transcript_path`, `stop_hook_active`, `tool_input`)
|
|
368
|
+
- Stop hooks only look at the current turn (everything after your last prompt) in the transcript JSONL
|
|
369
|
+
- Validation/security failures return `{"decision": "block", "reason": ...}` so Claude keeps working and fixes them; never twice in a row (`stop_hook_active`)
|
|
370
|
+
- Advisory feedback returns `{"systemMessage": ...}` (shown to you, does not block)
|
|
371
|
+
- Optional thresholds live in `.claude/hooks.config.json`
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Usage Examples
|
|
376
|
+
|
|
377
|
+
### Example 1: Simple Feature
|
|
378
|
+
|
|
379
|
+
**User**: "Add login button to header"
|
|
380
|
+
|
|
381
|
+
**Optimized Plan Mode Workflow**:
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
Phase 1: Research (1 min)
|
|
385
|
+
- Explore (quick): "How are buttons styled?"
|
|
386
|
+
- Lint check: Check Header.tsx
|
|
387
|
+
|
|
388
|
+
Phase 2: Plan (30 sec)
|
|
389
|
+
## Summary
|
|
390
|
+
Add login button following existing button patterns.
|
|
391
|
+
|
|
392
|
+
## Files to Modify
|
|
393
|
+
- components/Header.tsx
|
|
394
|
+
- Pattern: Follow @components/Button.tsx
|
|
395
|
+
- Tools: Edit, Lint check
|
|
396
|
+
|
|
397
|
+
## Steps
|
|
398
|
+
1. Find button patterns (Explore (quick))
|
|
399
|
+
2. Add button (Edit)
|
|
400
|
+
3. Verify (Lint check)
|
|
401
|
+
|
|
402
|
+
## Time: 10 minutes
|
|
403
|
+
|
|
404
|
+
Phase 3: Validation (30 sec)
|
|
405
|
+
- Agent: Validate (quick)
|
|
406
|
+
- Result: PASS
|
|
407
|
+
|
|
408
|
+
Phase 4: Execution
|
|
409
|
+
✅ Step 1: Explore (quick) → found patterns
|
|
410
|
+
✅ Step 2: Edit → button added
|
|
411
|
+
✅ Step 3: Lint check → clear
|
|
412
|
+
Complete in 8 minutes
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
### Example 2: Complex Feature
|
|
418
|
+
|
|
419
|
+
**User**: "Add user dashboard"
|
|
420
|
+
|
|
421
|
+
**Optimized Plan Mode Workflow**:
|
|
422
|
+
|
|
423
|
+
```
|
|
424
|
+
Phase 1: Research (3 min)
|
|
425
|
+
- Explore (quick): "How are pages structured?"
|
|
426
|
+
- Agent (parallel x3):
|
|
427
|
+
- "Find page patterns"
|
|
428
|
+
- "Find component patterns"
|
|
429
|
+
- "Find API patterns"
|
|
430
|
+
- Lint check: Check target files
|
|
431
|
+
- AskUserQuestion: "Which widgets for MVP?"
|
|
432
|
+
|
|
433
|
+
Phase 2: Plan (2 min)
|
|
434
|
+
## Summary
|
|
435
|
+
Create dashboard with stats, activity feed, settings.
|
|
436
|
+
|
|
437
|
+
## Files to Create
|
|
438
|
+
- app/dashboard/page.tsx (pattern: @app/profile/page.tsx)
|
|
439
|
+
- components/dashboard/StatsCard.tsx
|
|
440
|
+
- app/api/dashboard/stats/route.ts
|
|
441
|
+
|
|
442
|
+
## Tool Strategy
|
|
443
|
+
- Exploration: Agent (Explore) x3 parallel
|
|
444
|
+
- Implementation: Write, Edit
|
|
445
|
+
- Validation: Bash (tests), Lint check
|
|
446
|
+
|
|
447
|
+
## Risk Mitigation
|
|
448
|
+
- Checkpoint before API changes
|
|
449
|
+
- Fallback: Mock data if API delayed
|
|
450
|
+
|
|
451
|
+
## Time: 45 minutes
|
|
452
|
+
|
|
453
|
+
Phase 3: Validation (1 min)
|
|
454
|
+
- Agent: Validate feasibility
|
|
455
|
+
- Warning: API dependency
|
|
456
|
+
- Result: PASS with caveats
|
|
457
|
+
|
|
458
|
+
Phase 4: Execution
|
|
459
|
+
✅ Research phase complete
|
|
460
|
+
✅ API endpoint created
|
|
461
|
+
📸 Checkpoint created
|
|
462
|
+
✅ Dashboard page created
|
|
463
|
+
✅ Components created
|
|
464
|
+
⚠️ Tests failing → fix-and-retest loop (2 iterations)
|
|
465
|
+
✅ Tests passing
|
|
466
|
+
Complete in 52 minutes
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
### Example 3: Complex Refactor
|
|
472
|
+
|
|
473
|
+
**User**: "Migrate authentication from JWT to sessions"
|
|
474
|
+
|
|
475
|
+
**Optimized Plan Mode Workflow**:
|
|
476
|
+
|
|
477
|
+
```
|
|
478
|
+
Phase 1: Research (3 min)
|
|
479
|
+
- Explore (quick): "How is auth implemented?"
|
|
480
|
+
- Agent (parallel x4):
|
|
481
|
+
- "Find JWT validation"
|
|
482
|
+
- "Find session management"
|
|
483
|
+
- "Find OAuth integrations"
|
|
484
|
+
- "Find password hashing"
|
|
485
|
+
- Lint check: Check all auth files (found 2 warnings)
|
|
486
|
+
- AskUserQuestion: "Target session provider?"
|
|
487
|
+
|
|
488
|
+
Phase 2: Plan (3 min)
|
|
489
|
+
## Summary
|
|
490
|
+
Migrate from JWT to sessions with zero downtime.
|
|
491
|
+
|
|
492
|
+
## Files to Modify (8 files)
|
|
493
|
+
- src/auth/validateToken.ts → sessions
|
|
494
|
+
- src/auth/middleware.ts → session middleware
|
|
495
|
+
- app/api/auth/login/route.ts → session creation
|
|
496
|
+
- ... (5 more files)
|
|
497
|
+
|
|
498
|
+
## Checkpoints (3)
|
|
499
|
+
1. Before database changes
|
|
500
|
+
2. Before middleware changes
|
|
501
|
+
3. Before removing JWT code
|
|
502
|
+
|
|
503
|
+
## Risk Mitigation
|
|
504
|
+
- Rollback plan: Keep JWT until tests pass
|
|
505
|
+
- Fallback: Hybrid auth during transition
|
|
506
|
+
- Monitoring: Auth failure rate tracking
|
|
507
|
+
|
|
508
|
+
## Time: 3 hours
|
|
509
|
+
|
|
510
|
+
Phase 3: Validation (1 min)
|
|
511
|
+
- Agent: Validate (comprehensive)
|
|
512
|
+
- Warning: High risk, breaking change
|
|
513
|
+
- Suggestion: Phased rollout
|
|
514
|
+
- Result: PASS with warnings
|
|
515
|
+
|
|
516
|
+
Phase 4: Execution
|
|
517
|
+
✅ Phase 1: Research complete
|
|
518
|
+
✅ Phase 2: Dependencies added
|
|
519
|
+
📸 Checkpoint 1 created
|
|
520
|
+
✅ Phase 3: Database migrated
|
|
521
|
+
📸 Checkpoint 2 created
|
|
522
|
+
✅ Phase 4: Middleware updated
|
|
523
|
+
⚠️ Tests failing (auth edge case)
|
|
524
|
+
→ fix-and-retest loop (3 iterations)
|
|
525
|
+
✅ Tests passing
|
|
526
|
+
📸 Checkpoint 3 created
|
|
527
|
+
✅ Phase 5: JWT code removed
|
|
528
|
+
Complete in 3.5 hours
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Performance Metrics
|
|
534
|
+
|
|
535
|
+
### Before Optimization
|
|
536
|
+
|
|
537
|
+
| Metric | Value |
|
|
538
|
+
|--------|-------|
|
|
539
|
+
| Plan accuracy | ~60% |
|
|
540
|
+
| Time variance | ±50% |
|
|
541
|
+
| Revisions needed | 2-3 |
|
|
542
|
+
| Tool usage | Manual |
|
|
543
|
+
| Blocker frequency | 30% |
|
|
544
|
+
|
|
545
|
+
### After Optimization (Projected)
|
|
546
|
+
|
|
547
|
+
| Metric | Target | Improvement |
|
|
548
|
+
|--------|--------|-------------|
|
|
549
|
+
| Plan accuracy | >85% | +25% |
|
|
550
|
+
| Time variance | ±20% | -30% |
|
|
551
|
+
| Revisions needed | 0-1 | -60% |
|
|
552
|
+
| Tool usage | Automatic | +100% |
|
|
553
|
+
| Blocker frequency | <10% | -20% |
|
|
554
|
+
|
|
555
|
+
### Overall Impact
|
|
556
|
+
|
|
557
|
+
- **60-70% faster** completion (vs no planning)
|
|
558
|
+
- **70-80% fewer** revisions
|
|
559
|
+
- **40-50% reduction** in blockers
|
|
560
|
+
- **20-30% more accurate** time estimates
|
|
561
|
+
- **2-4 hours saved** per week per developer
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
|
|
565
|
+
## Best Practices
|
|
566
|
+
|
|
567
|
+
### 1. Always Research First
|
|
568
|
+
|
|
569
|
+
**Bad**: "I'll create a plan immediately"
|
|
570
|
+
**Good**: "Let me research existing patterns first"
|
|
571
|
+
|
|
572
|
+
Research phase should:
|
|
573
|
+
- Use Explore (quick) for patterns
|
|
574
|
+
- Launch parallel subagents
|
|
575
|
+
- Check code health with Lint check
|
|
576
|
+
- Batch questions with AskUserQuestion
|
|
577
|
+
|
|
578
|
+
### 2. Validate Before Presenting
|
|
579
|
+
|
|
580
|
+
**Bad**: Present plan without checking
|
|
581
|
+
**Good**: Validate feasibility first
|
|
582
|
+
|
|
583
|
+
Validation should:
|
|
584
|
+
- Use subagent for review
|
|
585
|
+
- Check file accessibility
|
|
586
|
+
- Verify tool availability
|
|
587
|
+
- Flag risks explicitly
|
|
588
|
+
|
|
589
|
+
### 3. Track Progress Religiously
|
|
590
|
+
|
|
591
|
+
**Bad**: Work without updating todos
|
|
592
|
+
**Good**: Update after each step
|
|
593
|
+
|
|
594
|
+
Tracking should:
|
|
595
|
+
- Create todos automatically
|
|
596
|
+
- Update immediately
|
|
597
|
+
- One task in_progress at a time
|
|
598
|
+
- Report blockers early
|
|
599
|
+
|
|
600
|
+
### 4. Iterate When Stuck
|
|
601
|
+
|
|
602
|
+
**Bad**: Give up after first failure
|
|
603
|
+
**Good**: Use the fix-and-retest loop (max 5 iterations)
|
|
604
|
+
|
|
605
|
+
Iteration should:
|
|
606
|
+
- Run tests → identify failures
|
|
607
|
+
- Fix code → run again
|
|
608
|
+
- Update scratchpad
|
|
609
|
+
- Report BLOCKED if stuck
|
|
610
|
+
|
|
611
|
+
### 5. Adapt When Needed
|
|
612
|
+
|
|
613
|
+
**Bad**: Follow failing plan rigidly
|
|
614
|
+
**Good**: Re-plan if >30% deviation
|
|
615
|
+
|
|
616
|
+
Re-planning should:
|
|
617
|
+
- Pause execution
|
|
618
|
+
- Create checkpoint
|
|
619
|
+
- Assess what changed
|
|
620
|
+
- Present updated plan
|
|
621
|
+
- Get approval
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## Troubleshooting
|
|
626
|
+
|
|
627
|
+
### Research Taking Too Long
|
|
628
|
+
|
|
629
|
+
**Problem**: >5 minutes in research phase
|
|
630
|
+
|
|
631
|
+
**Solutions**:
|
|
632
|
+
- Time-box to 3 minutes max
|
|
633
|
+
- Use model="haiku" for subagents
|
|
634
|
+
- Narrow target_directories
|
|
635
|
+
- Accept "good enough" patterns
|
|
636
|
+
|
|
637
|
+
### Validation Failing Repeatedly
|
|
638
|
+
|
|
639
|
+
**Problem**: Plan fails validation multiple times
|
|
640
|
+
|
|
641
|
+
**Solutions**:
|
|
642
|
+
- Simplify the plan
|
|
643
|
+
- Break into smaller phases
|
|
644
|
+
- Add more fallback strategies
|
|
645
|
+
- Revise time estimates
|
|
646
|
+
|
|
647
|
+
### Tests Not Passing
|
|
648
|
+
|
|
649
|
+
**Problem**: fix-and-retest loop failing after 5 iterations
|
|
650
|
+
|
|
651
|
+
**Solutions**:
|
|
652
|
+
- Report BLOCKED with details
|
|
653
|
+
- AskUserQuestion for guidance
|
|
654
|
+
- Re-plan approach
|
|
655
|
+
- Check for missing dependencies
|
|
656
|
+
|
|
657
|
+
### Plan Deviation
|
|
658
|
+
|
|
659
|
+
**Problem**: Execution diverging >30% from plan
|
|
660
|
+
|
|
661
|
+
**Solutions**:
|
|
662
|
+
- Pause immediately
|
|
663
|
+
- Create checkpoint
|
|
664
|
+
- Assess what changed
|
|
665
|
+
- Present updated plan
|
|
666
|
+
- Get approval before continuing
|
|
667
|
+
|
|
668
|
+
---
|
|
669
|
+
|
|
670
|
+
## Maintenance
|
|
671
|
+
|
|
672
|
+
### Weekly Review (First Month)
|
|
673
|
+
|
|
674
|
+
- Review plan accuracy metrics
|
|
675
|
+
- Identify failure patterns
|
|
676
|
+
- Refine rules based on data
|
|
677
|
+
- Update tool selection heuristics
|
|
678
|
+
|
|
679
|
+
### Monthly Review (Ongoing)
|
|
680
|
+
|
|
681
|
+
- Analyze tool usage trends
|
|
682
|
+
- Update best practices
|
|
683
|
+
- Add new tool patterns
|
|
684
|
+
- Refine time estimates
|
|
685
|
+
|
|
686
|
+
### Quarterly Major Update
|
|
687
|
+
|
|
688
|
+
- Major feature additions
|
|
689
|
+
- Architecture improvements
|
|
690
|
+
- Integration with new Claude Code features
|
|
691
|
+
- Community feedback incorporation
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## MCP Server Integration (NEW)
|
|
696
|
+
|
|
697
|
+
### Automatic MCP Selection
|
|
698
|
+
|
|
699
|
+
The optimized plan mode now automatically selects and uses MCP servers:
|
|
700
|
+
|
|
701
|
+
**Browser MCP** (claude-in-chrome):
|
|
702
|
+
- Triggered by: UI changes, visual verification needs
|
|
703
|
+
- Automatic actions: Snapshot → Interact → Screenshot → Verify
|
|
704
|
+
- Cost: High → Used only when essential
|
|
705
|
+
|
|
706
|
+
**GitHub MCP** (github):
|
|
707
|
+
- Triggered by: PR/issue operations, git commands
|
|
708
|
+
- Automatic actions: Fetch → Implement → Create PR
|
|
709
|
+
- Cost: Moderate → Used for all git operations
|
|
710
|
+
|
|
711
|
+
**ESLint MCP** (eslint):
|
|
712
|
+
- Triggered by: ALL code changes (automatic)
|
|
713
|
+
- Automatic actions: Lint → Auto-fix → Report
|
|
714
|
+
- Cost: Low → Run after every edit
|
|
715
|
+
|
|
716
|
+
**Context7 MCP** (context7):
|
|
717
|
+
- Triggered by: Library/framework questions
|
|
718
|
+
- Automatic actions: Fetch docs → Apply best practices
|
|
719
|
+
- Cost: Low → Fetch proactively
|
|
720
|
+
|
|
721
|
+
### MCP Usage Metrics
|
|
722
|
+
|
|
723
|
+
Track MCP effectiveness:
|
|
724
|
+
- Usage frequency per MCP
|
|
725
|
+
- Success rate correlation
|
|
726
|
+
- Cost vs benefit analysis
|
|
727
|
+
- Auto-disable underperforming MCPs
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
731
|
+
## Parallel Exploration Strategy (NEW)
|
|
732
|
+
|
|
733
|
+
### Automatic Subagent Deployment
|
|
734
|
+
|
|
735
|
+
For complex tasks, automatically launch 2-4 parallel subagents:
|
|
736
|
+
|
|
737
|
+
**When**:
|
|
738
|
+
- Task complexity: High (>10 steps)
|
|
739
|
+
- Exploration time: >5 minutes
|
|
740
|
+
- Multiple codebase areas involved
|
|
741
|
+
|
|
742
|
+
**Configuration**:
|
|
743
|
+
```typescript
|
|
744
|
+
Agent:
|
|
745
|
+
description="Explore [area]"
|
|
746
|
+
model="haiku" // Cost optimization
|
|
747
|
+
run_in_background=true // Non-blocking
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
**Benefits**:
|
|
751
|
+
- 60-70% faster discovery
|
|
752
|
+
- Broader codebase coverage
|
|
753
|
+
- Reduced sequential waiting
|
|
754
|
+
|
|
755
|
+
### Consolidation Pattern
|
|
756
|
+
|
|
757
|
+
After parallel exploration:
|
|
758
|
+
1. Aggregate findings from all subagents
|
|
759
|
+
2. Identify consensus (multiple found same thing)
|
|
760
|
+
3. Resolve conflicts
|
|
761
|
+
4. Create unified codebase map
|
|
762
|
+
5. Generate informed plan
|
|
763
|
+
|
|
764
|
+
---
|
|
765
|
+
|
|
766
|
+
## Tool Cost Optimization (NEW)
|
|
767
|
+
|
|
768
|
+
### Automatic Escalation Protocol
|
|
769
|
+
|
|
770
|
+
**Rule**: Start with cheapest tool, escalate only if needed
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
Tier 1 (Always Try First):
|
|
774
|
+
- Read: Single file access
|
|
775
|
+
- Glob: Pattern matching
|
|
776
|
+
- Grep: Exact text search
|
|
777
|
+
|
|
778
|
+
If Tier 1 insufficient → Escalate to Tier 2:
|
|
779
|
+
- Explore (quick): Conceptual search
|
|
780
|
+
- Edit: Small edits
|
|
781
|
+
- Write: New files
|
|
782
|
+
|
|
783
|
+
If Tier 2 inadequate → Escalate to Tier 3:
|
|
784
|
+
- Agent: Complex exploration
|
|
785
|
+
- Bash: Command execution
|
|
786
|
+
- Lint check: Quality checks
|
|
787
|
+
|
|
788
|
+
If Tier 3 insufficient → Escalate to Tier 4:
|
|
789
|
+
- Parallel subagents: Multi-angle discovery
|
|
790
|
+
- Browser MCP: Visual verification
|
|
791
|
+
- Complex workflows: Multi-step automation
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
### Cost Tracking
|
|
795
|
+
|
|
796
|
+
Monitor tool costs:
|
|
797
|
+
- Execution time per tool
|
|
798
|
+
- Token consumption per tool
|
|
799
|
+
- Success rate per tool
|
|
800
|
+
- Optimal tool sequences
|
|
801
|
+
|
|
802
|
+
**Optimization**: Prefer tools with high success/low cost ratio
|
|
803
|
+
|
|
804
|
+
---
|
|
805
|
+
|
|
806
|
+
## Related Documentation
|
|
807
|
+
|
|
808
|
+
- `AGENT-INSTRUCTION-BEST-PRACTICES.md` - Core principles
|
|
809
|
+
- `docs/builtin/WorkflowTools.md` - Plan Mode capabilities
|
|
810
|
+
- `docs/builtin/CodeAnalysis.md` - Research tools
|
|
811
|
+
- `docs/best-practices/ToolSelection.md` - Tool optimization
|
|
812
|
+
- `.claude/rules/plan-mode-*.md` - Implementation rules
|
|
813
|
+
- `.claude/skills/*/SKILL.md` - Implementation skills
|
|
814
|
+
- `.claude/docs/MCP-INTEGRATION-GUIDE.md` - MCP server usage guide
|
|
815
|
+
|
|
816
|
+
---
|
|
817
|
+
|
|
818
|
+
## Conclusion
|
|
819
|
+
|
|
820
|
+
This comprehensive optimization transforms Plan Mode from a **passive planning tool** into an **active, intelligent workflow orchestrator** that:
|
|
821
|
+
|
|
822
|
+
1. ✅ **Automatically researches** before planning
|
|
823
|
+
2. ✅ **Creates tool-aware plans** with specific strategies
|
|
824
|
+
3. ✅ **Validates feasibility** before presentation
|
|
825
|
+
4. ✅ **Monitors execution** with adaptive re-planning
|
|
826
|
+
5. ✅ **Learns from experience** to improve over time
|
|
827
|
+
|
|
828
|
+
**Implementation**: 10 files, 0 breaking changes
|
|
829
|
+
**Impact**: 60-70% faster, 70-80% fewer revisions
|
|
830
|
+
**ROI**: 2-4 hours saved per week per developer
|
|
831
|
+
|
|
832
|
+
---
|
|
833
|
+
|
|
834
|
+
**Last Updated**: March 29, 2026
|
|
835
|
+
**License**: CC BY 4.0 (Share and adapt with attribution)
|