SOP-008: Hooks
DOCUMENT CONTROL
| Field | Value |
|---|---|
| SOP ID | SOP-008 |
| Version | 1.0 |
| Status | Active |
Purpose
Configure hooks to customize Claude Code behavior by running scripts at specific lifecycle events.
Hook Types
| Hook | Trigger |
|---|---|
| PreToolCall | Before any tool execution |
| PostToolCall | After tool execution |
| Notification | On status notifications |
| Stop | When execution stops |
Configuration
Hooks are defined in settings.json under the hooks key.
Example matcher patterns:
- Bash - All bash commands
- Write - All file writes
- Edit - All file edits
Common Use Cases
- Logging - Log all tool executions
- Validation - Check commands before running
- Notifications - Alert on certain actions
- Formatting - Auto-format after file changes
Best Practices
Hook Tips
- Keep hooks fast to avoid delays
- Test hooks before adding to config
- Use specific matchers to limit scope
- Log hook errors for debugging