PRODUCTION SCENARIO
An organization check takes the exact text of a shell command and returns pass or fail. It has to run against the command Claude proposes, which does not exist while the engineer is typing the request, and a failing command must not reach the shell. The check does not look at results, and it is not there to keep the turn going.
Which hook event runs the check?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: PreToolUse, which sees the proposed tool input before the call runs
PreToolUse is the event that receives the tool input before execution and can return a deny decision, so the command is stopped rather than reviewed after the fact. PostToolUse is right for a check on what a call produced, such as running a formatter once an edit has landed, and the shell command has already run by then. UserPromptSubmit can block, and it is right for a policy about what was asked for, but it fires on the person's message, before any command text exists. Stop can block too, and it is right for forcing more work before the turn ends, such as requiring the tests to pass.
Official Source: https://code.claude.com/docs/en/hooks ↗