Intermediate
Open
Pro
Choosing the Right Hook Event for a Guardrail
A team wants three guardrails on their shared Claude Code setup:
- Never let an edit touch
prod-config.yaml. - Every file Claude edits should be auto-formatted with the project's formatter.
- Whenever Claude finishes a turn, verify the test suite still passes and, if not, feed the failure back so Claude keeps working instead of reporting done.
For each guardrail, name the correct hook event, explain why the "obvious" alternative event would not work correctly, and sketch the key exit-code/JSON behavior the hook needs.
Share this question