claude-all-hands 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/agents/code-simplifier.md +52 -0
- package/.claude/agents/curator.md +189 -245
- package/.claude/agents/documentor.md +147 -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/audit-docs.md +94 -0
- package/.claude/commands/continue.md +120 -0
- package/.claude/commands/create-docs.md +100 -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/plan.md +199 -102
- package/.claude/commands/validate.md +11 -0
- package/.claude/commands/whats-next.md +106 -134
- package/.claude/envoy/envoy +11 -14
- package/.claude/envoy/package-lock.json +1388 -0
- package/.claude/envoy/package.json +29 -0
- package/.claude/envoy/src/cli.ts +126 -0
- package/.claude/envoy/src/commands/base.ts +216 -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 +187 -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/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 +594 -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/watcher.ts +167 -0
- package/.claude/envoy/tsconfig.json +21 -0
- 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 +37 -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/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/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 +110 -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,587 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
Common issues and solutions when working with hooks.
|
|
4
|
+
|
|
5
|
+
## Hook Not Triggering
|
|
6
|
+
|
|
7
|
+
### Symptom
|
|
8
|
+
Hook never executes, even when expected event occurs.
|
|
9
|
+
|
|
10
|
+
### Diagnostic steps
|
|
11
|
+
|
|
12
|
+
**1. Enable debug mode**
|
|
13
|
+
```bash
|
|
14
|
+
claude --debug
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Look for:
|
|
18
|
+
```
|
|
19
|
+
[DEBUG] Getting matching hook commands for PreToolUse with query: Bash
|
|
20
|
+
[DEBUG] Found 0 hooks
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**2. Check hook file location**
|
|
24
|
+
|
|
25
|
+
Hooks must be in:
|
|
26
|
+
- Project: `.claude/hooks.json`
|
|
27
|
+
- User: `~/.claude/hooks.json`
|
|
28
|
+
- Plugin: `{plugin}/hooks.json`
|
|
29
|
+
|
|
30
|
+
Verify:
|
|
31
|
+
```bash
|
|
32
|
+
cat .claude/hooks.json
|
|
33
|
+
# or
|
|
34
|
+
cat ~/.claude/hooks.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**3. Validate JSON syntax**
|
|
38
|
+
|
|
39
|
+
Invalid JSON is silently ignored:
|
|
40
|
+
```bash
|
|
41
|
+
jq . .claude/hooks.json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If error: fix JSON syntax.
|
|
45
|
+
|
|
46
|
+
**4. Check matcher pattern**
|
|
47
|
+
|
|
48
|
+
Common mistakes:
|
|
49
|
+
|
|
50
|
+
❌ Case sensitivity
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"matcher": "bash" // Won't match "Bash"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
✅ Fix
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"matcher": "Bash"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
❌ Missing escape for regex
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"matcher": "mcp__memory__*" // Literal *, not wildcard
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
✅ Fix
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"matcher": "mcp__memory__.*" // Regex wildcard
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**5. Test matcher in isolation**
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
node -e "console.log(/Bash/.test('Bash'))" # true
|
|
84
|
+
node -e "console.log(/bash/.test('Bash'))" # false
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Solutions
|
|
88
|
+
|
|
89
|
+
**Missing hook file**: Create `.claude/hooks.json` or `~/.claude/hooks.json`
|
|
90
|
+
|
|
91
|
+
**Invalid JSON**: Use `jq` to validate and format:
|
|
92
|
+
```bash
|
|
93
|
+
jq . .claude/hooks.json > temp.json && mv temp.json .claude/hooks.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Wrong matcher**: Check tool names with `--debug` and update matcher
|
|
97
|
+
|
|
98
|
+
**No matcher specified**: If you want to match all tools, omit the matcher field entirely:
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"hooks": {
|
|
102
|
+
"PreToolUse": [
|
|
103
|
+
{
|
|
104
|
+
"hooks": [...] // No matcher = all tools
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Command Hook Failing
|
|
114
|
+
|
|
115
|
+
### Symptom
|
|
116
|
+
Hook executes but fails with error.
|
|
117
|
+
|
|
118
|
+
### Diagnostic steps
|
|
119
|
+
|
|
120
|
+
**1. Check debug output**
|
|
121
|
+
```
|
|
122
|
+
[DEBUG] Hook command completed with status 1: <error message>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Status 1 = command failed.
|
|
126
|
+
|
|
127
|
+
**2. Test command directly**
|
|
128
|
+
|
|
129
|
+
Copy the command and run in terminal:
|
|
130
|
+
```bash
|
|
131
|
+
echo '{"session_id":"test","tool_name":"Bash"}' | /path/to/your/hook.sh
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**3. Check permissions**
|
|
135
|
+
```bash
|
|
136
|
+
ls -l /path/to/hook.sh
|
|
137
|
+
chmod +x /path/to/hook.sh # If not executable
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**4. Verify dependencies**
|
|
141
|
+
|
|
142
|
+
Does the command require tools?
|
|
143
|
+
```bash
|
|
144
|
+
which jq # Check if jq is installed
|
|
145
|
+
which osascript # macOS only
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Common issues
|
|
149
|
+
|
|
150
|
+
**Missing executable permission**
|
|
151
|
+
```bash
|
|
152
|
+
chmod +x /path/to/hook.sh
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Missing dependencies**
|
|
156
|
+
|
|
157
|
+
Install required tools:
|
|
158
|
+
```bash
|
|
159
|
+
# macOS
|
|
160
|
+
brew install jq
|
|
161
|
+
|
|
162
|
+
# Linux
|
|
163
|
+
apt-get install jq
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Bad path**
|
|
167
|
+
|
|
168
|
+
Use absolute paths:
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"command": "/Users/username/.claude/hooks/script.sh"
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Or use environment variables:
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/script.sh"
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Timeout**
|
|
183
|
+
|
|
184
|
+
If command takes too long:
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"command": "/path/to/slow-script.sh",
|
|
188
|
+
"timeout": 120000 // 2 minutes
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Prompt Hook Not Working
|
|
195
|
+
|
|
196
|
+
### Symptom
|
|
197
|
+
Prompt hook blocks everything or doesn't block when expected.
|
|
198
|
+
|
|
199
|
+
### Diagnostic steps
|
|
200
|
+
|
|
201
|
+
**1. Check LLM response format**
|
|
202
|
+
|
|
203
|
+
Debug output shows:
|
|
204
|
+
```
|
|
205
|
+
[DEBUG] Hook command completed with status 0: {"decision": "approve", "reason": "ok"}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Verify JSON is valid.
|
|
209
|
+
|
|
210
|
+
**2. Check prompt structure**
|
|
211
|
+
|
|
212
|
+
Ensure prompt is clear:
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"prompt": "Evaluate: $ARGUMENTS\n\nReturn JSON: {\"decision\": \"approve\" or \"block\", \"reason\": \"why\"}"
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**3. Test prompt manually**
|
|
220
|
+
|
|
221
|
+
Submit similar prompt to Claude directly to see response format.
|
|
222
|
+
|
|
223
|
+
### Common issues
|
|
224
|
+
|
|
225
|
+
**Ambiguous instructions**
|
|
226
|
+
|
|
227
|
+
❌ Vague
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"prompt": "Is this ok? $ARGUMENTS"
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
✅ Clear
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"prompt": "Check if this command is safe: $ARGUMENTS\n\nBlock if: contains 'rm -rf', 'mkfs', or force push to main\n\nReturn: {\"decision\": \"approve\" or \"block\", \"reason\": \"explanation\"}"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Missing $ARGUMENTS**
|
|
242
|
+
|
|
243
|
+
❌ No placeholder
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"prompt": "Validate this command"
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
✅ With placeholder
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"prompt": "Validate this command: $ARGUMENTS"
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Invalid JSON response**
|
|
258
|
+
|
|
259
|
+
The LLM must return valid JSON. If it returns plain text, the hook fails.
|
|
260
|
+
|
|
261
|
+
Add explicit formatting instructions:
|
|
262
|
+
```
|
|
263
|
+
IMPORTANT: Return ONLY valid JSON, no other text:
|
|
264
|
+
{
|
|
265
|
+
"decision": "approve" or "block",
|
|
266
|
+
"reason": "your explanation"
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Hook Blocks Everything
|
|
273
|
+
|
|
274
|
+
### Symptom
|
|
275
|
+
Hook blocks all operations, even safe ones.
|
|
276
|
+
|
|
277
|
+
### Diagnostic steps
|
|
278
|
+
|
|
279
|
+
**1. Check hook logic**
|
|
280
|
+
|
|
281
|
+
Review the script/prompt logic. Is the condition too broad?
|
|
282
|
+
|
|
283
|
+
**2. Test with known-safe input**
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
echo '{"tool_name":"Read","tool_input":{"file_path":"test.txt"}}' | /path/to/hook.sh
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Expected: `{"decision": "approve"}`
|
|
290
|
+
|
|
291
|
+
**3. Check for errors in script**
|
|
292
|
+
|
|
293
|
+
Add error output:
|
|
294
|
+
```bash
|
|
295
|
+
#!/bin/bash
|
|
296
|
+
set -e # Exit on error
|
|
297
|
+
input=$(cat)
|
|
298
|
+
# ... rest of script
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Solutions
|
|
302
|
+
|
|
303
|
+
**Logic error**
|
|
304
|
+
|
|
305
|
+
Review conditions:
|
|
306
|
+
```bash
|
|
307
|
+
# Before (blocks everything)
|
|
308
|
+
if [[ "$command" != "safe_command" ]]; then
|
|
309
|
+
block
|
|
310
|
+
fi
|
|
311
|
+
|
|
312
|
+
# After (blocks dangerous commands)
|
|
313
|
+
if [[ "$command" == *"dangerous"* ]]; then
|
|
314
|
+
block
|
|
315
|
+
fi
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Default to approve**
|
|
319
|
+
|
|
320
|
+
If logic is complex, default to approve on unclear cases:
|
|
321
|
+
```bash
|
|
322
|
+
# Default
|
|
323
|
+
decision="approve"
|
|
324
|
+
reason="ok"
|
|
325
|
+
|
|
326
|
+
# Only change if dangerous
|
|
327
|
+
if [[ "$command" == *"rm -rf"* ]]; then
|
|
328
|
+
decision="block"
|
|
329
|
+
reason="Dangerous command"
|
|
330
|
+
fi
|
|
331
|
+
|
|
332
|
+
echo "{\"decision\": \"$decision\", \"reason\": \"$reason\"}"
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Infinite Loop in Stop Hook
|
|
338
|
+
|
|
339
|
+
### Symptom
|
|
340
|
+
Stop hook runs repeatedly, Claude never stops.
|
|
341
|
+
|
|
342
|
+
### Cause
|
|
343
|
+
Hook blocks stop without checking `stop_hook_active` flag.
|
|
344
|
+
|
|
345
|
+
### Solution
|
|
346
|
+
|
|
347
|
+
**Always check the flag**:
|
|
348
|
+
```bash
|
|
349
|
+
#!/bin/bash
|
|
350
|
+
input=$(cat)
|
|
351
|
+
stop_hook_active=$(echo "$input" | jq -r '.stop_hook_active')
|
|
352
|
+
|
|
353
|
+
# If hook already active, don't block again
|
|
354
|
+
if [[ "$stop_hook_active" == "true" ]]; then
|
|
355
|
+
echo '{"decision": undefined}'
|
|
356
|
+
exit 0
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
# Your logic here
|
|
360
|
+
if [ tests_passing ]; then
|
|
361
|
+
echo '{"decision": "approve", "reason": "Tests pass"}'
|
|
362
|
+
else
|
|
363
|
+
echo '{"decision": "block", "reason": "Tests failing"}'
|
|
364
|
+
fi
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Or in prompt hooks:
|
|
368
|
+
```json
|
|
369
|
+
{
|
|
370
|
+
"prompt": "Evaluate stopping: $ARGUMENTS\n\nIMPORTANT: If stop_hook_active is true, return {\"decision\": undefined}\n\nOtherwise check if tasks complete..."
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Hook Output Not Visible
|
|
377
|
+
|
|
378
|
+
### Symptom
|
|
379
|
+
Hook runs but output not shown to user.
|
|
380
|
+
|
|
381
|
+
### Cause
|
|
382
|
+
`suppressOutput: true` or output goes to stderr.
|
|
383
|
+
|
|
384
|
+
### Solutions
|
|
385
|
+
|
|
386
|
+
**Don't suppress output**:
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"decision": "approve",
|
|
390
|
+
"reason": "ok",
|
|
391
|
+
"suppressOutput": false
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Use systemMessage**:
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"decision": "approve",
|
|
399
|
+
"reason": "ok",
|
|
400
|
+
"systemMessage": "This message will be shown to user"
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Write to stdout, not stderr**:
|
|
405
|
+
```bash
|
|
406
|
+
echo "This is shown" >&1
|
|
407
|
+
echo "This is hidden" >&2
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Permission Errors
|
|
413
|
+
|
|
414
|
+
### Symptom
|
|
415
|
+
Hook script can't read files or execute commands.
|
|
416
|
+
|
|
417
|
+
### Solutions
|
|
418
|
+
|
|
419
|
+
**Make script executable**:
|
|
420
|
+
```bash
|
|
421
|
+
chmod +x /path/to/hook.sh
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Check file ownership**:
|
|
425
|
+
```bash
|
|
426
|
+
ls -l /path/to/hook.sh
|
|
427
|
+
chown $USER /path/to/hook.sh
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**Use absolute paths**:
|
|
431
|
+
```bash
|
|
432
|
+
# Instead of
|
|
433
|
+
command="./script.sh"
|
|
434
|
+
|
|
435
|
+
# Use
|
|
436
|
+
command="$CLAUDE_PROJECT_DIR/.claude/hooks/script.sh"
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Hook Timeouts
|
|
442
|
+
|
|
443
|
+
### Symptom
|
|
444
|
+
```
|
|
445
|
+
[DEBUG] Hook command timed out after 60000ms
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Solutions
|
|
449
|
+
|
|
450
|
+
**Increase timeout**:
|
|
451
|
+
```json
|
|
452
|
+
{
|
|
453
|
+
"type": "command",
|
|
454
|
+
"command": "/path/to/slow-script.sh",
|
|
455
|
+
"timeout": 300000 // 5 minutes
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Optimize script**:
|
|
460
|
+
- Reduce unnecessary operations
|
|
461
|
+
- Cache results when possible
|
|
462
|
+
- Run expensive operations in background
|
|
463
|
+
|
|
464
|
+
**Run in background**:
|
|
465
|
+
```bash
|
|
466
|
+
#!/bin/bash
|
|
467
|
+
# Start long operation in background
|
|
468
|
+
/path/to/long-operation.sh &
|
|
469
|
+
|
|
470
|
+
# Return immediately
|
|
471
|
+
echo '{"decision": "approve", "reason": "ok"}'
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Matcher Conflicts
|
|
477
|
+
|
|
478
|
+
### Symptom
|
|
479
|
+
Multiple hooks triggering when only one expected.
|
|
480
|
+
|
|
481
|
+
### Cause
|
|
482
|
+
Tool name matches multiple matchers.
|
|
483
|
+
|
|
484
|
+
### Diagnostic
|
|
485
|
+
```
|
|
486
|
+
[DEBUG] Matched 3 hooks for query "Bash"
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Solutions
|
|
490
|
+
|
|
491
|
+
**Be more specific**:
|
|
492
|
+
```json
|
|
493
|
+
// Instead of
|
|
494
|
+
{"matcher": ".*"} // Matches everything
|
|
495
|
+
|
|
496
|
+
// Use
|
|
497
|
+
{"matcher": "Bash"} // Exact match
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Check overlapping patterns**:
|
|
501
|
+
```json
|
|
502
|
+
{
|
|
503
|
+
"hooks": {
|
|
504
|
+
"PreToolUse": [
|
|
505
|
+
{"matcher": "Bash", ...}, // Matches Bash
|
|
506
|
+
{"matcher": "Bash.*", ...}, // Also matches Bash!
|
|
507
|
+
{"matcher": ".*", ...} // Also matches everything!
|
|
508
|
+
]
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Remove overlaps or make them mutually exclusive.
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Environment Variables Not Working
|
|
518
|
+
|
|
519
|
+
### Symptom
|
|
520
|
+
`$CLAUDE_PROJECT_DIR` or other variables are empty.
|
|
521
|
+
|
|
522
|
+
### Solutions
|
|
523
|
+
|
|
524
|
+
**Check variable spelling**:
|
|
525
|
+
- `$CLAUDE_PROJECT_DIR` (correct)
|
|
526
|
+
- `$CLAUDE_PROJECT_ROOT` (wrong)
|
|
527
|
+
|
|
528
|
+
**Use double quotes**:
|
|
529
|
+
```json
|
|
530
|
+
{
|
|
531
|
+
"command": "$CLAUDE_PROJECT_DIR/hooks/script.sh"
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**In shell scripts, use from input**:
|
|
536
|
+
```bash
|
|
537
|
+
#!/bin/bash
|
|
538
|
+
input=$(cat)
|
|
539
|
+
cwd=$(echo "$input" | jq -r '.cwd')
|
|
540
|
+
cd "$cwd" || exit 1
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## Debugging Workflow
|
|
546
|
+
|
|
547
|
+
**Step 1**: Enable debug mode
|
|
548
|
+
```bash
|
|
549
|
+
claude --debug
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
**Step 2**: Look for hook execution logs
|
|
553
|
+
```
|
|
554
|
+
[DEBUG] Executing hooks for PreToolUse:Bash
|
|
555
|
+
[DEBUG] Found 1 hook matchers
|
|
556
|
+
[DEBUG] Executing hook command: /path/to/script.sh
|
|
557
|
+
[DEBUG] Hook command completed with status 0
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
**Step 3**: Test hook in isolation
|
|
561
|
+
```bash
|
|
562
|
+
echo '{"test":"data"}' | /path/to/hook.sh
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
**Step 4**: Check script with `set -x`
|
|
566
|
+
```bash
|
|
567
|
+
#!/bin/bash
|
|
568
|
+
set -x # Print each command before executing
|
|
569
|
+
# ... your script
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Step 5**: Add logging
|
|
573
|
+
```bash
|
|
574
|
+
#!/bin/bash
|
|
575
|
+
echo "Hook started" >> /tmp/hook-debug.log
|
|
576
|
+
input=$(cat)
|
|
577
|
+
echo "Input: $input" >> /tmp/hook-debug.log
|
|
578
|
+
# ... your logic
|
|
579
|
+
echo "Decision: $decision" >> /tmp/hook-debug.log
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
**Step 6**: Verify JSON output
|
|
583
|
+
```bash
|
|
584
|
+
echo '{"decision":"approve","reason":"test"}' | jq .
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
If `jq` fails, JSON is invalid.
|