🪝Hooks·Hook Events1/4
📖 Concept

Deterministic guardrails

Hooks let you run shell commands at fixed points in Claude's lifecycle — independent of the model deciding to. Use them to auto-format on edit, block forbidden commands, send notifications, or log every tool call.

{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{ "type": "command", "command": "bun run format" }]
    }]
  }
}
  • PreToolUse — fires BEFORE a tool runs (can block by exiting non-zero)
  • PostToolUse — fires AFTER a tool runs (great for format/lint)
  • UserPromptSubmit, Stop, SubagentStop, Notification