claude-capsule-kit 3.0.0

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 (107) hide show
  1. package/README.md +281 -0
  2. package/agents/agent-developer.md +206 -0
  3. package/agents/architecture-explorer.md +90 -0
  4. package/agents/brainstorm-coordinator.md +120 -0
  5. package/agents/code-reviewer.md +135 -0
  6. package/agents/context-librarian.md +227 -0
  7. package/agents/context-manager.md +151 -0
  8. package/agents/database-architect.md +107 -0
  9. package/agents/database-navigator.md +136 -0
  10. package/agents/debugger.md +121 -0
  11. package/agents/devops-sre.md +102 -0
  12. package/agents/error-detective.md +128 -0
  13. package/agents/git-workflow-manager.md +212 -0
  14. package/agents/github-issue-tracker.md +252 -0
  15. package/agents/product-dx-specialist.md +99 -0
  16. package/agents/refactoring-specialist.md +159 -0
  17. package/agents/security-engineer.md +102 -0
  18. package/agents/session-summarizer.md +126 -0
  19. package/agents/system-architect.md +103 -0
  20. package/bin/cck.js +1624 -0
  21. package/commands/crew-setup.md +75 -0
  22. package/commands/load-session.md +68 -0
  23. package/commands/sessions.md +55 -0
  24. package/commands/statusline.md +51 -0
  25. package/commands/sync-disable.md +35 -0
  26. package/commands/sync-enable.md +32 -0
  27. package/commands/sync.md +31 -0
  28. package/crew/lib/activity-monitor.js +128 -0
  29. package/crew/lib/crew-config-reader.js +255 -0
  30. package/crew/lib/health-monitor.js +171 -0
  31. package/crew/lib/merge-pilot.js +340 -0
  32. package/crew/lib/prompt-generator.js +268 -0
  33. package/crew/lib/role-presets.js +63 -0
  34. package/crew/lib/task-decomposer.js +382 -0
  35. package/crew/lib/team-spawner.sh +557 -0
  36. package/crew/lib/team-state-manager.js +155 -0
  37. package/crew/lib/worktree-gc.js +357 -0
  38. package/crew/lib/worktree-manager.sh +700 -0
  39. package/docs/AGENT_ROUTING_GUIDE.md +655 -0
  40. package/docs/AGENT_TEAMS_WORKTREE_MODE.md +681 -0
  41. package/docs/BEST_PRACTICES.md +194 -0
  42. package/docs/CAPSULE_DEGRADATION_RCA.md +577 -0
  43. package/docs/SKILLS_ORCHESTRATION_ARCHITECTURE.md +455 -0
  44. package/docs/SUPER_CLAUDE_SYSTEM_ARCHITECTURE.md +1647 -0
  45. package/docs/TOOL_ENFORCEMENT_REFERENCE.md +418 -0
  46. package/hooks/check-refresh-needed.sh +77 -0
  47. package/hooks/detect-changes.sh +90 -0
  48. package/hooks/keyword-triggers.sh +66 -0
  49. package/hooks/lib/crew-detect.js +241 -0
  50. package/hooks/lib/handoff-generator.js +158 -0
  51. package/hooks/load-from-journal.sh +41 -0
  52. package/hooks/post-tool-use.js +212 -0
  53. package/hooks/pre-compact.js +77 -0
  54. package/hooks/pre-edit-analysis.sh +68 -0
  55. package/hooks/pre-tool-use.sh +212 -0
  56. package/hooks/prompt-submit-memory.sh +87 -0
  57. package/hooks/quality-check.sh +48 -0
  58. package/hooks/session-end.js +133 -0
  59. package/hooks/session-start.js +439 -0
  60. package/hooks/stop.sh +66 -0
  61. package/hooks/suggest-discoveries.sh +84 -0
  62. package/hooks/summarize-session.sh +122 -0
  63. package/hooks/sync-to-journal.sh +77 -0
  64. package/hooks/sync-todowrite.sh +37 -0
  65. package/hooks/tool-auto-suggest.sh +77 -0
  66. package/hooks/user-prompt-submit.sh +71 -0
  67. package/lib/audit-logger.sh +120 -0
  68. package/lib/sandbox-validator.sh +194 -0
  69. package/lib/tool-runner.sh +274 -0
  70. package/package.json +67 -0
  71. package/scripts/postinstall.js +4 -0
  72. package/scripts/show-capsule-visual.sh +103 -0
  73. package/scripts/show-capsule.sh +113 -0
  74. package/scripts/show-deps-tree.sh +66 -0
  75. package/scripts/show-stats-dashboard.sh +52 -0
  76. package/scripts/show-stats.sh +79 -0
  77. package/skills/code-review/SKILL.md +520 -0
  78. package/skills/crew/SKILL.md +395 -0
  79. package/skills/debug/SKILL.md +473 -0
  80. package/skills/deep-context/SKILL.md +446 -0
  81. package/skills/task-router/SKILL.md +390 -0
  82. package/skills/workflow/SKILL.md +370 -0
  83. package/templates/CLAUDE.md +124 -0
  84. package/templates/crew-config.json +21 -0
  85. package/templates/settings-hooks.json +74 -0
  86. package/templates/statusline-command.sh +208 -0
  87. package/tools/context-query/context-query.js +312 -0
  88. package/tools/context-query/context-query.sh +5 -0
  89. package/tools/context-query/tool.json +42 -0
  90. package/tools/dependency-scanner/dependency-scanner.sh +53 -0
  91. package/tools/dependency-scanner/tool.json +8 -0
  92. package/tools/find-circular/find-circular.sh +41 -0
  93. package/tools/find-circular/tool.json +36 -0
  94. package/tools/find-dead-code/find-dead-code.sh +41 -0
  95. package/tools/find-dead-code/tool.json +36 -0
  96. package/tools/impact-analysis/impact-analysis.sh +99 -0
  97. package/tools/impact-analysis/tool.json +38 -0
  98. package/tools/progressive-reader/progressive-reader.sh +14 -0
  99. package/tools/progressive-reader/tool.json +69 -0
  100. package/tools/query-deps/query-deps.sh +69 -0
  101. package/tools/query-deps/tool.json +34 -0
  102. package/tools/stats/stats.js +299 -0
  103. package/tools/stats/stats.sh +5 -0
  104. package/tools/stats/tool.json +34 -0
  105. package/tools/token-counter/README.md +73 -0
  106. package/tools/token-counter/token-counter.py +202 -0
  107. package/tools/token-counter/tool.json +40 -0
@@ -0,0 +1,390 @@
1
+ ---
2
+ name: task-router
3
+ description: |
4
+ Decision matrix for choosing optimal approach to any task. Helps Claude
5
+ decide when to delegate to sub-agents vs. working directly. Use when
6
+ starting a new task or unsure of best approach.
7
+ allowed-tools: [Read]
8
+ ---
9
+
10
+ # Task Router Skill
11
+
12
+ This skill provides clear decision rules for choosing the optimal approach to any task.
13
+
14
+ ## Purpose
15
+
16
+ **Problem**: Claude has many tools (sub-agents, direct work, parallel calls) but no clear guidance on when to use each.
17
+ **Solution**: Decision matrix with clear rules and examples.
18
+
19
+ ## When to Use
20
+
21
+ Activate this skill when:
22
+ - Starting a new task and unsure of approach
23
+ - Task seems complex (>30 min, >5 files)
24
+ - User asks "what's the best way to do X?"
25
+ - Need to validate chosen approach
26
+
27
+ ## Decision Matrix
28
+
29
+ ### 🤖 Use `agent-developer` Sub-Agent
30
+
31
+ **Trigger Conditions**:
32
+ - Building/creating mini-agents (Python with OpenAI Agents SDK)
33
+ - Implementing executive agent configs (YAML)
34
+ - Adding skills to skill registry
35
+ - Writing job handlers for BullMQ
36
+ - Integrating MCP servers
37
+ - System Python Architecture tasks
38
+
39
+ **Examples**:
40
+ - "Create a Slack notification mini-agent"
41
+ - "Build job handler for experiment tracking"
42
+ - "Add Google Docs skill to registry"
43
+
44
+ **Why Delegate**:
45
+ - Specialized knowledge of agent patterns
46
+ - Knows OpenAI Agents SDK deeply
47
+ - Understands System Python Architecture
48
+ - Has MCP integration best practices
49
+ - 75% faster than manual implementation
50
+
51
+ **How to Invoke**:
52
+ ```
53
+ Task tool with:
54
+ - subagent_type: "agent-developer"
55
+ - prompt: "Create [specific agent/handler] with [requirements]"
56
+ ```
57
+
58
+ ---
59
+
60
+ ### 🔍 Use `Explore` Sub-Agent
61
+
62
+ **Trigger Conditions**:
63
+ - Finding files by pattern/keyword
64
+ - Understanding how a feature works
65
+ - Locating implementation of functionality
66
+ - Searching across multiple directories
67
+ - Don't know exact file location
68
+
69
+ **Examples**:
70
+ - "Where are errors from client handled?"
71
+ - "Find all authentication-related code"
72
+ - "How does the SSE streaming work?"
73
+
74
+ **Why Delegate**:
75
+ - Multi-round investigation capability
76
+ - Pattern matching across codebase
77
+ - Faster than manual Grep/Glob
78
+ - Systematic exploration approach
79
+
80
+ **How to Invoke**:
81
+ ```
82
+ Task tool with:
83
+ - subagent_type: "Explore"
84
+ - prompt: "Find [what you're looking for]"
85
+ - Specify thoroughness: "quick", "medium", "very thorough"
86
+ ```
87
+
88
+ ---
89
+
90
+ ### 🧪 Use `labs-specialist` Sub-Agent
91
+
92
+ **Trigger Conditions**:
93
+ - Experiment tracking logic
94
+ - Validation algorithms (Type A/B)
95
+ - Playbook generation
96
+ - ML service integration (Vertex AI)
97
+ - BigQuery query logic for Labs
98
+ - Reach/Creative intelligence features
99
+
100
+ **Examples**:
101
+ - "How does experiment validation work?"
102
+ - "Implement playbook confidence scoring"
103
+ - "Fix experiment tracking job"
104
+
105
+ **Why Delegate**:
106
+ - Expert in Labs domain logic
107
+ - Knows validation algorithms
108
+ - Understands ML service architecture
109
+ - Familiar with BigQuery integration
110
+
111
+ **How to Invoke**:
112
+ ```
113
+ Task tool with:
114
+ - subagent_type: "labs-specialist"
115
+ - prompt: "Explain/fix/implement [Labs-specific task]"
116
+ ```
117
+
118
+ ---
119
+
120
+ ### 🗄️ Use `database-navigator` Sub-Agent
121
+
122
+ **Trigger Conditions**:
123
+ - Understanding database schema
124
+ - Analyzing migrations
125
+ - Finding entity relationships
126
+ - Query optimization
127
+ - JSONB structure analysis
128
+ - Foreign key dependencies
129
+
130
+ **Examples**:
131
+ - "Show me the Labs database schema"
132
+ - "What tables are related to experiments?"
133
+ - "Explain the migration 175800000*"
134
+
135
+ **Why Delegate**:
136
+ - Specialized in schema analysis
137
+ - Understands TypeORM patterns
138
+ - Can trace relationships
139
+ - Migration expertise
140
+
141
+ **How to Invoke**:
142
+ ```
143
+ Task tool with:
144
+ - subagent_type: "database-navigator"
145
+ - prompt: "Analyze [database/schema/migration topic]"
146
+ ```
147
+
148
+ ---
149
+
150
+ ### 🏗️ Use `architecture-explorer` Sub-Agent
151
+
152
+ **Trigger Conditions**:
153
+ - Understanding service boundaries
154
+ - Data flow analysis
155
+ - Integration points between services
156
+ - API communication patterns
157
+ - System design questions
158
+
159
+ **Examples**:
160
+ - "How does Frontend talk to Cognitive Engine?"
161
+ - "Explain the SSE streaming architecture"
162
+ - "What's the agent execution flow?"
163
+
164
+ **Why Delegate**:
165
+ - Holistic system understanding
166
+ - Service boundary expertise
167
+ - Data flow visualization
168
+ - Integration pattern knowledge
169
+
170
+ **How to Invoke**:
171
+ ```
172
+ Task tool with:
173
+ - subagent_type: "architecture-explorer"
174
+ - prompt: "Explain [system/integration/flow]"
175
+ ```
176
+
177
+ ---
178
+
179
+ ### ✋ Work Directly (No Sub-Agent)
180
+
181
+ **When to Work Directly**:
182
+ - Simple file edits (<50 lines changed)
183
+ - Quick bug fixes (known location)
184
+ - Documentation updates
185
+ - Configuration changes
186
+ - Reading 1-3 specific files
187
+ - Small refactors
188
+
189
+ **Examples**:
190
+ - "Fix typo in labs.controller.ts:123"
191
+ - "Update CLAUDE.md with new model"
192
+ - "Change port in config"
193
+
194
+ **Why Direct**:
195
+ - Faster for simple tasks
196
+ - No delegation overhead
197
+ - Clear, known scope
198
+
199
+ **How to Execute**:
200
+ - Use Read, Edit, Write tools directly
201
+ - Use TodoWrite for tracking if multi-step
202
+ - Parallel tool calls if multiple independent operations
203
+
204
+ ---
205
+
206
+ ## Special Cases
207
+
208
+ ### Parallel Tool Calls
209
+
210
+ **Use When**:
211
+ - Reading multiple independent files
212
+ - Running multiple independent commands
213
+ - Checking multiple services
214
+ - Validating multiple configurations
215
+
216
+ **Example**:
217
+ ```
218
+ Single message with:
219
+ - Read tool (file1.ts)
220
+ - Read tool (file2.ts)
221
+ - Read tool (file3.ts)
222
+ All in one response block
223
+ ```
224
+
225
+ **Why**: 3x faster than sequential reads
226
+
227
+ ---
228
+
229
+ ### Plan Sub-Agent
230
+
231
+ **Use When**:
232
+ - Need to plan multi-step implementation
233
+ - Breaking down complex feature
234
+ - Creating implementation roadmap
235
+ - Analyzing technical approach
236
+
237
+ **Example**: "Plan the implementation of playbook management APIs"
238
+
239
+ ---
240
+
241
+ ### Exploration Journal
242
+
243
+ **Always Check When**:
244
+ - User says "continue", "resume", "pick up where we left off"
245
+ - Starting work on familiar topic
246
+ - Complex investigation (might have been explored before)
247
+
248
+ **Location**: `docs/exploration/CURRENT_SESSION.md`
249
+
250
+ **Why**: Avoid repeating work, maintain continuity
251
+
252
+ ---
253
+
254
+ ## Decision Flowchart
255
+
256
+ ```
257
+ START: New Task Received
258
+
259
+ Is it continuation work?
260
+ YES → Read exploration journal first
261
+ NO → Continue
262
+
263
+ Is it simple (<30 min, <5 files, known location)?
264
+ YES → Work directly
265
+ NO → Continue
266
+
267
+ Is it development (agent/handler/skill)?
268
+ YES → Use agent-developer
269
+ NO → Continue
270
+
271
+ Is it exploration (find/understand/locate)?
272
+ YES → Use Explore sub-agent
273
+ NO → Continue
274
+
275
+ Is it Labs-specific?
276
+ YES → Use labs-specialist
277
+ NO → Continue
278
+
279
+ Is it database/schema?
280
+ YES → Use database-navigator
281
+ NO → Continue
282
+
283
+ Is it architecture/integration?
284
+ YES → Use architecture-explorer
285
+ NO → Continue
286
+
287
+ DEFAULT → Work directly with TodoWrite tracking
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Quality Checks
293
+
294
+ After choosing approach, verify:
295
+
296
+ ### ✅ Correct Choice If:
297
+ - Approach matches decision matrix
298
+ - Estimated time saved > delegation overhead
299
+ - Sub-agent has specialized knowledge for this task
300
+ - Task is complex enough to benefit from specialization
301
+
302
+ ### ❌ Wrong Choice If:
303
+ - Using sub-agent for simple 1-file edit
304
+ - Working directly on complex multi-file feature
305
+ - Not using parallel calls for independent operations
306
+ - Forgetting to check exploration journal on continuation
307
+
308
+ ---
309
+
310
+ ## Examples: Good vs. Bad Decisions
311
+
312
+ ### Example 1: Building Job Handler
313
+
314
+ **Task**: "Create experiment tracking job handler"
315
+
316
+ ❌ **Bad**: Work directly
317
+ - Why bad: 200+ lines, needs BullMQ patterns, integration knowledge
318
+ - Result: Slow, might miss patterns, no validation
319
+
320
+ ✅ **Good**: Use agent-developer sub-agent
321
+ - Why good: Specialized in job handlers, knows patterns, faster
322
+ - Result: Production-quality handler following best practices
323
+
324
+ ---
325
+
326
+ ### Example 2: Finding Implementation
327
+
328
+ **Task**: "Where is SSE streaming implemented?"
329
+
330
+ ❌ **Bad**: Manual Grep + Read chain
331
+ - Why bad: Multiple rounds, trial and error, slow
332
+ - Result: Might miss files, incomplete understanding
333
+
334
+ ✅ **Good**: Use Explore sub-agent
335
+ - Why good: Systematic search, multi-round investigation
336
+ - Result: Complete findings with file paths and line numbers
337
+
338
+ ---
339
+
340
+ ### Example 3: Simple Config Change
341
+
342
+ **Task**: "Update port in .env.example"
343
+
344
+ ❌ **Bad**: Use agent-developer sub-agent
345
+ - Why bad: Massive overhead for 1-line change
346
+ - Result: Slower, overkill
347
+
348
+ ✅ **Good**: Work directly
349
+ - Why good: Read → Edit → Done in 30 seconds
350
+ - Result: Fast, efficient
351
+
352
+ ---
353
+
354
+ ### Example 4: Reading Multiple Files
355
+
356
+ **Task**: "Check these 5 files for X pattern"
357
+
358
+ ❌ **Bad**: Sequential reads (5 separate messages)
359
+ - Why bad: 5x slower than parallel
360
+ - Result: Wastes time and tokens
361
+
362
+ ✅ **Good**: Parallel tool calls (single message, 5 Read tools)
363
+ - Why good: All reads execute simultaneously
364
+ - Result: 5x faster
365
+
366
+ ---
367
+
368
+ ## Integration with Hooks
369
+
370
+ This skill complements the hooks system:
371
+
372
+ 1. **Pre-Task Analysis Hook** suggests which approach to use
373
+ 2. **Task Router Skill** provides detailed decision matrix
374
+ 3. **Quality Check Hook** validates approach was optimal
375
+
376
+ User can invoke this skill manually: "What's the best way to [task]?"
377
+
378
+ ---
379
+
380
+ ## Success Criteria
381
+
382
+ ✅ Correct sub-agent chosen for specialized tasks
383
+ ✅ Direct work used for simple operations
384
+ ✅ Parallel calls used for independent operations
385
+ ✅ Exploration journal checked on continuation
386
+ ✅ No obvious inefficiencies in approach
387
+
388
+ ---
389
+
390
+ **Remember**: The goal is OPTIMAL approach, not just ANY approach. Use sub-agents when they provide value, work directly when they don't!