Five hook events
- PreToolUse — before a tool call; can block or rewrite args
- PostToolUse — after a tool call; typical use is audit / notify
- UserPromptSubmit — before user submits a prompt; can inject context
- Stop — agent ends naturally; cleanup hook
- Notification — agent needs user input — can forward to external systems
A hook that blocks Bash from making outbound requests
{
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "node check-no-curl.js"
}]
}]
}Design principles
- Pre = prevention, Post = record
- Don’t do heavy work in a hook (it runs synchronously)
- A failing hook blocks the agent by default — mind the timeout
- Write hook logs into the vault for postmortems