[BUG] PreToolUse and PostToolUse hooks cannot coexist - PreToolUse silently fails when PostToolUse configured
Bug Description
PreToolUse and PostToolUse hooks cannot coexist in the same configuration. When both hooks are configured, PreToolUse events are silently dropped and never execute, while PostToolUse works correctly.
This appears to be a specific conflict between these two hook types, not a general hook system limitation.
Severity
Critical - Prevents comprehensive tool execution tracking
Steps to Reproduce
- Configure both PreToolUse and PostToolUse hooks in
.claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "/path/to/post_tool_use.sh"
}
]
}
],
"PreToolUse": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "/path/to/pre_tool_use.sh"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "/path/to/stop.sh"
}
]
}
]
}
}
- Start Claude Code session
- Execute any tool (Read, Write, Bash, etc.)
- Check hook logs
Expected Behavior
- PreToolUse hook should fire before tool execution
- PostToolUse hook should fire after tool execution
- Both hooks should log events
Actual Behavior
- ✅ PostToolUse executes correctly
- ✅ Stop executes correctly
- ❌ PreToolUse never executes (silently fails)
- No error messages in Debug Console
- Hook shows as "registered" in
/hookscommand but never fires
Evidence
Test 1: Both hooks configured together
Log output (only PostToolUse and Stop fire):
[2025-11-25 17:47:44] PostToolUse event - tool: Read ✅
[2025-11-25 17:48:00] Stop event ✅
# PreToolUse missing - should fire BEFORE PostToolUse ❌
Test 2: PreToolUse WITHOUT PostToolUse
Configuration:
{
"hooks": {
"Stop": [...],
"PreToolUse": [...] // NO PostToolUse
}
}
Log output (PreToolUse works!):
[2025-11-25 18:08:14] PreToolUse event - tool: Read ✅
[2025-11-25 18:08:23] Stop event ✅
Compatibility Matrix
| Configuration | PreToolUse Works? | PostToolUse Works? | Result |
|--------------|-------------------|-------------------|---------|
| Stop + PostToolUse | N/A | ✅ Yes | ✅ Both work |
| Stop + PreToolUse | ✅ Yes | N/A | ✅ Both work |
| Stop + PostToolUse + PreToolUse | ❌ No | ✅ Yes | ❌ PreToolUse silently fails |
Additional Testing
Through systematic testing, we verified that 8 hooks work simultaneously without issues:
- ✅ PostToolUse
- ✅ Stop
- ✅ SessionStart
- ✅ SessionEnd
- ✅ UserPromptSubmit
- ✅ SubagentStop
- ✅ Notification
- ✅ PreCompact
- ❌ PreToolUse (only when PostToolUse is also configured)
This proves the issue is not a hook count limitation but a specific PreToolUse + PostToolUse conflict.
Environment
- OS: Linux (Ubuntu 24.04 LTS, kernel 6.12.48)
- Claude Code Version: v1.0.51+ (latest as of 2025-11-25)
- Platform: VSCode extension
- Shell: Bash
Hook Script Configuration
Both hook scripts follow best practices:
- ✅ Proper shebang (
#!/bin/bash) - ✅ Read from stdin
- ✅ Parse JSON with jq
- ✅ Exit with code 0 (non-blocking)
- ✅ Scripts are executable
- ✅ Correct permissions
Workaround
Current recommendation: Use only PostToolUse (not both PreToolUse and PostToolUse)
PostToolUse provides sufficient information for monitoring tool execution. While PreToolUse would be preferable for pre-execution validation, it's unusable when PostToolUse is configured.
Related Issues
This issue is distinct from:
- #6305 - Both PreToolUse and PostToolUse not executing (in our case, PostToolUse does work)
- #3148 - Wildcard matcher issue (we use empty string
"") - #4113 - Multi-hook cancellation bug (we're not canceling operations)
This is a new, previously undocumented interaction bug between PreToolUse and PostToolUse specifically.
Impact
- Cannot implement comprehensive tool execution tracking (pre + post)
- Cannot use PreToolUse for permission/validation gates when also tracking completions
- Silent failure makes debugging difficult (no error messages)
- Limits observability and monitoring capabilities
Request
Please investigate why PreToolUse events are dropped when PostToolUse is configured. These hooks should be able to coexist since they track different lifecycle stages (before vs. after tool execution).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗