Skip to content
BENIBIX Learn

PreToolUse vs PostToolUse

People think both hooks can stop a bad tool call. Only one can. PreToolUse fires before the tool runs, so it can allow, deny or ask. PostToolUse fires after the tool has run, so the change is already made. It can only tell Claude what went wrong. Guard in the first, check and tidy in the second.

AI⌨️ Claude Code

PreToolUse Hook

The event before a tool runs. A hook can say yes, no or ask.

PreToolUse is the hook event that fires after Claude picks a tool call and before it runs. A hook here can allow the call, deny it, ask you, or defer it. It can also change the tool's input. When hooks disagree, deny wins, then defer, then ask, then allow. Your deny and ask rules are still checked, whatever the hook says.

Example
Jack's hook reads each Bash command. If it touches the live database, the hook denies it and tells Claude why.
Why it matters
It is the last stop before a tool acts. Your own code can look at the exact call there.
Full entry
AI⌨️ Claude Code

PostToolUse Hook

The event right after a tool works. It is often used to tidy code.

PostToolUse is the hook event that fires right after a tool call works. It is the usual place to tidy code, lint it or run a quick test after Claude edits a file. The tool has already run, so the hook cannot undo it. It can send Claude a note to act on. It does that by exiting 2, or with a block decision and a reason.

Example
After each edit, Emma's hook runs the linter. When it finds an error, Claude sees the message and fixes it at once.
Why it matters
It catches mistakes the moment they are made, while Claude still has the file in mind.
Full entry

In one line

PreToolUse Hook
The event before a tool runs. A hook can say yes, no or ask.
PostToolUse Hook
The event right after a tool works. It is often used to tidy code.