[BUG] UserPromptSubmit and PostToolUse hooks fire intermittently on Windows 11 — same-matcher hooks have inconsistent trigger rates
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
UserPromptSubmit hooks fire intermittently on Windows 11. Multiple hooks registered under the same matcher show wildly inconsistent trigger rates. PostToolUse hooks for Edit also show intermittent firing.
Previous behavior (CC 2.1.81): hooks never fired (0%).
Current behavior (latest CC): hooks fire, but unreliably — the simplest script fires 100% while heavier scripts in the same matcher fire ~18%.
Evidence (single session, 2026-03-23)
Three hooks registered under the same UserPromptSubmit entry with matcher: "":
| Hook | Complexity | Expected | Actual | Rate |
|------|-----------|:--------:|:------:|:----:|
| user_prompt_trace.py (6 imports, write 1 event) | Low | 11 | 11 | 100% |
| router_prefilter.py (7 imports incl. hashlib/re, regex classify + trace write) | Medium | 11 | 2 | 18% |
| skill_preflight.py (8 imports, JSON registry load + regex match) | Medium | 11 | ~2-3 | ~20% |
Additionally, PostToolUse hooks for Edit:
| Hook | Expected | Actual | Rate |
|------|:--------:|:------:|:----:|
| post_tool_trace.py on Edit | 7 | 1 | 14% |
All scripts execute correctly when invoked manually. The matcher config is correct (Edit is explicitly listed). Other PostToolUse matchers (for Read, Grep, Glob) also show some missing events but at a lower loss rate.
Key Observation
The lightest script (fewest imports, minimal logic) fires 100%. Heavier scripts in the same matcher entry fire ~18-20%. This pattern suggests:
- A timeout or resource contention issue when CC runs multiple hooks concurrently
- Or a Python startup overhead issue on Windows (interpreter startup + imports can exceed 1-2s)
All hooks have timeout: 5 (seconds). The actual classification logic runs in <0.1ms — overhead is entirely in Python startup + module imports.
Environment
| Component | Version |
|-----------|---------|
| Claude Code CLI | Latest (post-2.1.81) |
| OS | Windows 11 Home 10.0.26200 |
| Shell | Git Bash (MINGW64) |
| Python | 3.13 |
| Working directory | Non-ASCII path (contains Japanese characters) |
Hook Configuration
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{ "type": "command", "command": "python .../router_prefilter.py", "timeout": 5 },
{ "type": "command", "command": "python .../skill_preflight.py", "timeout": 5 },
{ "type": "command", "command": "python .../user_prompt_trace.py", "timeout": 5 }
]
}
]
}
}
What Should Happen?
All hooks in the same matcher entry should fire for every matching event. Trigger rate should be 100% for all hooks, not just the lightest one.
Steps to Reproduce
- On Windows 11, register 3 UserPromptSubmit hooks with varying complexity (import count)
- Have each write a timestamped event to a shared trace file
- Send 10+ prompts
- Compare trigger counts — the lightest script fires every time, heavier ones miss most invocations
Related Issues
- #10450 — "No hook is working on Windows" (closed by bot)
- #14219 — "[Windows 11] All hooks fail silently" (closed as dup)
- #17277 — "UserPromptSubmit not triggering consistently" (closed, said improved in 2.1.3)
Is this a regression?
Partial improvement from 2.1.81 (0% → ~18-100% depending on script complexity), but still far from reliable.
Claude Code Version
Latest (post-2.1.81)
Platform
Anthropic API (direct)
Operating System
Windows
Terminal/Shell
Windows Terminal + Git Bash
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗