claude-all-hands 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.
- package/.claude/agents/code-simplifier.md +52 -0
- package/.claude/agents/curator.md +186 -246
- package/.claude/agents/documentation-taxonomist.md +255 -0
- package/.claude/agents/documentation-writer.md +366 -0
- package/.claude/agents/planner.md +123 -166
- package/.claude/agents/researcher.md +58 -41
- package/.claude/agents/surveyor.md +81 -0
- package/.claude/agents/worker.md +74 -0
- package/.claude/commands/continue.md +122 -0
- package/.claude/commands/create-skill.md +107 -0
- package/.claude/commands/create-specialist.md +111 -0
- package/.claude/commands/curator-audit.md +4 -0
- package/.claude/commands/debug.md +183 -0
- package/.claude/commands/docs-adjust.md +214 -0
- package/.claude/commands/docs-audit.md +172 -0
- package/.claude/commands/docs-init.md +210 -0
- package/.claude/commands/plan.md +199 -102
- package/.claude/commands/validate.md +11 -0
- package/.claude/commands/whats-next.md +106 -134
- package/.claude/envoy/README.md +5 -5
- package/.claude/envoy/envoy +11 -14
- package/.claude/envoy/package-lock.json +1594 -0
- package/.claude/envoy/package.json +38 -0
- package/.claude/envoy/src/cli.ts +126 -0
- package/.claude/envoy/src/commands/base.ts +216 -0
- package/.claude/envoy/src/commands/docs.ts +881 -0
- package/.claude/envoy/src/commands/gemini.ts +999 -0
- package/.claude/envoy/src/commands/git.ts +639 -0
- package/.claude/envoy/src/commands/index.ts +73 -0
- package/.claude/envoy/src/commands/knowledge.ts +178 -0
- package/.claude/envoy/src/commands/perplexity.ts +129 -0
- package/.claude/envoy/src/commands/plan/core.ts +134 -0
- package/.claude/envoy/src/commands/plan/findings.ts +446 -0
- package/.claude/envoy/src/commands/plan/gates.ts +672 -0
- package/.claude/envoy/src/commands/plan/index.ts +135 -0
- package/.claude/envoy/src/commands/plan/lifecycle.ts +648 -0
- package/.claude/envoy/src/commands/plan/plan-file.ts +138 -0
- package/.claude/envoy/src/commands/plan/prompts.ts +285 -0
- package/.claude/envoy/src/commands/plan/protocols.ts +166 -0
- package/.claude/envoy/src/commands/repomix.ts +99 -0
- package/.claude/envoy/src/commands/tavily.ts +220 -0
- package/.claude/envoy/src/commands/xai.ts +168 -0
- package/.claude/envoy/src/lib/ast-queries.ts +261 -0
- package/.claude/envoy/src/lib/design.ts +41 -0
- package/.claude/envoy/src/lib/feedback-schemas.ts +154 -0
- package/.claude/envoy/src/lib/findings.ts +215 -0
- package/.claude/envoy/src/lib/gates.ts +572 -0
- package/.claude/envoy/src/lib/git.ts +132 -0
- package/.claude/envoy/src/lib/index.ts +188 -0
- package/.claude/envoy/src/lib/knowledge.ts +646 -0
- package/.claude/envoy/src/lib/markdown.ts +75 -0
- package/.claude/envoy/src/lib/observability.ts +262 -0
- package/.claude/envoy/src/lib/paths.ts +130 -0
- package/.claude/envoy/src/lib/plan-io.ts +117 -0
- package/.claude/envoy/src/lib/prompts.ts +231 -0
- package/.claude/envoy/src/lib/protocols.ts +314 -0
- package/.claude/envoy/src/lib/repomix.ts +133 -0
- package/.claude/envoy/src/lib/retry.ts +138 -0
- package/.claude/envoy/src/lib/tree-sitter-utils.ts +301 -0
- package/.claude/envoy/src/lib/watcher.ts +167 -0
- package/.claude/envoy/src/types/tree-sitter.d.ts +76 -0
- package/.claude/envoy/tsconfig.json +21 -0
- package/.claude/hooks/scripts/enforce_research_fetch.py +1 -1
- package/.claude/hooks/scripts/scan_agents.py +62 -0
- package/.claude/hooks/scripts/scan_commands.py +50 -0
- package/.claude/hooks/scripts/scan_skills.py +46 -70
- package/.claude/hooks/scripts/validate_artifacts.py +128 -0
- package/.claude/hooks/startup.sh +26 -24
- package/.claude/protocols/bug-discovery.yaml +55 -0
- package/.claude/protocols/debugging.yaml +51 -0
- package/.claude/protocols/discovery.yaml +53 -0
- package/.claude/protocols/implementation.yaml +84 -0
- package/.claude/settings.json +38 -97
- package/.claude/skills/brainstorming/SKILL.md +54 -0
- package/.claude/skills/commands-development/SKILL.md +630 -0
- package/.claude/skills/commands-development/references/arguments.md +252 -0
- package/.claude/skills/commands-development/references/patterns.md +796 -0
- package/.claude/skills/commands-development/references/tool-restrictions.md +376 -0
- package/.claude/skills/discovery-mode/SKILL.md +108 -0
- package/.claude/skills/documentation-taxonomy/SKILL.md +287 -0
- package/.claude/skills/hooks-development/SKILL.md +332 -0
- package/.claude/skills/hooks-development/references/command-vs-prompt.md +269 -0
- package/.claude/skills/hooks-development/references/examples.md +658 -0
- package/.claude/skills/hooks-development/references/hook-types.md +463 -0
- package/.claude/skills/hooks-development/references/input-output-schemas.md +469 -0
- package/.claude/skills/hooks-development/references/matchers.md +470 -0
- package/.claude/skills/hooks-development/references/troubleshooting.md +587 -0
- package/.claude/skills/implementation-mode/SKILL.md +171 -0
- package/.claude/skills/knowledge-discovery/SKILL.md +178 -0
- package/.claude/skills/research-tools/SKILL.md +35 -33
- package/.claude/skills/skills-development/SKILL.md +192 -0
- package/.claude/skills/skills-development/references/api-security.md +226 -0
- package/.claude/skills/skills-development/references/be-clear-and-direct.md +531 -0
- package/.claude/skills/skills-development/references/common-patterns.md +595 -0
- package/.claude/skills/skills-development/references/core-principles.md +437 -0
- package/.claude/skills/skills-development/references/executable-code.md +175 -0
- package/.claude/skills/skills-development/references/iteration-and-testing.md +474 -0
- package/.claude/skills/skills-development/references/recommended-structure.md +168 -0
- package/.claude/skills/skills-development/references/skill-structure.md +372 -0
- package/.claude/skills/skills-development/references/use-xml-tags.md +466 -0
- package/.claude/skills/skills-development/references/using-scripts.md +113 -0
- package/.claude/skills/skills-development/references/using-templates.md +112 -0
- package/.claude/skills/skills-development/references/workflows-and-validation.md +510 -0
- package/.claude/skills/skills-development/templates/router-skill.md +73 -0
- package/.claude/skills/skills-development/templates/simple-skill.md +33 -0
- package/.claude/skills/skills-development/workflows/add-reference.md +96 -0
- package/.claude/skills/skills-development/workflows/add-script.md +93 -0
- package/.claude/skills/skills-development/workflows/add-template.md +74 -0
- package/.claude/skills/skills-development/workflows/add-workflow.md +120 -0
- package/.claude/skills/skills-development/workflows/audit-skill.md +138 -0
- package/.claude/skills/skills-development/workflows/create-domain-expertise-skill.md +605 -0
- package/.claude/skills/skills-development/workflows/create-new-skill.md +191 -0
- package/.claude/skills/skills-development/workflows/get-guidance.md +121 -0
- package/.claude/skills/skills-development/workflows/upgrade-to-router.md +161 -0
- package/.claude/skills/skills-development/workflows/verify-skill.md +204 -0
- package/.claude/skills/subagents-development/SKILL.md +325 -0
- package/.claude/skills/subagents-development/references/context-management.md +567 -0
- package/.claude/skills/subagents-development/references/debugging-agents.md +714 -0
- package/.claude/skills/subagents-development/references/error-handling-and-recovery.md +502 -0
- package/.claude/skills/subagents-development/references/evaluation-and-testing.md +374 -0
- package/.claude/skills/subagents-development/references/orchestration-patterns.md +591 -0
- package/.claude/skills/subagents-development/references/subagents.md +508 -0
- package/.claude/skills/subagents-development/references/writing-subagent-prompts.md +517 -0
- package/.claude/statusline.sh +24 -0
- package/bin/cli.js +150 -72
- package/package.json +1 -1
- package/.claude/agents/explorer.md +0 -62
- package/.claude/agents/parallel-worker.md +0 -121
- package/.claude/commands/curation-fix.md +0 -92
- package/.claude/commands/new-branch.md +0 -36
- package/.claude/commands/parallel-discovery.md +0 -69
- package/.claude/commands/parallel-orchestration.md +0 -99
- package/.claude/commands/plan-checkpoint.md +0 -37
- package/.claude/envoy/commands/__init__.py +0 -1
- package/.claude/envoy/commands/base.py +0 -95
- package/.claude/envoy/commands/parallel.py +0 -439
- package/.claude/envoy/commands/perplexity.py +0 -86
- package/.claude/envoy/commands/plans.py +0 -451
- package/.claude/envoy/commands/tavily.py +0 -156
- package/.claude/envoy/commands/vertex.py +0 -358
- package/.claude/envoy/commands/xai.py +0 -124
- package/.claude/envoy/envoy.py +0 -122
- package/.claude/envoy/pyrightconfig.json +0 -4
- package/.claude/envoy/requirements.txt +0 -2
- package/.claude/hooks/capture-queries.sh +0 -3
- package/.claude/hooks/scripts/enforce_planning.py +0 -118
- package/.claude/hooks/scripts/enforce_rg.py +0 -34
- package/.claude/hooks/scripts/validate_skill.py +0 -81
- package/.claude/skills/claude-envoy-curation/SKILL.md +0 -162
- package/.claude/skills/claude-envoy-usage/SKILL.md +0 -46
- package/.claude/skills/command-development/SKILL.md +0 -206
- package/.claude/skills/command-development/examples/simple-commands.md +0 -212
- package/.claude/skills/command-development/references/frontmatter-reference.md +0 -221
- package/.claude/skills/hook-development/SKILL.md +0 -127
- package/.claude/skills/hook-development/examples/command-hooks.md +0 -301
- package/.claude/skills/hook-development/examples/prompt-hooks.md +0 -114
- package/.claude/skills/hook-development/references/event-reference.md +0 -226
- package/.claude/skills/repomix-extraction/SKILL.md +0 -91
- package/.claude/skills/skill-development/SKILL.md +0 -168
- package/.claude/skills/skill-development/examples/complete-skill-examples.md +0 -281
- package/.claude/skills/skill-development/references/progressive-disclosure.md +0 -141
- package/.claude/skills/skill-development/references/writing-style.md +0 -180
- package/.claude/skills/skill-development/scripts/validate-skill.sh +0 -144
- package/.claude/skills/specialist-builder/SKILL.md +0 -327
- package/.claude/skills/specialist-builder/docs/agent-catalog.md +0 -28
- package/.claude/skills/specialist-builder/examples/complete-agent-examples.md +0 -206
- package/.claude/skills/specialist-builder/references/system-prompt-patterns.md +0 -281
- package/.claude/skills/specialist-builder/references/triggering-examples.md +0 -162
- package/.claude/skills/specialist-builder/scripts/validate-agent.sh +0 -137
- /package/.claude/{envoy/claude-envoy.py → skills/claude-envoy-patterns/SKILL.md} +0 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-taxonomy
|
|
3
|
+
description: Reference documentation for the taxonomy-based documentation system. Covers envoy docs commands, segmentation strategies, complexity metrics, and symbol reference format.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Provide reference documentation for the taxonomy-based documentation system. Used by documentation-taxonomist and documentation-writer agents.
|
|
8
|
+
</objective>
|
|
9
|
+
|
|
10
|
+
<quick_start>
|
|
11
|
+
```bash
|
|
12
|
+
# Get documentation tree with coverage
|
|
13
|
+
envoy docs tree src/ --depth 3
|
|
14
|
+
|
|
15
|
+
# Get complexity metrics
|
|
16
|
+
envoy docs complexity src/lib/
|
|
17
|
+
|
|
18
|
+
# Format a symbol reference
|
|
19
|
+
envoy docs format-reference src/auth.ts validateToken
|
|
20
|
+
|
|
21
|
+
# Validate all documentation references
|
|
22
|
+
envoy docs validate
|
|
23
|
+
```
|
|
24
|
+
</quick_start>
|
|
25
|
+
|
|
26
|
+
<command_reference>
|
|
27
|
+
## envoy docs tree
|
|
28
|
+
|
|
29
|
+
Get directory tree with documentation coverage indicators.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
envoy docs tree <path> [--depth <n>]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Arguments:**
|
|
36
|
+
- `path`: Directory to analyze
|
|
37
|
+
- `--depth`: Max depth to traverse (default: 3)
|
|
38
|
+
|
|
39
|
+
**Output:**
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"path": "src/",
|
|
43
|
+
"tree": [
|
|
44
|
+
{
|
|
45
|
+
"name": "auth",
|
|
46
|
+
"type": "directory",
|
|
47
|
+
"has_docs": true,
|
|
48
|
+
"doc_path": "docs/auth/README.md",
|
|
49
|
+
"children": [...]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"coverage": {
|
|
53
|
+
"total": 42,
|
|
54
|
+
"covered": 15,
|
|
55
|
+
"percentage": 36
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## envoy docs complexity
|
|
61
|
+
|
|
62
|
+
Get complexity metrics for file or directory.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
envoy docs complexity <path>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Output (file):**
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"path": "src/auth.ts",
|
|
72
|
+
"type": "file",
|
|
73
|
+
"metrics": {
|
|
74
|
+
"lines": 250,
|
|
75
|
+
"imports": 8,
|
|
76
|
+
"exports": 5,
|
|
77
|
+
"functions": 12,
|
|
78
|
+
"classes": 2
|
|
79
|
+
},
|
|
80
|
+
"estimated_tokens": 2500
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Output (directory):**
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"path": "src/lib/",
|
|
88
|
+
"type": "directory",
|
|
89
|
+
"file_count": 15,
|
|
90
|
+
"metrics": {
|
|
91
|
+
"lines": 3200,
|
|
92
|
+
"imports": 45,
|
|
93
|
+
"exports": 32,
|
|
94
|
+
"functions": 78,
|
|
95
|
+
"classes": 12
|
|
96
|
+
},
|
|
97
|
+
"estimated_tokens": 32000
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## envoy docs format-reference
|
|
102
|
+
|
|
103
|
+
Format a symbol reference with git blame hash.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
envoy docs format-reference <file> <symbol>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Arguments:**
|
|
110
|
+
- `file`: Path to source file
|
|
111
|
+
- `symbol`: Symbol name (function, class, variable, type, interface)
|
|
112
|
+
|
|
113
|
+
**Output:**
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"reference": "[ref:src/auth.ts:validateToken:abc1234]",
|
|
117
|
+
"file": "src/auth.ts",
|
|
118
|
+
"symbol": "validateToken",
|
|
119
|
+
"hash": "abc1234",
|
|
120
|
+
"line_range": { "start": 42, "end": 67 },
|
|
121
|
+
"symbol_type": "function"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Supported symbol types by language:**
|
|
126
|
+
| Language | Symbols |
|
|
127
|
+
|----------|---------|
|
|
128
|
+
| TypeScript/JavaScript | function, class, variable, type, interface, method, arrowFunction |
|
|
129
|
+
| Python | function, class, variable, method |
|
|
130
|
+
| Go | function, type, method, variable, const |
|
|
131
|
+
| Rust | function, struct, enum, impl, trait, const |
|
|
132
|
+
| Java | class, interface, method, field, enum |
|
|
133
|
+
| Ruby | function, class, module |
|
|
134
|
+
| Swift | function, class, struct, enum, protocol |
|
|
135
|
+
|
|
136
|
+
## envoy docs validate
|
|
137
|
+
|
|
138
|
+
Validate all documentation references for staleness/validity.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
envoy docs validate [--path <docs_path>]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Output:**
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"message": "Validated 42 references",
|
|
148
|
+
"total_refs": 42,
|
|
149
|
+
"stale_count": 3,
|
|
150
|
+
"invalid_count": 1,
|
|
151
|
+
"stale": [
|
|
152
|
+
{
|
|
153
|
+
"doc_file": "docs/auth/README.md",
|
|
154
|
+
"reference": "[ref:src/auth.ts:validateToken:abc1234]",
|
|
155
|
+
"stored_hash": "abc1234",
|
|
156
|
+
"current_hash": "def5678"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"invalid": [
|
|
160
|
+
{
|
|
161
|
+
"doc_file": "docs/api/routes.md",
|
|
162
|
+
"reference": "[ref:src/routes.ts:deletedFunction:xyz789]",
|
|
163
|
+
"reason": "Symbol not found"
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
</command_reference>
|
|
169
|
+
|
|
170
|
+
<reference_format>
|
|
171
|
+
## Symbol Reference Format
|
|
172
|
+
|
|
173
|
+
References use the format: `[ref:file:symbol:hash]`
|
|
174
|
+
|
|
175
|
+
**Components:**
|
|
176
|
+
- `file`: Relative path from project root
|
|
177
|
+
- `symbol`: Symbol name (exact match required)
|
|
178
|
+
- `hash`: Short git commit hash (7 chars) from blame
|
|
179
|
+
|
|
180
|
+
**Regex pattern:** `/\[ref:([^:]+):([^:]+):([a-f0-9]+)\]/g`
|
|
181
|
+
|
|
182
|
+
**Examples:**
|
|
183
|
+
```markdown
|
|
184
|
+
The authentication flow starts with [ref:src/auth.ts:validateToken:abc1234].
|
|
185
|
+
|
|
186
|
+
Configuration is handled by [ref:src/config/index.ts:loadConfig:def5678].
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Why this format:**
|
|
190
|
+
- Symbol-based: survives line number changes within file
|
|
191
|
+
- Hash-tracked: enables staleness detection
|
|
192
|
+
- Human-readable: visible in docs, clickable in IDEs
|
|
193
|
+
- Parseable: regex-extractable for validation
|
|
194
|
+
</reference_format>
|
|
195
|
+
|
|
196
|
+
<segmentation_strategies>
|
|
197
|
+
## Segmentation Principles
|
|
198
|
+
|
|
199
|
+
**Size targets:**
|
|
200
|
+
- 1000-3000 tokens per segment (source code)
|
|
201
|
+
- Single segment documentable in one agent pass
|
|
202
|
+
- Balance between parallelism and overhead
|
|
203
|
+
|
|
204
|
+
**Domain grouping:**
|
|
205
|
+
```
|
|
206
|
+
authentication/ → single segment
|
|
207
|
+
api/
|
|
208
|
+
routes/ → segment if > 2000 tokens
|
|
209
|
+
middleware/ → segment if > 2000 tokens
|
|
210
|
+
handlers/ → may need sub-segments
|
|
211
|
+
lib/
|
|
212
|
+
utils/ → often single segment
|
|
213
|
+
core/ → often needs splitting
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Complexity thresholds:**
|
|
217
|
+
| Complexity | Action |
|
|
218
|
+
|------------|--------|
|
|
219
|
+
| < 500 tokens | Combine with adjacent |
|
|
220
|
+
| 500-3000 tokens | Single segment |
|
|
221
|
+
| > 3000 tokens | Split by subdirectory |
|
|
222
|
+
| > 50 functions | Split by functionality |
|
|
223
|
+
|
|
224
|
+
**Depth guidance:**
|
|
225
|
+
| Depth | When to use |
|
|
226
|
+
|-------|-------------|
|
|
227
|
+
| overview | Simple utilities, config, low complexity |
|
|
228
|
+
| detailed | Core business logic, complex flows |
|
|
229
|
+
| comprehensive | Public APIs, libraries, critical paths |
|
|
230
|
+
</segmentation_strategies>
|
|
231
|
+
|
|
232
|
+
<complexity_interpretation>
|
|
233
|
+
## Interpreting Complexity Metrics
|
|
234
|
+
|
|
235
|
+
**Lines of code:**
|
|
236
|
+
- < 100: Simple module
|
|
237
|
+
- 100-500: Standard module
|
|
238
|
+
- 500-1000: Complex module
|
|
239
|
+
- > 1000: Consider splitting
|
|
240
|
+
|
|
241
|
+
**Functions/classes ratio:**
|
|
242
|
+
- High functions, few classes: Utility module
|
|
243
|
+
- Few functions, many classes: OOP-heavy module
|
|
244
|
+
- Balanced: Standard module
|
|
245
|
+
|
|
246
|
+
**Imports:**
|
|
247
|
+
- < 5: Self-contained
|
|
248
|
+
- 5-15: Normal coupling
|
|
249
|
+
- > 15: Highly coupled, document dependencies
|
|
250
|
+
|
|
251
|
+
**Exports:**
|
|
252
|
+
- 1-5: Focused API surface
|
|
253
|
+
- 5-15: Medium API
|
|
254
|
+
- > 15: Large API, needs comprehensive docs
|
|
255
|
+
|
|
256
|
+
**Estimated tokens:**
|
|
257
|
+
- Rough guide: lines × 10
|
|
258
|
+
- Used for segment sizing
|
|
259
|
+
- Not exact, account for variance
|
|
260
|
+
</complexity_interpretation>
|
|
261
|
+
|
|
262
|
+
<parallel_writers>
|
|
263
|
+
## Parallel Writer Pattern
|
|
264
|
+
|
|
265
|
+
Writers work directly on the branch without worktrees. The taxonomist ensures non-overlapping output directories, preventing conflicts.
|
|
266
|
+
|
|
267
|
+
**Segmentation rule:** Each segment gets a unique `output_path` (e.g., `docs/auth/`, `docs/api/`). Writers only modify files within their assigned output directory.
|
|
268
|
+
|
|
269
|
+
**Why no worktrees:** Since each writer owns a distinct directory, there are no file conflicts. This simplifies the workflow and avoids worktree management overhead.
|
|
270
|
+
</parallel_writers>
|
|
271
|
+
|
|
272
|
+
<anti_patterns>
|
|
273
|
+
- Creating docs without symbol references (no traceability)
|
|
274
|
+
- Overlapping segments (causes merge conflicts)
|
|
275
|
+
- Segments too large (> 5000 tokens, agent struggles)
|
|
276
|
+
- Segments too small (< 500 tokens, overhead)
|
|
277
|
+
- Skipping complexity analysis (poor segmentation)
|
|
278
|
+
- Not searching existing docs (duplication)
|
|
279
|
+
- Ignoring depth guidance (inconsistent detail)
|
|
280
|
+
</anti_patterns>
|
|
281
|
+
|
|
282
|
+
<success_criteria>
|
|
283
|
+
- All code snippets have `[ref:...]` format
|
|
284
|
+
- Segments are non-overlapping (enables parallel writers without conflicts)
|
|
285
|
+
- Complexity informs depth decisions
|
|
286
|
+
- Validation passes after commits
|
|
287
|
+
</success_criteria>
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hooks-development
|
|
3
|
+
description: Expert guidance for creating, refining, and auditing Claude Code hooks. Use when working with hooks, setting up event listeners, validating commands, automating workflows, adding notifications, or understanding hook types (PreToolUse, PostToolUse, Stop, SessionStart, UserPromptSubmit, etc).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Hooks are event-driven automation for Claude Code that execute shell commands or LLM prompts in response to tool usage, session events, and user interactions. This skill teaches you how to create, configure, and debug hooks for validating commands, automating workflows, injecting context, and implementing custom completion criteria.
|
|
8
|
+
|
|
9
|
+
Hooks provide programmatic control over Claude's behavior without modifying core code, enabling project-specific automation, safety checks, and workflow customization.
|
|
10
|
+
</objective>
|
|
11
|
+
|
|
12
|
+
<context>
|
|
13
|
+
Hooks are shell commands or LLM-evaluated prompts that execute in response to Claude Code events. They operate within an event hierarchy: events (PreToolUse, PostToolUse, Stop, etc.) trigger matchers (tool patterns) which fire hooks (commands or prompts). Hooks can block actions, modify tool inputs, inject context, or simply observe and log Claude's operations.
|
|
14
|
+
</context>
|
|
15
|
+
|
|
16
|
+
<quick_start>
|
|
17
|
+
<workflow>
|
|
18
|
+
1. Create hooks config file:
|
|
19
|
+
- Project: `.claude/hooks.json`
|
|
20
|
+
- User: `~/.claude/hooks.json`
|
|
21
|
+
2. Choose hook event (when it fires)
|
|
22
|
+
3. Choose hook type (command or prompt)
|
|
23
|
+
4. Configure matcher (which tools trigger it)
|
|
24
|
+
5. Test with `claude --debug`
|
|
25
|
+
</workflow>
|
|
26
|
+
|
|
27
|
+
<example>
|
|
28
|
+
**Log all bash commands**:
|
|
29
|
+
|
|
30
|
+
`.claude/hooks.json`:
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"hooks": {
|
|
34
|
+
"PreToolUse": [
|
|
35
|
+
{
|
|
36
|
+
"matcher": "Bash",
|
|
37
|
+
"hooks": [
|
|
38
|
+
{
|
|
39
|
+
"type": "command",
|
|
40
|
+
"command": "jq -r '\"\\(.tool_input.command) - \\(.tool_input.description // \\\"No description\\\")\"' >> ~/.claude/bash-log.txt"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This hook:
|
|
50
|
+
- Fires before (`PreToolUse`) every `Bash` tool use
|
|
51
|
+
- Executes a `command` (not an LLM prompt)
|
|
52
|
+
- Logs command + description to a file
|
|
53
|
+
</example>
|
|
54
|
+
</quick_start>
|
|
55
|
+
|
|
56
|
+
<hook_types>
|
|
57
|
+
| Event | When it fires | Can block? |
|
|
58
|
+
|-------|---------------|------------|
|
|
59
|
+
| **PreToolUse** | Before tool execution | Yes |
|
|
60
|
+
| **PostToolUse** | After tool execution | No |
|
|
61
|
+
| **UserPromptSubmit** | User submits a prompt | Yes |
|
|
62
|
+
| **Stop** | Claude attempts to stop | Yes |
|
|
63
|
+
| **SubagentStop** | Subagent attempts to stop | Yes |
|
|
64
|
+
| **SessionStart** | Session begins | No |
|
|
65
|
+
| **SessionEnd** | Session ends | No |
|
|
66
|
+
| **PreCompact** | Before context compaction | Yes |
|
|
67
|
+
| **Notification** | Claude needs input | No |
|
|
68
|
+
|
|
69
|
+
Blocking hooks can return `"decision": "block"` to prevent the action. See [references/hook-types.md](references/hook-types.md) for detailed use cases.
|
|
70
|
+
</hook_types>
|
|
71
|
+
|
|
72
|
+
<hook_anatomy>
|
|
73
|
+
<hook_type name="command">
|
|
74
|
+
**Type**: Executes a shell command
|
|
75
|
+
|
|
76
|
+
**Use when**:
|
|
77
|
+
- Simple validation (check file exists)
|
|
78
|
+
- Logging (append to file)
|
|
79
|
+
- External tools (formatters, linters)
|
|
80
|
+
- Desktop notifications
|
|
81
|
+
|
|
82
|
+
**Input**: JSON via stdin
|
|
83
|
+
**Output**: JSON via stdout (optional)
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"type": "command",
|
|
88
|
+
"command": "/path/to/script.sh",
|
|
89
|
+
"timeout": 30000
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
</hook_type>
|
|
93
|
+
|
|
94
|
+
<hook_type name="prompt">
|
|
95
|
+
**Type**: LLM evaluates a prompt
|
|
96
|
+
|
|
97
|
+
**Use when**:
|
|
98
|
+
- Complex decision logic
|
|
99
|
+
- Natural language validation
|
|
100
|
+
- Context-aware checks
|
|
101
|
+
- Reasoning required
|
|
102
|
+
|
|
103
|
+
**Input**: Prompt with `$ARGUMENTS` placeholder
|
|
104
|
+
**Output**: JSON with `decision` and `reason`
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"type": "prompt",
|
|
109
|
+
"prompt": "Evaluate if this command is safe: $ARGUMENTS\n\nReturn JSON: {\"decision\": \"approve\" or \"block\", \"reason\": \"explanation\"}"
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
</hook_type>
|
|
113
|
+
</hook_anatomy>
|
|
114
|
+
|
|
115
|
+
<matchers>
|
|
116
|
+
Matchers filter which tools trigger the hook:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"matcher": "Bash", // Exact match
|
|
121
|
+
"matcher": "Write|Edit", // Multiple tools (regex OR)
|
|
122
|
+
"matcher": "mcp__.*", // All MCP tools
|
|
123
|
+
"matcher": "mcp__memory__.*" // Specific MCP server
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**No matcher**: Hook fires for all tools
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"hooks": {
|
|
131
|
+
"UserPromptSubmit": [
|
|
132
|
+
{
|
|
133
|
+
"hooks": [...] // No matcher - fires on every user prompt
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
</matchers>
|
|
140
|
+
|
|
141
|
+
<input_output>
|
|
142
|
+
Hooks receive JSON via stdin with session info, current directory, and event-specific data. Blocking hooks can return JSON to approve/block actions or modify inputs.
|
|
143
|
+
|
|
144
|
+
**Example output** (blocking hooks):
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"decision": "approve" | "block",
|
|
148
|
+
"reason": "Why this decision was made"
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
See [references/input-output-schemas.md](references/input-output-schemas.md) for complete schemas for each hook type.
|
|
153
|
+
</input_output>
|
|
154
|
+
|
|
155
|
+
<environment_variables>
|
|
156
|
+
Available in hook commands:
|
|
157
|
+
|
|
158
|
+
| Variable | Value |
|
|
159
|
+
|----------|-------|
|
|
160
|
+
| `$CLAUDE_PROJECT_DIR` | Project root directory |
|
|
161
|
+
| `${CLAUDE_PLUGIN_ROOT}` | Plugin directory (plugin hooks only) |
|
|
162
|
+
| `$ARGUMENTS` | Hook input JSON (prompt hooks only) |
|
|
163
|
+
|
|
164
|
+
**Example**:
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/validate.sh"
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
</environment_variables>
|
|
171
|
+
|
|
172
|
+
<common_patterns>
|
|
173
|
+
**Desktop notification when input needed**:
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"hooks": {
|
|
177
|
+
"Notification": [
|
|
178
|
+
{
|
|
179
|
+
"hooks": [
|
|
180
|
+
{
|
|
181
|
+
"type": "command",
|
|
182
|
+
"command": "osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'"
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Block destructive git commands**:
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"hooks": {
|
|
195
|
+
"PreToolUse": [
|
|
196
|
+
{
|
|
197
|
+
"matcher": "Bash",
|
|
198
|
+
"hooks": [
|
|
199
|
+
{
|
|
200
|
+
"type": "prompt",
|
|
201
|
+
"prompt": "Check if this command is destructive: $ARGUMENTS\n\nBlock if it contains: 'git push --force', 'rm -rf', 'git reset --hard'\n\nReturn: {\"decision\": \"approve\" or \"block\", \"reason\": \"explanation\"}"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Auto-format code after edits**:
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"hooks": {
|
|
214
|
+
"PostToolUse": [
|
|
215
|
+
{
|
|
216
|
+
"matcher": "Write|Edit",
|
|
217
|
+
"hooks": [
|
|
218
|
+
{
|
|
219
|
+
"type": "command",
|
|
220
|
+
"command": "prettier --write $CLAUDE_PROJECT_DIR",
|
|
221
|
+
"timeout": 10000
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Add context at session start**:
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"hooks": {
|
|
234
|
+
"SessionStart": [
|
|
235
|
+
{
|
|
236
|
+
"hooks": [
|
|
237
|
+
{
|
|
238
|
+
"type": "command",
|
|
239
|
+
"command": "echo '{\"hookSpecificOutput\": {\"hookEventName\": \"SessionStart\", \"additionalContext\": \"Current sprint: Sprint 23. Focus: User authentication\"}}'"
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
</common_patterns>
|
|
248
|
+
|
|
249
|
+
<debugging>
|
|
250
|
+
Always test hooks with the debug flag:
|
|
251
|
+
```bash
|
|
252
|
+
claude --debug
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
This shows which hooks matched, command execution, and output. See [references/troubleshooting.md](references/troubleshooting.md) for common issues and solutions.
|
|
256
|
+
</debugging>
|
|
257
|
+
|
|
258
|
+
<reference_guides>
|
|
259
|
+
**Hook types and events**: [references/hook-types.md](references/hook-types.md)
|
|
260
|
+
- Complete list of hook events
|
|
261
|
+
- When each event fires
|
|
262
|
+
- Input/output schemas for each
|
|
263
|
+
- Blocking vs non-blocking hooks
|
|
264
|
+
|
|
265
|
+
**Command vs Prompt hooks**: [references/command-vs-prompt.md](references/command-vs-prompt.md)
|
|
266
|
+
- Decision tree: which type to use
|
|
267
|
+
- Command hook patterns and examples
|
|
268
|
+
- Prompt hook patterns and examples
|
|
269
|
+
- Performance considerations
|
|
270
|
+
|
|
271
|
+
**Matchers and patterns**: [references/matchers.md](references/matchers.md)
|
|
272
|
+
- Regex patterns for tool matching
|
|
273
|
+
- MCP tool matching patterns
|
|
274
|
+
- Multiple tool matching
|
|
275
|
+
- Debugging matcher issues
|
|
276
|
+
|
|
277
|
+
**Input/Output schemas**: [references/input-output-schemas.md](references/input-output-schemas.md)
|
|
278
|
+
- Complete schema for each hook type
|
|
279
|
+
- Field descriptions and types
|
|
280
|
+
- Hook-specific output fields
|
|
281
|
+
- Example JSON for each event
|
|
282
|
+
|
|
283
|
+
**Working examples**: [references/examples.md](references/examples.md)
|
|
284
|
+
- Desktop notifications
|
|
285
|
+
- Command validation
|
|
286
|
+
- Auto-formatting workflows
|
|
287
|
+
- Logging and audit trails
|
|
288
|
+
- Stop logic patterns
|
|
289
|
+
- Session context injection
|
|
290
|
+
|
|
291
|
+
**Troubleshooting**: [references/troubleshooting.md](references/troubleshooting.md)
|
|
292
|
+
- Hooks not triggering
|
|
293
|
+
- Command execution failures
|
|
294
|
+
- Prompt hook issues
|
|
295
|
+
- Permission problems
|
|
296
|
+
- Timeout handling
|
|
297
|
+
- Debug workflow
|
|
298
|
+
</reference_guides>
|
|
299
|
+
|
|
300
|
+
<security_checklist>
|
|
301
|
+
**Critical safety requirements**:
|
|
302
|
+
|
|
303
|
+
- **Infinite loop prevention**: Check `stop_hook_active` flag in Stop hooks to prevent recursive triggering
|
|
304
|
+
- **Timeout configuration**: Set reasonable timeouts (default: 60s) to prevent hanging
|
|
305
|
+
- **Permission validation**: Ensure hook scripts have executable permissions (`chmod +x`)
|
|
306
|
+
- **Path safety**: Use absolute paths with `$CLAUDE_PROJECT_DIR` to avoid path injection
|
|
307
|
+
- **JSON validation**: Validate hook config with `jq` before use to catch syntax errors
|
|
308
|
+
- **Selective blocking**: Be conservative with blocking hooks to avoid workflow disruption
|
|
309
|
+
|
|
310
|
+
**Testing protocol**:
|
|
311
|
+
```bash
|
|
312
|
+
# Always test with debug flag first
|
|
313
|
+
claude --debug
|
|
314
|
+
|
|
315
|
+
# Validate JSON config
|
|
316
|
+
jq . .claude/hooks.json
|
|
317
|
+
```
|
|
318
|
+
</security_checklist>
|
|
319
|
+
|
|
320
|
+
<success_criteria>
|
|
321
|
+
A working hook configuration has:
|
|
322
|
+
|
|
323
|
+
- Valid JSON in `.claude/hooks.json` (validated with `jq`)
|
|
324
|
+
- Appropriate hook event selected for the use case
|
|
325
|
+
- Correct matcher pattern that matches target tools
|
|
326
|
+
- Command or prompt that executes without errors
|
|
327
|
+
- Proper output schema (decision/reason for blocking hooks)
|
|
328
|
+
- Tested with `--debug` flag showing expected behavior
|
|
329
|
+
- No infinite loops in Stop hooks (checks `stop_hook_active` flag)
|
|
330
|
+
- Reasonable timeout set (especially for external commands)
|
|
331
|
+
- Executable permissions on script files if using file paths
|
|
332
|
+
</success_criteria>
|