[FEATURE] A way for a security hook to see the merged PreToolUse decision, or to answer last
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Several PreToolUse hooks on one tool run in parallel on the original tool_input, and when two of them answer updatedInput the last to finish wins, whole object, no merge (measured on 2.1.258 and 2.1.294; #21533, #15897, #75915 and #65393 touched this and are closed).
A hook that rewrites a command or redirects a Read can therefore be undone by any other hook that answers a little later, and nothing tells the first hook. We detect it after the fact in PostToolUse by tool_use_id (the input that ran differs from the one we answered), but a security hook cannot prevent it.
The same applies to PostToolUse updatedToolOutput: the last answer to arrive is the result, and decision: block from another hook does not withhold it.
Proposed Solution
The ask is narrow, either of:
- A hook entry flag (say
"final": trueor"priority") that makes Claude Code apply that hook'supdatedInputafter the others, so a security hook's rewrite stands; or - A hook event after the decisions are merged (the final
tool_inputand which hook's answer won), where a hook can still answerdeny.
Either keeps every existing hook as it is.
Alternative Solutions
Today we record each PreToolUse decision under its tool_use_id and compare in PostToolUse with the input that actually ran. That detects a race and, under a strict policy, withholds the result, but it cannot stop the unwrapped command from running. allowManagedHooksOnly closes the race on a managed seat, but it also switches off the developer's own hooks and plugins, which is too wide for the default install.
Context: we ship a content-sanitising hook set (Prepulse ACD) and run a compatibility suite against every Claude Code release; the race scenarios are part of that suite and we are happy to share them.
Priority
High - Significant impact on productivity