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,428 +1,433 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
│
|
|
72
|
-
│
|
|
73
|
-
│
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
│
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
│
|
|
120
|
-
│
|
|
121
|
-
│
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Tier
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
Tier
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
|
|
144
|
-
Tier
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
4
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
1
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
### ❌ Using
|
|
293
|
-
|
|
294
|
-
Bad:
|
|
295
|
-
Good:
|
|
296
|
-
|
|
297
|
-
### ❌
|
|
298
|
-
|
|
299
|
-
Bad:
|
|
300
|
-
Good:
|
|
301
|
-
|
|
302
|
-
### ❌
|
|
303
|
-
|
|
304
|
-
Bad:
|
|
305
|
-
Good:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
"
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
-
|
|
345
|
-
-
|
|
346
|
-
-
|
|
347
|
-
|
|
348
|
-
If Tier
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
-
|
|
352
|
-
|
|
353
|
-
If Tier
|
|
354
|
-
-
|
|
355
|
-
-
|
|
356
|
-
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
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
|