Claude Code hooks: timing changes the control
Documented pre-tool and post-tool events serve different purposes, even when both run a check.
Use PreToolUse when your check needs to act before a tool runs. Start by choosing that event: a check attached to PostToolUse sees an action that has already happened. The Claude Code hooks documentation explains these lifecycle points as an existing capability, rather than a newly announced feature.
Hooks connect lifecycle events to configured behavior. PreToolUse runs before a tool call, while PostToolUse operates after execution. Selecting the event determines when a check can act. A post-action report can reveal a problem, but it should not be described as a preventive barrier merely because it is automated.
The documentation supports different handler types, including commands and model-backed mechanisms. Consequently, a hook is not necessarily a deterministic rule. For an objective condition, a suitable command may provide a more predictable check than an open-ended language evaluation.
- Choose an event and write down the outcome your check should produce.
- Read that event's documented failure behavior before relying on it to block anything. Check which decisions the handler can control at that point; a report after execution cannot undo its timing.