claudify-agent 1.0.1 → 1.0.3

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.
Files changed (47) hide show
  1. package/.claude/QUICK-REFERENCE.md +213 -213
  2. package/.claude/cost-dashboard.md +162 -162
  3. package/.claude/docs/COST-OPTIMIZATION.md +402 -403
  4. package/.claude/docs/MCP-INTEGRATION-GUIDE.md +348 -348
  5. package/.claude/docs/PLAN-MODE-OPTIMIZATION.md +835 -836
  6. package/.claude/hooks/auto-learning-review.ts +200 -195
  7. package/.claude/hooks/auto-lint-fix.ts +60 -104
  8. package/.claude/hooks/auto-security-review.ts +314 -354
  9. package/.claude/hooks/auto-validate.ts +249 -348
  10. package/.claude/hooks/lib/claude-hook.ts +168 -0
  11. package/.claude/hooks/plan-quality-tracker.ts +598 -719
  12. package/.claude/rules/anti-patterns.md +22 -22
  13. package/.claude/rules/context-tier-1.md +41 -41
  14. package/.claude/rules/context-tier-2.md +285 -285
  15. package/.claude/rules/general.md +25 -25
  16. package/.claude/rules/mcp-auto-use.md +46 -46
  17. package/.claude/rules/parallel-exploration-auto.md +30 -31
  18. package/.claude/rules/plan-mode-execution.md +289 -289
  19. package/.claude/rules/plan-mode-research.md +34 -34
  20. package/.claude/rules/plan-mode-structure.md +166 -166
  21. package/.claude/rules/plan-mode-validation.md +129 -130
  22. package/.claude/rules/security-critical.md +19 -19
  23. package/.claude/rules/tool-auto-selection.md +45 -45
  24. package/.claude/rules/tool-strategy.md +22 -22
  25. package/.claude/scripts/security-scan.js +1 -1
  26. package/.claude/security-dashboard.md +142 -142
  27. package/.claude/settings.json +50 -0
  28. package/.claude/skills/debug-optimizer/SKILL.md +420 -399
  29. package/.claude/skills/learning-loop/SKILL.md +313 -308
  30. package/.claude/skills/mcp-mastery/SKILL.md +218 -214
  31. package/.claude/skills/nextjs-guide/SKILL.md +687 -687
  32. package/.claude/skills/parallel-exploration/SKILL.md +197 -193
  33. package/.claude/skills/plan-mode-mastery/SKILL.md +268 -263
  34. package/.claude/skills/python-guide/SKILL.md +822 -822
  35. package/.claude/skills/react-guide/SKILL.md +762 -762
  36. package/.claude/skills/{security.md → security-guide/SKILL.md} +10 -0
  37. package/.claude/skills/solidity-guide/SKILL.md +5 -0
  38. package/.claude/skills/tool-selection/SKILL.md +433 -428
  39. package/.claude/skills/vite-guide/SKILL.md +445 -445
  40. package/CLAUDE.md +1 -0
  41. package/README.md +74 -35
  42. package/README.vi.md +106 -0
  43. package/bin/cli.js +13 -4
  44. package/package.json +13 -1
  45. package/.claude/skills/debug-optimizer.md +0 -12
  46. package/.claude/skills/nextjs.md +0 -13
  47. package/.claude/skills/react.md +0 -12
@@ -1,428 +1,433 @@
1
- # SKILL.md: Optimal Tool Selection
2
-
3
- ## Description
4
- Automatically select best tools for each plan step based on task type, complexity, and available resources.
5
-
6
- ## When to Use
7
- - Creating implementation plans
8
- - Deciding which tools to use
9
- - Optimizing workflow efficiency
10
- - Troubleshooting tool failures
11
-
12
- ## Capabilities
13
- - Tool selection decision tree
14
- - Cost/complexity analysis
15
- - Fallback tool identification
16
- - Tool combination strategies
17
-
18
- ## Tool Selection Rules
19
-
20
- ### For Exploration
21
-
22
- | Goal | Tool | When |
23
- |------|------|------|
24
- | Read single file | Read | Know exact path |
25
- | Find multiple files | Glob + Read | Pattern matching |
26
- | Exact text search | Grep | Specific strings/symbols |
27
- | Conceptual search | SemanticSearch | Behavior/pattern |
28
- | Broad exploration | Task (explore) | Multi-file investigation |
29
-
30
- ### For Implementation
31
-
32
- | Goal | Tool | When |
33
- |------|------|------|
34
- | New file | Write | Creating from scratch |
35
- | Small edit (<50 lines) | StrReplace | Targeted changes |
36
- | Large rewrite (>50 lines) | Write | Replace entire file |
37
- | Jupyter notebook | EditNotebook | Cell-level edits |
38
-
39
- ### For Validation
40
-
41
- | Goal | Tool | When |
42
- |------|------|------|
43
- | Code quality | ReadLints | After edits |
44
- | Functionality | Shell (tests) | Run test suite |
45
- | Visual changes | Browser/Screenshot | UI verification |
46
- | User feedback | AskQuestion | Decisions needed |
47
-
48
- ### For Complex Tasks
49
-
50
- | Goal | Tool | When |
51
- |------|------|------|
52
- | Multi-step tracking | TodoWrite | 3+ steps |
53
- | Ambiguous requirements | AskQuestion | Clarification needed |
54
- | Risky changes | Checkpoints | Before breaking changes |
55
- | Iterative fixes | /grind loop | Tests failing |
56
-
57
- ## Decision Trees
58
-
59
- ### "I need to find code"
60
-
61
- ```
62
- Know file path?
63
- ├─ Yes → Read
64
- └─ No
65
- ├─ Exact text/symbol?
66
- │ ├─ Yes → Grep
67
- │ └─ No
68
- │ ├─ Concept/behavior?
69
- │ │ ├─ Yes → SemanticSearch
70
- │ │ └─ No
71
- │ └─ Broad exploration?
72
- │ ├─ Yes → Task (explore)
73
- │ └─ No → Glob
74
- ```
75
-
76
- ### "I need to modify code"
77
-
78
- ```
79
- Jupyter notebook?
80
- ├─ Yes → EditNotebook
81
- └─ No
82
- ├─ New file?
83
- │ ├─ Yes → Write
84
- │ └─ No
85
- │ ├─ <50 lines change?
86
- │ │ ├─ Yes → StrReplace
87
- │ │ └─ No → Write (replace entire file)
88
- ```
89
-
90
- ### "I need to verify"
91
-
92
- ```
93
- Linting issues?
94
- ├─ Yes → ReadLints
95
- └─ No
96
- ├─ Tests needed?
97
- │ ├─ Yes → Shell (npm run test)
98
- │ └─ No
99
- │ ├─ Visual changes?
100
- │ │ ├─ Yes → Browser/Screenshot
101
- │ │ └─ No
102
- │ └─ User approval?
103
- │ ├─ Yes → AskQuestion
104
- │ └─ No → Continue
105
- ```
106
-
107
- ### "I need to automate browser"
108
-
109
- ```
110
- Need performance profiling?
111
- ├─ Yes → cursor-ide-browser (has profiling)
112
- └─ No
113
- ├─ Need Lighthouse audits?
114
- │ ├─ Yes → user-chrome-devtools
115
- │ └─ No
116
- │ ├─ Need cross-browser testing?
117
- │ │ ├─ Yes → user-playwright
118
- │ │ └─ No
119
- │ └─ Quick testing?
120
- │ ├─ Yes → Built-in Browser (7 capabilities)
121
- │ └─ No → user-selenium (accessibility)
122
- ```
123
-
124
- ## Tool Cost Hierarchy
125
-
126
- **Start cheap, escalate as needed:**
127
-
128
- ```
129
- Tier 1 (Cheapest, fastest):
130
- - Read (single file)
131
- - Glob (file finding)
132
- - Grep (exact text)
133
-
134
- Tier 2 (Moderate cost):
135
- - SemanticSearch (conceptual)
136
- - StrReplace (edits)
137
- - Write (new files)
138
-
139
- Tier 3 (Higher cost):
140
- - Task (subagents)
141
- - Shell (command execution)
142
- - ReadLints (analysis)
143
-
144
- Tier 4 (Most expensive):
145
- - Multiple parallel subagents
146
- - Browser automation (MCP)
147
- - Complex multi-tool workflows
148
- ```
149
-
150
- ## Tool Combinations
151
-
152
- ### Common Patterns
153
-
154
- **Pattern 1: Feature Implementation**
155
- ```
156
- 1. SemanticSearch: Find patterns
157
- 2. Read: Study examples
158
- 3. Write: Create new files
159
- 4. Shell: Run tests
160
- 5. ReadLints: Verify quality
161
- ```
162
-
163
- **Pattern 2: Bug Fix**
164
- ```
165
- 1. Grep: Find related code
166
- 2. Read: Understand issue
167
- 3. StrReplace: Fix code
168
- 4. Shell: Run tests
169
- 5. ReadLints: Check quality
170
- ```
171
-
172
- **Pattern 3: Refactor**
173
- ```
174
- 1. Task (explore): Map all usages
175
- 2. SemanticSearch: Find patterns
176
- 3. Read: Review current code
177
- 4. Checkpoint: Before changes
178
- 5. StrReplace: Incremental changes
179
- 6. Shell: Run tests after each
180
- 7. ReadLints: Verify quality
181
- ```
182
-
183
- **Pattern 4: Code Review**
184
- ```
185
- 1. Glob: Find changed files
186
- 2. Read: Review diffs
187
- 3. ReadLints: Check for issues
188
- 4. Shell: Run tests
189
- 5. AskQuestion: Clarify if needed
190
- ```
191
-
192
- ## Examples
193
-
194
- ### Example 1: Add API Endpoint
195
-
196
- User: "Add /api/products endpoint"
197
-
198
- Tool sequence:
199
- 1. **SemanticSearch**: "Find API route patterns"
200
- - Result: app/api/users/route.ts
201
-
202
- 2. **Read**: Existing route file
203
- - Understand pattern
204
-
205
- 3. **Write**: New route file
206
- - Create app/api/products/route.ts
207
-
208
- 4. **Shell**: Run tests
209
- - Command: npm run test -- products.test.ts
210
-
211
- 5. **ReadLints**: Check for errors
212
- - Verify quality
213
-
214
- **Why these tools**:
215
- - SemanticSearch: Find pattern (conceptual)
216
- - Read: Study example (single file)
217
- - Write: New file (creation)
218
- - Shell: Validate (tests)
219
- - ReadLints: Quality gate
220
-
221
- ### Example 2: Refactor Authentication
222
-
223
- User: "Refactor auth system"
224
-
225
- Tool sequence:
226
- 1. **Task (explore)**: "Find all auth code"
227
- - Parallel: JWT, sessions, OAuth, hashing
228
-
229
- 2. **SemanticSearch**: "Find token validation"
230
- - Result: src/auth/validateToken.ts
231
-
232
- 3. **Read**: Auth files
233
- - Understand current implementation
234
-
235
- 4. **Checkpoint**: Before breaking changes
236
- - Rollback point
237
-
238
- 5. **StrReplace**: Incremental changes
239
- - Small, safe edits
240
-
241
- 6. **Shell**: Run auth tests
242
- - After each change
243
-
244
- 7. **ReadLints**: Verify quality
245
- - Zero new lints
246
-
247
- **Why these tools**:
248
- - Task: Broad exploration (complex)
249
- - SemanticSearch: Specific patterns
250
- - Read: Understanding
251
- - Checkpoint: Safety (risky change)
252
- - StrReplace: Targeted edits
253
- - Shell + ReadLints: Validation
254
-
255
- ### Example 3: Fix Bug
256
-
257
- User: "Fix login bug"
258
-
259
- Tool sequence:
260
- 1. **Grep**: "Find login function"
261
- - Exact text search
262
-
263
- 2. **Read**: Login code
264
- - Understand issue
265
-
266
- 3. **ReadLints**: Check for errors
267
- - Identify problems
268
-
269
- 4. **StrReplace**: Fix code
270
- - Targeted fix
271
-
272
- 5. **Shell**: Run login tests
273
- - Verify fix
274
-
275
- 6. **ReadLints**: Final check
276
- - Quality gate
277
-
278
- **Why these tools**:
279
- - Grep: Exact search (cheap)
280
- - Read: Understanding
281
- - ReadLints: Find issues
282
- - StrReplace: Small fix
283
- - Shell + ReadLints: Validate
284
-
285
- ## Anti-Patterns
286
-
287
- ### ❌ Using Expensive Tools When Cheap Works
288
-
289
- Bad: Task subagent to find single file
290
- Good: Read (know path) or Glob (pattern)
291
-
292
- ### ❌ Using Wrong Tool for Job
293
-
294
- Bad: Grep for conceptual search
295
- Good: SemanticSearch for behavior
296
-
297
- ### ❌ Skipping Validation
298
-
299
- Bad: Edit without ReadLints
300
- Good: Always validate after substantive changes
301
-
302
- ### ❌ No Checkpoints for Risky Changes
303
-
304
- Bad: Refactor without rollback
305
- Good: Checkpoint before breaking changes
306
-
307
- ## Automatic Tool Selection Workflow
308
-
309
- ### Decision Matrix (Automatic, No User Input)
310
-
311
- ```
312
- Task Type → Tool Sequence
313
- ─────────────────────────
314
- "Find [symbol/text]" → Grep → Read
315
- "Find [pattern/concept]" → SemanticSearch → Task (if broad)
316
- "Add [feature]" → Research patterns → Write/StrReplace → ReadLints → Shell
317
- "Fix [bug]" → Grep/SemanticSearch → Read → StrReplace → ReadLints → Shell
318
- "Refactor [X]" → Task (explore) → Checkpoint → StrReplace → ReadLints → Shell
319
- "Test [feature]" → Read existing tests → Write tests → Shell → ReadLints
320
- ```
321
-
322
- ### MCP Server Selection (Automatic)
323
-
324
- ```
325
- User Request → MCP Server
326
- ─────────────────────────
327
- "UI", "visual", "browser" → cursor-ide-browser
328
- "PR", "issue", "github" → user-github
329
- "lint", "quality" → user-ESLint
330
- "how to [library]", "[framework] setup" → user-context7
331
- ```
332
-
333
- ## Tool Escalation Protocol
334
-
335
- **Rule**: Start with Tier 1, escalate only if needed
336
-
337
- ```
338
- Tier 1 (Try First):
339
- - Read: Know exact file path
340
- - Glob: Pattern matching
341
- - Grep: Exact text search
342
-
343
- If Tier 1 fails → Escalate to Tier 2:
344
- - SemanticSearch: Conceptual search
345
- - StrReplace: Small edits
346
- - Write: New files
347
-
348
- If Tier 2 insufficient → Escalate to Tier 3:
349
- - Task: Complex exploration
350
- - Shell: Run commands/tests
351
- - ReadLints: Quality checks
352
-
353
- If Tier 3 inadequate → Escalate to Tier 4:
354
- - Parallel subagents: Multi-angle exploration
355
- - Browser MCP: Visual verification
356
- - Complex workflows: Multi-step automation
357
- ```
358
-
359
- ## Automatic Validation Rules
360
-
361
- **After EVERY Code Change**:
362
- 1. ReadLints on modified files
363
- 2. Fix introduced lints immediately
364
- 3. If tests exist → run relevant tests
365
- 4. Update TodoWrite if tracking
366
-
367
- **Before EVERY Commit**:
368
- 1. Run full test suite
369
- 2. Run linter
370
- 3. Run typecheck
371
- 4. Create checkpoint if breaking change
372
-
373
- ## Examples
374
-
375
- ### Example: Automatic Tool Selection
376
-
377
- User: "Add authentication to checkout"
378
-
379
- Agent automatically selects:
380
- 1. **SemanticSearch**: "How is authentication implemented?" (Tier 2)
381
- 2. **Read**: `@src/auth/validateToken.ts` (Tier 1)
382
- 3. **StrReplace**: Add auth to checkout (Tier 2)
383
- 4. **ReadLints**: Verify quality (Tier 3, automatic)
384
- 5. **Shell**: Run auth tests (Tier 3, automatic)
385
-
386
- ### Example: Automatic MCP Use
387
-
388
- User: "Fix issue #123"
389
-
390
- Agent automatically:
391
- 1. **user-github**: Fetch issue #123
392
- 2. **Grep**: Find related code
393
- 3. **StrReplace**: Implement fix
394
- 4. **user-ESLint**: Check quality
395
- 5. **user-github**: Create PR linking issue
396
-
397
- ---
398
-
399
- ## Troubleshooting
400
-
401
- ### Tool Not Available
402
-
403
- **Problem**: Selected tool not accessible
404
-
405
- **Solutions**:
406
- 1. Check MCP server running
407
- 2. Use alternative tool
408
- 3. Fallback to manual approach
409
-
410
- ### Tool Taking Too Long
411
-
412
- **Problem**: Tool execution slow
413
-
414
- **Solutions**:
415
- 1. Use model="fast" for subagents
416
- 2. Narrow scope (target_directories)
417
- 3. Try cheaper alternative
418
- 4. Time-box execution
419
-
420
- ### Tool Failing Repeatedly
421
-
422
- **Problem**: Tool errors persist
423
-
424
- **Solutions**:
425
- 1. Check parameters
426
- 2. Verify permissions
427
- 3. Try alternative approach
428
- 4. Report blocker
1
+ ---
2
+ name: tool-selection
3
+ description: Decision trees for choosing the cheapest effective Claude Code tool (Read, Glob, Grep, Edit, Bash, Agent, MCP) per step. Use when planning steps or tool usage feels expensive.
4
+ ---
5
+
6
+ # SKILL.md: Optimal Tool Selection
7
+
8
+ ## Description
9
+ Automatically select best tools for each plan step based on task type, complexity, and available resources.
10
+
11
+ ## When to Use
12
+ - Creating implementation plans
13
+ - Deciding which tools to use
14
+ - Optimizing workflow efficiency
15
+ - Troubleshooting tool failures
16
+
17
+ ## Capabilities
18
+ - Tool selection decision tree
19
+ - Cost/complexity analysis
20
+ - Fallback tool identification
21
+ - Tool combination strategies
22
+
23
+ ## Tool Selection Rules
24
+
25
+ ### For Exploration
26
+
27
+ | Goal | Tool | When |
28
+ |------|------|------|
29
+ | Read single file | Read | Know exact path |
30
+ | Find multiple files | Glob + Read | Pattern matching |
31
+ | Exact text search | Grep | Specific strings/symbols |
32
+ | Conceptual search | Explore (quick) | Behavior/pattern |
33
+ | Broad exploration | Agent (Explore) | Multi-file investigation |
34
+
35
+ ### For Implementation
36
+
37
+ | Goal | Tool | When |
38
+ |------|------|------|
39
+ | New file | Write | Creating from scratch |
40
+ | Small edit (<50 lines) | Edit | Targeted changes |
41
+ | Large rewrite (>50 lines) | Write | Replace entire file |
42
+ | Jupyter notebook | NotebookEdit | Cell-level edits |
43
+
44
+ ### For Validation
45
+
46
+ | Goal | Tool | When |
47
+ |------|------|------|
48
+ | Code quality | Lint check | After edits |
49
+ | Functionality | Bash (tests) | Run test suite |
50
+ | Visual changes | Browser/Screenshot | UI verification |
51
+ | User feedback | AskUserQuestion | Decisions needed |
52
+
53
+ ### For Complex Tasks
54
+
55
+ | Goal | Tool | When |
56
+ |------|------|------|
57
+ | Multi-step tracking | TodoWrite | 3+ steps |
58
+ | Ambiguous requirements | AskUserQuestion | Clarification needed |
59
+ | Risky changes | Checkpoints | Before breaking changes |
60
+ | Iterative fixes | fix-and-retest loop | Tests failing |
61
+
62
+ ## Decision Trees
63
+
64
+ ### "I need to find code"
65
+
66
+ ```
67
+ Know file path?
68
+ ├─ Yes → Read
69
+ └─ No
70
+ ├─ Exact text/symbol?
71
+ │ ├─ Yes → Grep
72
+ │ └─ No
73
+ │ ├─ Concept/behavior?
74
+ │ │ ├─ Yes → Explore (quick)
75
+ │ │ └─ No
76
+ │ └─ Broad exploration?
77
+ │ ├─ Yes → Agent (Explore)
78
+ │ └─ No → Glob
79
+ ```
80
+
81
+ ### "I need to modify code"
82
+
83
+ ```
84
+ Jupyter notebook?
85
+ ├─ Yes → NotebookEdit
86
+ └─ No
87
+ ├─ New file?
88
+ │ ├─ Yes → Write
89
+ │ └─ No
90
+ │ ├─ <50 lines change?
91
+ │ │ ├─ Yes → Edit
92
+ │ │ └─ No → Write (replace entire file)
93
+ ```
94
+
95
+ ### "I need to verify"
96
+
97
+ ```
98
+ Linting issues?
99
+ ├─ Yes → Lint check
100
+ └─ No
101
+ ├─ Tests needed?
102
+ │ ├─ Yes → Bash (npm run test)
103
+ │ └─ No
104
+ │ ├─ Visual changes?
105
+ │ │ ├─ Yes → Browser/Screenshot
106
+ │ │ └─ No
107
+ │ └─ User approval?
108
+ │ ├─ Yes → AskUserQuestion
109
+ │ └─ No → Continue
110
+ ```
111
+
112
+ ### "I need to automate browser"
113
+
114
+ ```
115
+ Need performance profiling?
116
+ ├─ Yes → chrome-devtools (performance traces)
117
+ └─ No
118
+ ├─ Need Lighthouse audits?
119
+ │ ├─ Yes → chrome-devtools
120
+ │ └─ No
121
+ │ ├─ Need cross-browser testing?
122
+ │ │ ├─ Yes → playwright
123
+ │ │ └─ No
124
+ │ └─ Quick testing?
125
+ │ ├─ Yes → claude-in-chrome (`/chrome`)
126
+ │ └─ No → selenium (accessibility)
127
+ ```
128
+
129
+ ## Tool Cost Hierarchy
130
+
131
+ **Start cheap, escalate as needed:**
132
+
133
+ ```
134
+ Tier 1 (Cheapest, fastest):
135
+ - Read (single file)
136
+ - Glob (file finding)
137
+ - Grep (exact text)
138
+
139
+ Tier 2 (Moderate cost):
140
+ - Explore (quick) (conceptual)
141
+ - Edit (edits)
142
+ - Write (new files)
143
+
144
+ Tier 3 (Higher cost):
145
+ - Agent (subagents)
146
+ - Bash (command execution)
147
+ - Lint check (analysis)
148
+
149
+ Tier 4 (Most expensive):
150
+ - Multiple parallel subagents
151
+ - Browser automation (MCP)
152
+ - Complex multi-tool workflows
153
+ ```
154
+
155
+ ## Tool Combinations
156
+
157
+ ### Common Patterns
158
+
159
+ **Pattern 1: Feature Implementation**
160
+ ```
161
+ 1. Explore (quick): Find patterns
162
+ 2. Read: Study examples
163
+ 3. Write: Create new files
164
+ 4. Bash: Run tests
165
+ 5. Lint check: Verify quality
166
+ ```
167
+
168
+ **Pattern 2: Bug Fix**
169
+ ```
170
+ 1. Grep: Find related code
171
+ 2. Read: Understand issue
172
+ 3. Edit: Fix code
173
+ 4. Bash: Run tests
174
+ 5. Lint check: Check quality
175
+ ```
176
+
177
+ **Pattern 3: Refactor**
178
+ ```
179
+ 1. Agent (Explore): Map all usages
180
+ 2. Explore (quick): Find patterns
181
+ 3. Read: Review current code
182
+ 4. Checkpoint: Before changes
183
+ 5. Edit: Incremental changes
184
+ 6. Bash: Run tests after each
185
+ 7. Lint check: Verify quality
186
+ ```
187
+
188
+ **Pattern 4: Code Review**
189
+ ```
190
+ 1. Glob: Find changed files
191
+ 2. Read: Review diffs
192
+ 3. Lint check: Check for issues
193
+ 4. Bash: Run tests
194
+ 5. AskUserQuestion: Clarify if needed
195
+ ```
196
+
197
+ ## Examples
198
+
199
+ ### Example 1: Add API Endpoint
200
+
201
+ User: "Add /api/products endpoint"
202
+
203
+ Tool sequence:
204
+ 1. **Explore (quick)**: "Find API route patterns"
205
+ - Result: app/api/users/route.ts
206
+
207
+ 2. **Read**: Existing route file
208
+ - Understand pattern
209
+
210
+ 3. **Write**: New route file
211
+ - Create app/api/products/route.ts
212
+
213
+ 4. **Bash**: Run tests
214
+ - Command: npm run test -- products.test.ts
215
+
216
+ 5. **Lint check**: Check for errors
217
+ - Verify quality
218
+
219
+ **Why these tools**:
220
+ - Explore (quick): Find pattern (conceptual)
221
+ - Read: Study example (single file)
222
+ - Write: New file (creation)
223
+ - Bash: Validate (tests)
224
+ - Lint check: Quality gate
225
+
226
+ ### Example 2: Refactor Authentication
227
+
228
+ User: "Refactor auth system"
229
+
230
+ Tool sequence:
231
+ 1. **Agent (Explore)**: "Find all auth code"
232
+ - Parallel: JWT, sessions, OAuth, hashing
233
+
234
+ 2. **Explore (quick)**: "Find token validation"
235
+ - Result: src/auth/validateToken.ts
236
+
237
+ 3. **Read**: Auth files
238
+ - Understand current implementation
239
+
240
+ 4. **Checkpoint**: Before breaking changes
241
+ - Rollback point
242
+
243
+ 5. **Edit**: Incremental changes
244
+ - Small, safe edits
245
+
246
+ 6. **Bash**: Run auth tests
247
+ - After each change
248
+
249
+ 7. **Lint check**: Verify quality
250
+ - Zero new lints
251
+
252
+ **Why these tools**:
253
+ - Agent: Broad exploration (complex)
254
+ - Explore (quick): Specific patterns
255
+ - Read: Understanding
256
+ - Checkpoint: Safety (risky change)
257
+ - Edit: Targeted edits
258
+ - Bash + Lint check: Validation
259
+
260
+ ### Example 3: Fix Bug
261
+
262
+ User: "Fix login bug"
263
+
264
+ Tool sequence:
265
+ 1. **Grep**: "Find login function"
266
+ - Exact text search
267
+
268
+ 2. **Read**: Login code
269
+ - Understand issue
270
+
271
+ 3. **Lint check**: Check for errors
272
+ - Identify problems
273
+
274
+ 4. **Edit**: Fix code
275
+ - Targeted fix
276
+
277
+ 5. **Bash**: Run login tests
278
+ - Verify fix
279
+
280
+ 6. **Lint check**: Final check
281
+ - Quality gate
282
+
283
+ **Why these tools**:
284
+ - Grep: Exact search (cheap)
285
+ - Read: Understanding
286
+ - Lint check: Find issues
287
+ - Edit: Small fix
288
+ - Bash + Lint check: Validate
289
+
290
+ ## Anti-Patterns
291
+
292
+ ### ❌ Using Expensive Tools When Cheap Works
293
+
294
+ Bad: Agent subagent to find single file
295
+ Good: Read (know path) or Glob (pattern)
296
+
297
+ ### ❌ Using Wrong Tool for Job
298
+
299
+ Bad: Grep for conceptual search
300
+ Good: Explore (quick) for behavior
301
+
302
+ ### ❌ Skipping Validation
303
+
304
+ Bad: Edit without Lint check
305
+ Good: Always validate after substantive changes
306
+
307
+ ### ❌ No Checkpoints for Risky Changes
308
+
309
+ Bad: Refactor without rollback
310
+ Good: Checkpoint before breaking changes
311
+
312
+ ## Automatic Tool Selection Workflow
313
+
314
+ ### Decision Matrix (Automatic, No User Input)
315
+
316
+ ```
317
+ Task Type → Tool Sequence
318
+ ─────────────────────────
319
+ "Find [symbol/text]" → Grep → Read
320
+ "Find [pattern/concept]" → Explore (quick) → Agent (if broad)
321
+ "Add [feature]" → Research patterns → Write/Edit → Lint check → Bash
322
+ "Fix [bug]" → Grep/Explore (quick) → Read → Edit → Lint check → Bash
323
+ "Refactor [X]" → Agent (Explore) → Checkpoint → Edit → Lint check → Bash
324
+ "Test [feature]" → Read existing tests → Write tests → Bash → Lint check
325
+ ```
326
+
327
+ ### MCP Server Selection (Automatic)
328
+
329
+ ```
330
+ User Request → MCP Server
331
+ ─────────────────────────
332
+ "UI", "visual", "browser" → claude-in-chrome
333
+ "PR", "issue", "github" → github
334
+ "lint", "quality" → eslint
335
+ "how to [library]", "[framework] setup" → context7
336
+ ```
337
+
338
+ ## Tool Escalation Protocol
339
+
340
+ **Rule**: Start with Tier 1, escalate only if needed
341
+
342
+ ```
343
+ Tier 1 (Try First):
344
+ - Read: Know exact file path
345
+ - Glob: Pattern matching
346
+ - Grep: Exact text search
347
+
348
+ If Tier 1 fails → Escalate to Tier 2:
349
+ - Explore (quick): Conceptual search
350
+ - Edit: Small edits
351
+ - Write: New files
352
+
353
+ If Tier 2 insufficient → Escalate to Tier 3:
354
+ - Agent: Complex exploration
355
+ - Bash: Run commands/tests
356
+ - Lint check: Quality checks
357
+
358
+ If Tier 3 inadequate → Escalate to Tier 4:
359
+ - Parallel subagents: Multi-angle exploration
360
+ - Browser MCP: Visual verification
361
+ - Complex workflows: Multi-step automation
362
+ ```
363
+
364
+ ## Automatic Validation Rules
365
+
366
+ **After EVERY Code Change**:
367
+ 1. Lint check on modified files
368
+ 2. Fix introduced lints immediately
369
+ 3. If tests exist → run relevant tests
370
+ 4. Update TodoWrite if tracking
371
+
372
+ **Before EVERY Commit**:
373
+ 1. Run full test suite
374
+ 2. Run linter
375
+ 3. Run typecheck
376
+ 4. Create checkpoint if breaking change
377
+
378
+ ## Examples
379
+
380
+ ### Example: Automatic Tool Selection
381
+
382
+ User: "Add authentication to checkout"
383
+
384
+ Agent automatically selects:
385
+ 1. **Explore (quick)**: "How is authentication implemented?" (Tier 2)
386
+ 2. **Read**: `@src/auth/validateToken.ts` (Tier 1)
387
+ 3. **Edit**: Add auth to checkout (Tier 2)
388
+ 4. **Lint check**: Verify quality (Tier 3, automatic)
389
+ 5. **Bash**: Run auth tests (Tier 3, automatic)
390
+
391
+ ### Example: Automatic MCP Use
392
+
393
+ User: "Fix issue #123"
394
+
395
+ Agent automatically:
396
+ 1. **github**: Fetch issue #123
397
+ 2. **Grep**: Find related code
398
+ 3. **Edit**: Implement fix
399
+ 4. **eslint**: Check quality
400
+ 5. **github**: Create PR linking issue
401
+
402
+ ---
403
+
404
+ ## Troubleshooting
405
+
406
+ ### Tool Not Available
407
+
408
+ **Problem**: Selected tool not accessible
409
+
410
+ **Solutions**:
411
+ 1. Check MCP server running
412
+ 2. Use alternative tool
413
+ 3. Fallback to manual approach
414
+
415
+ ### Tool Taking Too Long
416
+
417
+ **Problem**: Tool execution slow
418
+
419
+ **Solutions**:
420
+ 1. Use model="haiku" for subagents
421
+ 2. Narrow scope (target_directories)
422
+ 3. Try cheaper alternative
423
+ 4. Time-box execution
424
+
425
+ ### Tool Failing Repeatedly
426
+
427
+ **Problem**: Tool errors persist
428
+
429
+ **Solutions**:
430
+ 1. Check parameters
431
+ 2. Verify permissions
432
+ 3. Try alternative approach
433
+ 4. Report blocker