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,399 +1,420 @@
1
- # SKILL.md: Debug Mode Optimizer
2
-
3
- ## Description
4
- Automatic optimization of debug mode workflows for maximum efficiency. Activates automatically in debug mode to coordinate tools, MCPs, skills, hooks, and rules.
5
-
6
- ## When to Use (Automatic Activation)
7
- **This skill activates AUTOMATICALLY in debug mode for ALL tasks.**
8
-
9
- **Purpose**: Coordinate all optimization mechanisms to minimize task completion time and token usage while maximizing quality.
10
-
11
- ---
12
-
13
- ## Automatic Optimizations
14
-
15
- ### 1. Tool Selection Optimization
16
- **Automatic Triggers**:
17
- ```
18
- Task analysis → Select optimal tools based on:
19
- - Task type (exploration, implementation, validation)
20
- - Complexity (number of files, steps)
21
- - Required precision (exact vs conceptual)
22
- - Cost hierarchy (Tier 1 → Tier 4)
23
- ```
24
-
25
- **Optimization Rules**:
26
- ```
27
- ✓ ALWAYS start with Tier 1 tools (Read, Glob, Grep)
28
- ✓ Escalate one tier at a time only if needed
29
- ✓ NEVER use expensive tools when cheap tools work
30
- ✓ Track tool effectiveness for future optimization
31
- ```
32
-
33
- ---
34
-
35
- ### 2. MCP Server Optimization
36
- **Automatic Triggers**:
37
- ```
38
- File patterns + Keywords + Task type → Select optimal MCPs:
39
- - components/**, "UI" → cursor-ide-browser
40
- - __tests__/**, "E2E" → user-playwright
41
- - "PR", "issue" → user-github
42
- - "lint" → user-ESLint
43
- - "docs", "how to" → user-context7
44
- - "performance" → user-chrome-devtools
45
- ```
46
-
47
- **Optimization Rules**:
48
- ```
49
- ✓ ALWAYS run user-ESLint after code changes (cheap, high value)
50
- ✓ ALWAYS fetch user-context7 before library implementation (prevents errors)
51
- ✓ Use cursor-ide-browser ONLY when visual verification essential
52
- ✓ Chain MCPs automatically for complex workflows
53
- ✓ Track MCP usage and cost for optimization
54
- ```
55
-
56
- ---
57
-
58
- ### 3. Parallel Subagent Optimization
59
- **Automatic Triggers**:
60
- ```
61
- Task complexity analysis → Launch parallel subagents:
62
- - >3 areas mentioned → Launch 4 subagents
63
- - >10 steps → Launch 3 subagents
64
- - Bug investigation → Launch 4 subagents
65
- - Large refactor (>5 files) → Launch 4 subagents
66
- ```
67
-
68
- **Configuration** (Automatic):
69
- ```yaml
70
- model: "fast" # Cost optimization
71
- readonly: true # Safety
72
- run_in_background: true # Non-blocking
73
- timeout: 120s # Time-box per subagent
74
- max_parallel: 4 # Diminishing returns after 4
75
- ```
76
-
77
- ---
78
-
79
- ### 4. Context Engineering Optimization
80
- **Automatic Triggers**:
81
- ```
82
- Task keywords + File patterns → Load relevant Tier 2 context:
83
- - "test" → Testing context
84
- - "API" → API development context
85
- - "UI", "component" → UI/Styling context
86
- - "performance" → Performance context
87
- - "database" → Database context
88
- - "security" → Security context
89
- ```
90
-
91
- **Optimization Rules**:
92
- ```
93
- ✓ Load ONLY relevant context (avoid over-specification)
94
- ✓ Use Tier 1 (minimal) + Tier 2 (task-specific) injection
95
- ✓ Prune context after task completion
96
- ✓ Agent discovers details via search tools (not context)
97
- ```
98
-
99
- ---
100
-
101
- ### 5. Hook-Based Validation Optimization
102
- **Automatic Triggers**:
103
- ```
104
- After code changes (after_code_change hook):
105
- - auto-lint-fix → Fix lint issues first
106
- - auto-validate → Unified validation (lint + typecheck + tests + MCP)
107
-
108
- After plan mode (plan_mode_exit hook):
109
- - plan-quality-tracker → Track metrics and provide feedback
110
- ```
111
-
112
- **Validation Pipeline** (Automatic):
113
- ```
114
- 1. Code change detected
115
- 2. after_code_change hook triggers
116
- 3. auto-lint-fix: Run ESLint, auto-fix
117
- 4. auto-validate:
118
- - Lint check
119
- - Typecheck
120
- - Run tests
121
- - Validate MCP tools
122
- 5. Report results to user
123
- ```
124
-
125
- ---
126
-
127
- ## Debug-Specific Workflows
128
-
129
- ### Workflow 1: Feature Implementation (Optimized)
130
- ```
131
- User: "Add user authentication with JWT"
132
-
133
- Automatic Optimizations:
134
- 1. **Parallel Exploration** (4 subagents, 60s):
135
- - Find auth patterns
136
- - Find JWT libraries
137
- - Find existing auth code
138
- - Find auth tests
139
-
140
- 2. **Context Loading** (Tier 2):
141
- - Security context
142
- - API context
143
-
144
- 3. **MCP Chain**:
145
- - user-context7: Fetch JWT library docs
146
- - Implement feature
147
- - user-ESLint: Auto-lint
148
- - user-github: Create PR
149
-
150
- 4. **Validation Hooks**:
151
- - auto-lint-fix: Fix issues
152
- - auto-validate: Unified validation (includes MCP validation + tests)
153
-
154
- Time: 5-7 minutes (vs 15-20 manual)
155
- ```
156
-
157
- ---
158
-
159
- ### Workflow 2: Bug Fix (Optimized)
160
- ```
161
- User: "Fix checkout bug #456"
162
-
163
- Automatic Optimizations:
164
- 1. **Parallel Exploration** (4 subagents, 90s):
165
- - Find checkout code
166
- - Find payment code
167
- - Find recent changes
168
- - Find similar issues
169
-
170
- 2. **Context Loading** (Tier 2):
171
- - API context (if API-related)
172
- - Database context (if DB-related)
173
-
174
- 3. **MCP Chain**:
175
- - user-github: Fetch issue #456
176
- - user-context7: Check payment docs (if needed)
177
- - Implement fix
178
- - user-ESLint: Auto-lint
179
- - user-github: Create PR
180
-
181
- 4. **Validation Hooks**:
182
- - auto-lint-fix: Fix issues
183
- - auto-validate: Unified validation (includes MCP validation + tests)
184
-
185
- Time: 3-5 minutes (vs 10-15 manual)
186
- ```
187
-
188
- ---
189
-
190
- ### Workflow 3: Large Refactor (Optimized)
191
- ```
192
- User: "Migrate from Prisma to Drizzle"
193
-
194
- Automatic Optimizations:
195
- 1. **Parallel Exploration** (4 subagents, 120s):
196
- - Find all Prisma usage
197
- - Find all queries
198
- - Find all migrations
199
- - Find all tests
200
-
201
- 2. **Context Loading** (Tier 2):
202
- - Database context
203
- - Testing context
204
-
205
- 3. **MCP Chain**:
206
- - user-context7: Fetch Drizzle docs
207
- - Implement migration (incremental)
208
- - user-ESLint: Auto-lint after each change
209
- - test-runner: Run tests after each change
210
-
211
- 4. **Validation Hooks** (after each step):
212
- - auto-lint-fix: Fix issues
213
- - auto-validate: Run unified validation (includes tests)
214
-
215
- Time: 20-30 minutes (vs 60-90 manual)
216
- ```
217
-
218
- ---
219
-
220
- ## Error Pattern Recognition
221
-
222
- ### Automatic Error Detection
223
- ```
224
- Monitor for error patterns:
225
- - ESLint errors → Trigger auto-lint-fix
226
- - Test failures → Trigger auto-validate with debug mode
227
- - Build errors → Fetch build docs via user-context7
228
- - Runtime errors → Trigger browser debugging
229
- ```
230
-
231
- ### Automatic Recovery
232
- ```
233
- Error detected → Automatic response:
234
- 1. Identify error type
235
- 2. Fetch relevant docs (user-context7)
236
- 3. Implement fix
237
- 4. Validate (lint + tests)
238
- 5. If still failing → Escalate to human
239
- ```
240
-
241
- ---
242
-
243
- ## Performance Metrics (Automatic Tracking)
244
-
245
- ### Track Per Task
246
- ```
247
- - Task completion time
248
- - Token consumption
249
- - Tool calls count
250
- - MCP calls count
251
- - Validation gate pass rate
252
- - User satisfaction (manual rating)
253
- ```
254
-
255
- ### Weekly Optimization Review
256
- ```
257
- Analyze metrics:
258
- - Which optimizations saved most time?
259
- - Which tools/MCPs most effective?
260
- - Where are bottlenecks?
261
- - What can be further automated?
262
- - Adjust rules and triggers accordingly
263
- ```
264
-
265
- ---
266
-
267
- ## Cost Optimization (Enforced)
268
-
269
- ### Token Budget Allocation
270
- ```
271
- Tier 1 tools (Read, Glob, Grep): 40% of budget
272
- Tier 2 tools (SemanticSearch, StrReplace): 30% of budget
273
- Tier 3 tools (Task, Shell, ReadLints): 20% of budget
274
- Tier 4 tools (Parallel subagents, Browser MCP): 10% of budget
275
- ```
276
-
277
- ### Automatic Cost Control
278
- ```
279
- If task exceeds budget:
280
- 1. Warn user
281
- 2. Suggest scope reduction
282
- 3. Offer to continue with approval
283
- ```
284
-
285
- ---
286
-
287
- ## Examples
288
-
289
- ### Example 1: Add Dark Mode (Optimized)
290
- User: "Add dark mode toggle to settings page"
291
-
292
- **Automatic Optimizations**:
293
- ```
294
- 1. Parallel subagents (2, 45s):
295
- - "Find settings page structure"
296
- - "Find Tailwind dark mode examples"
297
-
298
- 2. Context loaded: UI/Styling
299
-
300
- 3. MCP chain:
301
- - user-context7: Tailwind dark mode docs
302
- - cursor-ide-browser: Verify UI
303
- - user-ESLint: Auto-lint
304
-
305
- 4. Hooks:
306
- - auto-lint-fix: ✅ Passed
307
- - auto-validate: ✅ All validations passed
308
-
309
- Result: 4 minutes, 100% quality gates pass
310
- ```
311
-
312
- ---
313
-
314
- ### Example 2: Performance Audit (Optimized)
315
- User: "Audit and improve dashboard performance"
316
-
317
- **Automatic Optimizations**:
318
- ```
319
- 1. Parallel subagents (3, 90s):
320
- - "Find dashboard code"
321
- - "Find performance bottlenecks"
322
- - "Find optimization patterns"
323
-
324
- 2. Context loaded: Performance
325
-
326
- 3. MCP chain:
327
- - user-chrome-devtools: Lighthouse audit
328
- - cursor-ide-browser: CPU profiling
329
- - user-context7: React optimization docs
330
- - Implement optimizations
331
- - user-chrome-devtools: Re-audit
332
-
333
- 4. Hooks:
334
- - auto-validate: ✅ All validations passed (MCP + tests)
335
-
336
- Result: 8 minutes, Lighthouse score 92 (from 67)
337
- ```
338
-
339
- ---
340
-
341
- ### Example 3: Security Review (Optimized)
342
- User: "Review authentication for vulnerabilities"
343
-
344
- **Automatic Optimizations**:
345
- ```
346
- 1. Parallel subagents (4, 90s):
347
- - "Find auth code"
348
- - "Find token validation"
349
- - "Find password handling"
350
- - "Find input validation"
351
-
352
- 2. Context loaded: Security
353
-
354
- 3. MCP chain:
355
- - user-context7: OWASP auth guidelines
356
- - Implement security fixes
357
- - user-ESLint: Auto-lint
358
- - test-runner: Run security tests
359
-
360
- 4. Hooks:
361
- - auto-lint-fix: ✅ Fixed 3 issues
362
- - test-runner: ✅ All tests pass
363
-
364
- Result: 6 minutes, 5 vulnerabilities fixed
365
- ```
366
-
367
- ---
368
-
369
- ## Anti-Patterns (Automatically Avoided)
370
-
371
- ### ❌ Over-Automation
372
- **Prevention**: Start with minimal automation, add only when pain points observed
373
-
374
- ### ❌ Context Bloat
375
- **Prevention**: Enforce 20-line max per context file, use references over content
376
-
377
- ### ❌ MCP Cost Explosion
378
- **Prevention**: Cost-awareness rules, prefer cheaper tools first, track usage
379
-
380
- ### ❌ Hook Failures Blocking Progress
381
- **Prevention**: Hooks exit gracefully, agent continues if hooks fail
382
-
383
- ---
384
-
385
- ## Integration with Other Skills
386
-
387
- ### Works with:
388
- - **mcp-mastery**: Coordinates MCP selection
389
- - **tool-selection**: Optimizes tool choices
390
- - **parallel-exploration**: Launches subagents efficiently
391
-
392
- ### Coordinates with:
393
- - **Rules**: Enforces tool-auto-selection, parallel-exploration-auto, context tiers
394
- - **Hooks**: Triggers validation pipeline
395
- - **MCPs**: Chains multiple servers for complex workflows
396
-
397
- ---
398
-
399
- **Note**: This skill activates automatically in debug mode. No manual intervention needed. All optimizations applied transparently to maximize efficiency.
1
+ ---
2
+ name: debug-optimizer
3
+ description: Coordinate tools, MCP servers, subagents and validation hooks for debugging and multi-step tasks. Use when investigating a bug, a failing test, or a task spanning many files.
4
+ ---
5
+
6
+ # SKILL.md: Debug Optimizer
7
+
8
+ ## Description
9
+ Automatic optimization of debugging and multi-step workflows for maximum efficiency. Coordinates tools, MCPs, skills, hooks, and rules.
10
+
11
+ ## When to Use (Automatic Activation)
12
+ **This skill activates AUTOMATICALLY for debugging and multi-step tasks.**
13
+
14
+ **Purpose**: Coordinate all optimization mechanisms to minimize task completion time and token usage while maximizing quality.
15
+
16
+ ---
17
+
18
+ ## Root Cause Debugging Protocol
19
+
20
+ 1. **Reproduce & Isolate:** Recreate the exact failure with a minimal reproduction or a single targeted test.
21
+ 2. **Inspect & Trace:** Read actual runtime logs, stack traces, and variable state instead of guessing.
22
+ 3. **Hypothesize & Form Minimal Fix:** Identify the root mechanism of the failure. Make the smallest diff that fully fixes it.
23
+ 4. **Regression Prevention:** Add a targeted regression test proving the bug is gone and adjacent modules still work.
24
+
25
+ **Never**:
26
+ - ❌ Wrap code in `try-catch` without handling or logging the error
27
+ - ❌ Silence TypeScript errors with `@ts-ignore` or `as any`
28
+ - ❌ Write sprawling test fixtures when a focused unit test suffices
29
+
30
+ ---
31
+
32
+ ## Automatic Optimizations
33
+
34
+ ### 1. Tool Selection Optimization
35
+ **Automatic Triggers**:
36
+ ```
37
+ Task analysis → Select optimal tools based on:
38
+ - Task type (exploration, implementation, validation)
39
+ - Complexity (number of files, steps)
40
+ - Required precision (exact vs conceptual)
41
+ - Cost hierarchy (Tier 1 → Tier 4)
42
+ ```
43
+
44
+ **Optimization Rules**:
45
+ ```
46
+ ✓ ALWAYS start with Tier 1 tools (Read, Glob, Grep)
47
+ ✓ Escalate one tier at a time only if needed
48
+ ✓ NEVER use expensive tools when cheap tools work
49
+ ✓ Track tool effectiveness for future optimization
50
+ ```
51
+
52
+ ---
53
+
54
+ ### 2. MCP Server Optimization
55
+ **Automatic Triggers**:
56
+ ```
57
+ File patterns + Keywords + Task type → Select optimal MCPs:
58
+ - components/**, "UI" → claude-in-chrome
59
+ - __tests__/**, "E2E" → playwright
60
+ - "PR", "issue" → github
61
+ - "lint" → eslint
62
+ - "docs", "how to" → context7
63
+ - "performance" → chrome-devtools
64
+ ```
65
+
66
+ **Optimization Rules**:
67
+ ```
68
+ ✓ ALWAYS run eslint after code changes (cheap, high value)
69
+ ✓ ALWAYS fetch context7 before library implementation (prevents errors)
70
+ ✓ Use claude-in-chrome ONLY when visual verification essential
71
+ ✓ Chain MCPs automatically for complex workflows
72
+ ✓ Track MCP usage and cost for optimization
73
+ ```
74
+
75
+ ---
76
+
77
+ ### 3. Parallel Subagent Optimization
78
+ **Automatic Triggers**:
79
+ ```
80
+ Task complexity analysis → Launch parallel subagents:
81
+ - >3 areas mentioned → Launch 4 subagents
82
+ - >10 steps → Launch 3 subagents
83
+ - Bug investigation → Launch 4 subagents
84
+ - Large refactor (>5 files) → Launch 4 subagents
85
+ ```
86
+
87
+ **Configuration** (Automatic):
88
+ ```yaml
89
+ model: "haiku" # Cost optimization
90
+ run_in_background: true # Non-blocking
91
+ timeout: 120s # Time-box per subagent
92
+ max_parallel: 4 # Diminishing returns after 4
93
+ ```
94
+
95
+ ---
96
+
97
+ ### 4. Context Engineering Optimization
98
+ **Automatic Triggers**:
99
+ ```
100
+ Task keywords + File patterns → Load relevant Tier 2 context:
101
+ - "test" → Testing context
102
+ - "API" → API development context
103
+ - "UI", "component" → UI/Styling context
104
+ - "performance" → Performance context
105
+ - "database" → Database context
106
+ - "security" → Security context
107
+ ```
108
+
109
+ **Optimization Rules**:
110
+ ```
111
+ ✓ Load ONLY relevant context (avoid over-specification)
112
+ ✓ Use Tier 1 (minimal) + Tier 2 (task-specific) injection
113
+ ✓ Prune context after task completion
114
+ ✓ Agent discovers details via search tools (not context)
115
+ ```
116
+
117
+ ---
118
+
119
+ ### 5. Hook-Based Validation Optimization
120
+ **Automatic Triggers**:
121
+ ```
122
+ After each Edit/Write (PostToolUse hook):
123
+ - auto-lint-fix → Fix lint issues in the edited file
124
+
125
+ When Claude finishes a response (Stop hook):
126
+ - auto-validate → Unified validation (lint + typecheck + tests + MCP)
127
+ - auto-security-review → Scan written code for vulnerabilities
128
+ - plan-quality-tracker → Track metrics and provide feedback
129
+
130
+ At session start (SessionStart hook):
131
+ - auto-learning-review → Weekly learning report from plan metrics
132
+ ```
133
+
134
+ **Validation Pipeline** (Automatic):
135
+ ```
136
+ 1. Edit/Write → PostToolUse hook → auto-lint-fix (ESLint --fix on that file)
137
+ 2. Claude tries to stop → Stop hook → auto-validate:
138
+ - Lint check
139
+ - Typecheck
140
+ - Run tests
141
+ - Validate MCP tools
142
+ 3. Failures block the stop and are sent back to Claude to fix
143
+ 4. Report results to user
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Debug-Specific Workflows
149
+
150
+ ### Workflow 1: Feature Implementation (Optimized)
151
+ ```
152
+ User: "Add user authentication with JWT"
153
+
154
+ Automatic Optimizations:
155
+ 1. **Parallel Exploration** (4 subagents, 60s):
156
+ - Find auth patterns
157
+ - Find JWT libraries
158
+ - Find existing auth code
159
+ - Find auth tests
160
+
161
+ 2. **Context Loading** (Tier 2):
162
+ - Security context
163
+ - API context
164
+
165
+ 3. **MCP Chain**:
166
+ - context7: Fetch JWT library docs
167
+ - Implement feature
168
+ - eslint: Auto-lint
169
+ - github: Create PR
170
+
171
+ 4. **Validation Hooks**:
172
+ - auto-lint-fix: Fix issues
173
+ - auto-validate: Unified validation (includes MCP validation + tests)
174
+
175
+ Time: 5-7 minutes (vs 15-20 manual)
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Workflow 2: Bug Fix (Optimized)
181
+ ```
182
+ User: "Fix checkout bug #456"
183
+
184
+ Automatic Optimizations:
185
+ 1. **Parallel Exploration** (4 subagents, 90s):
186
+ - Find checkout code
187
+ - Find payment code
188
+ - Find recent changes
189
+ - Find similar issues
190
+
191
+ 2. **Context Loading** (Tier 2):
192
+ - API context (if API-related)
193
+ - Database context (if DB-related)
194
+
195
+ 3. **MCP Chain**:
196
+ - github: Fetch issue #456
197
+ - context7: Check payment docs (if needed)
198
+ - Implement fix
199
+ - eslint: Auto-lint
200
+ - github: Create PR
201
+
202
+ 4. **Validation Hooks**:
203
+ - auto-lint-fix: Fix issues
204
+ - auto-validate: Unified validation (includes MCP validation + tests)
205
+
206
+ Time: 3-5 minutes (vs 10-15 manual)
207
+ ```
208
+
209
+ ---
210
+
211
+ ### Workflow 3: Large Refactor (Optimized)
212
+ ```
213
+ User: "Migrate from Prisma to Drizzle"
214
+
215
+ Automatic Optimizations:
216
+ 1. **Parallel Exploration** (4 subagents, 120s):
217
+ - Find all Prisma usage
218
+ - Find all queries
219
+ - Find all migrations
220
+ - Find all tests
221
+
222
+ 2. **Context Loading** (Tier 2):
223
+ - Database context
224
+ - Testing context
225
+
226
+ 3. **MCP Chain**:
227
+ - context7: Fetch Drizzle docs
228
+ - Implement migration (incremental)
229
+ - eslint: Auto-lint after each change
230
+ - auto-validate: Run tests after each change
231
+
232
+ 4. **Validation Hooks** (after each step):
233
+ - auto-lint-fix: Fix issues
234
+ - auto-validate: Run unified validation (includes tests)
235
+
236
+ Time: 20-30 minutes (vs 60-90 manual)
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Error Pattern Recognition
242
+
243
+ ### Automatic Error Detection
244
+ ```
245
+ Monitor for error patterns:
246
+ - ESLint errors → Trigger auto-lint-fix
247
+ - Test failures → auto-validate blocks the stop and feeds failures back
248
+ - Build errors → Fetch build docs via context7
249
+ - Runtime errors → Trigger browser debugging
250
+ ```
251
+
252
+ ### Automatic Recovery
253
+ ```
254
+ Error detected → Automatic response:
255
+ 1. Identify error type
256
+ 2. Fetch relevant docs (context7)
257
+ 3. Implement fix
258
+ 4. Validate (lint + tests)
259
+ 5. If still failing → Escalate to human
260
+ ```
261
+
262
+ ---
263
+
264
+ ## Performance Metrics (Automatic Tracking)
265
+
266
+ ### Track Per Task
267
+ ```
268
+ - Task completion time
269
+ - Token consumption
270
+ - Tool calls count
271
+ - MCP calls count
272
+ - Validation gate pass rate
273
+ - User satisfaction (manual rating)
274
+ ```
275
+
276
+ ### Weekly Optimization Review
277
+ ```
278
+ Analyze metrics:
279
+ - Which optimizations saved most time?
280
+ - Which tools/MCPs most effective?
281
+ - Where are bottlenecks?
282
+ - What can be further automated?
283
+ - Adjust rules and triggers accordingly
284
+ ```
285
+
286
+ ---
287
+
288
+ ## Cost Optimization (Enforced)
289
+
290
+ ### Token Budget Allocation
291
+ ```
292
+ Tier 1 tools (Read, Glob, Grep): 40% of budget
293
+ Tier 2 tools (Explore (quick), Edit): 30% of budget
294
+ Tier 3 tools (Agent, Bash, Lint check): 20% of budget
295
+ Tier 4 tools (Parallel subagents, Browser MCP): 10% of budget
296
+ ```
297
+
298
+ ### Automatic Cost Control
299
+ ```
300
+ If task exceeds budget:
301
+ 1. Warn user
302
+ 2. Suggest scope reduction
303
+ 3. Offer to continue with approval
304
+ ```
305
+
306
+ ---
307
+
308
+ ## Examples
309
+
310
+ ### Example 1: Add Dark Mode (Optimized)
311
+ User: "Add dark mode toggle to settings page"
312
+
313
+ **Automatic Optimizations**:
314
+ ```
315
+ 1. Parallel subagents (2, 45s):
316
+ - "Find settings page structure"
317
+ - "Find Tailwind dark mode examples"
318
+
319
+ 2. Context loaded: UI/Styling
320
+
321
+ 3. MCP chain:
322
+ - context7: Tailwind dark mode docs
323
+ - claude-in-chrome: Verify UI
324
+ - eslint: Auto-lint
325
+
326
+ 4. Hooks:
327
+ - auto-lint-fix: ✅ Passed
328
+ - auto-validate: ✅ All validations passed
329
+
330
+ Result: 4 minutes, 100% quality gates pass
331
+ ```
332
+
333
+ ---
334
+
335
+ ### Example 2: Performance Audit (Optimized)
336
+ User: "Audit and improve dashboard performance"
337
+
338
+ **Automatic Optimizations**:
339
+ ```
340
+ 1. Parallel subagents (3, 90s):
341
+ - "Find dashboard code"
342
+ - "Find performance bottlenecks"
343
+ - "Find optimization patterns"
344
+
345
+ 2. Context loaded: Performance
346
+
347
+ 3. MCP chain:
348
+ - chrome-devtools: Lighthouse audit
349
+ - chrome-devtools: CPU profiling
350
+ - context7: React optimization docs
351
+ - Implement optimizations
352
+ - chrome-devtools: Re-audit
353
+
354
+ 4. Hooks:
355
+ - auto-validate: ✅ All validations passed (MCP + tests)
356
+
357
+ Result: 8 minutes, Lighthouse score 92 (from 67)
358
+ ```
359
+
360
+ ---
361
+
362
+ ### Example 3: Security Review (Optimized)
363
+ User: "Review authentication for vulnerabilities"
364
+
365
+ **Automatic Optimizations**:
366
+ ```
367
+ 1. Parallel subagents (4, 90s):
368
+ - "Find auth code"
369
+ - "Find token validation"
370
+ - "Find password handling"
371
+ - "Find input validation"
372
+
373
+ 2. Context loaded: Security
374
+
375
+ 3. MCP chain:
376
+ - context7: OWASP auth guidelines
377
+ - Implement security fixes
378
+ - eslint: Auto-lint
379
+ - auto-security-review: Scan written code
380
+
381
+ 4. Hooks:
382
+ - auto-lint-fix: ✅ Fixed 3 issues
383
+ - auto-validate: ✅ All tests pass
384
+
385
+ Result: 6 minutes, 5 vulnerabilities fixed
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Anti-Patterns (Automatically Avoided)
391
+
392
+ ### ❌ Over-Automation
393
+ **Prevention**: Start with minimal automation, add only when pain points observed
394
+
395
+ ### ❌ Context Bloat
396
+ **Prevention**: Enforce 20-line max per context file, use references over content
397
+
398
+ ### ❌ MCP Cost Explosion
399
+ **Prevention**: Cost-awareness rules, prefer cheaper tools first, track usage
400
+
401
+ ### ❌ Hook Failures Blocking Progress
402
+ **Prevention**: Hooks exit gracefully, agent continues if hooks fail
403
+
404
+ ---
405
+
406
+ ## Integration with Other Skills
407
+
408
+ ### Works with:
409
+ - **mcp-mastery**: Coordinates MCP selection
410
+ - **tool-selection**: Optimizes tool choices
411
+ - **parallel-exploration**: Launches subagents efficiently
412
+
413
+ ### Coordinates with:
414
+ - **Rules**: Enforces tool-auto-selection, parallel-exploration-auto, context tiers
415
+ - **Hooks**: Triggers validation pipeline
416
+ - **MCPs**: Chains multiple servers for complex workflows
417
+
418
+ ---
419
+
420
+ **Note**: This skill activates automatically for debugging and multi-step tasks. No manual intervention needed. All optimizations applied transparently to maximize efficiency.