Skip to content
BENIBIX Learn

PreToolUse Hook

AI⌨️ Claude CodeConfiguration

Also known as PreToolUse, pre tool use hook

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

Think of it like

It is like a guard who checks a bag before it goes through the gate.

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.

Definition

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 code

json
{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "Use the staging database, not prod."
  }
}
What a hook prints to deny a call.
Four answers, and the order that settles a tie.

Common mistake

Thinking a hook's allow beats a deny rule. Deny and ask rules are checked anyway.

Key takeaways

  1. 1
    Before the tool runs. Last stop.
  2. 2
    Allow, deny, ask, defer. Four answers.
  3. 3
    Rules still apply. Deny wins.

Compare