Skip to content

SOP-008: Hooks

DOCUMENT CONTROL

FieldValue
SOP IDSOP-008
Version1.0
StatusActive

Purpose

Configure hooks to customize Claude Code behavior by running scripts at specific lifecycle events.

Hook Types

HookTrigger
PreToolCallBefore any tool execution
PostToolCallAfter tool execution
NotificationOn status notifications
StopWhen 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

  1. Logging - Log all tool executions
  2. Validation - Check commands before running
  3. Notifications - Alert on certain actions
  4. Formatting - Auto-format after file changes

Best Practices

Hook Tips

  1. Keep hooks fast to avoid delays
  2. Test hooks before adding to config
  3. Use specific matchers to limit scope
  4. Log hook errors for debugging

Next Steps

Based on Official Claude Code Documentation