TIL: Claude Code Hooks Fire at Two Very Different Times
I'd been debugging a Claude Code hook that wasn't working the way I expected — it was blocking an action after Claude had already committed to it, rather than steering Claude away from it in the first place. I asked Claude to look at all my hooks and tell me how many had the same problem.
Me: Can you look at my hooks and find other (probably lots) of pretool hooks that fail like that? What's the "flavor" of hooks that means "before you pick a tool to run consider this", as opposed to "if you try to run this, I'll block it"?
Claude: The two "flavors":
event: prompt— fires when the user submits a message, before Claude has picked any tools. This is the "consider this before deciding what to do" flavor. Claude reads it as context during reasoning.
event: bash/event: file— fires after Claude has already decided to run a specific tool. PreToolUse, yes, but post-decision. Claude has already committed to a course of action — the hook is now an obstacle, not guidance.Analyzing your existing hooks:
Hook Event Verdict bead-first prompt ✅ Right flavor — fires before tool selection read-bin-tools-first bash ⚠️ Fires after I've already decided to run the tool infra-change-control bash ❌ Very specific SSH pattern — fires after I've written out the full command use-the-right-tool file ❌ By the time this fires I'm already editing a specific file verify-before-write file / .* ❌ Fires on every file edit — pure noise, I'll start ignoring it What needs changing:
infra-change-controlanduse-the-right-toolshould beevent: prompt— trigger on phrases like "change X on biggie", "update the server", "edit the script".verify-before-writeis probably just noise — worth deleting or making much more targeted.read-bin-tools-firstshould ideally beevent: prompttoo.
Four out of five hooks miscategorized. I'd built a library of "before you do X, consider Y" rules and wired them all to fire after the decision was already made.
This also explains why I was swearing at Claude a lot last month.
The distinction makes sense once you see it: event: prompt is guidance that shapes what Claude decides to do. PreToolUse hooks are gatekeepers that intercept a specific action. Using a gatekeeper to deliver guidance is like posting the directions at the destination.