cher": "Write|Edit", "hooks": [{ "type": "command", "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | xargs prettier --write 2>/dev/null || true" }] }] } } ``` ### Adding Permissions User: "Allow npm commands without prompting" 1. **Read**: Existing permissions 2. **Merge**: Add `Bash(npm:*)` to allow array 3. **Result**: Combined with existing allows ### Environment Variables User: "Set DEBUG=true" 1. **Decide**: User settings (global) or project settings? 2. **Read**: Target file 3. **Merge**: Add to env object ```json { "env": { "DEBUG": "true" } } ``` ## Common Mistakes to Avoid 1. **Replacing instead of merging** - Always preserve existing settings 2. **Wrong file** - Ask user if scope is unclear 3. **Invalid JSON** - Validate syntax after changes 4. **Forgetting to read first** - Always read before write ## Troubleshooting Hooks If a hook isn't running: 1. **Check the settings file** - Read ~/.claude/settings.json or .claude/settings.json 2. **Verify JSON syntax** - Invalid JSON silently fails 3. **Check the matcher** - Does it match the tool name? (e.g., "Bash", "Write", "Edit") 4. **Check hook type** - Is it "command", "prompt", or "agent"? 5. **Test the command** - Run the hook command manually to see if it works 6. **Use --debug** - Run `claude --debug` to see hook execution logs