Hooks are policy in code
Hooks are user-defined callbacks that fire on tool events: PreToolUse (before a tool runs), PostToolUse (after), UserPromptSubmit, Stop, and others. They let you enforce policy, log activity, redact arguments, or veto a call entirely without changing the model's behavior.
Why they beat in-prompt rules
You can ask the model 'never run rm -rf' in the system prompt and it will mostly comply. A hook that returns a refusal on any rm -rf invocation is a hard guarantee. Use prompt for guidance; use hooks for invariants.
Three patterns to start with
(1) Logging hook — record every tool call to your structured log. (2) Redaction hook — scrub secrets out of arguments before they hit the tool. (3) Veto hook — refuse calls that match a deny pattern. cwkPippa's hooks include all three for different concerns.