PreToolUse/PostToolUse hooks always show 'hook error' on Windows despite exit 0
Summary
On Windows 11 with Claude Code 2.1.96, all PreToolUse and PostToolUse hooks display "hook error" in the transcript even when they exit with code 0 and produce correct output. SessionStart and UserPromptSubmit hooks display "success" correctly.
Reproduction
- Windows 11 Pro (10.0.26200), shell: Git Bash
- Claude Code 2.1.96
- Add a minimal PreToolUse hook to
.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node -e \"process.exit(0)\""
}
]
}
]
}
}
- Run any Bash command in Claude Code
- Observe:
PreToolUse:Bash hook errorappears in transcript
What was tested
| Hook variant | Exit code | Stdout | Stderr | Result |
|---|---|---|---|---|
| node -e "process.exit(0)" | 0 | none | none | error |
| bash -c "exit 0" | 0 | none | none | error |
| bash -c "cat; exit 0" (stdin passthrough) | 0 | JSON | none | error |
| Node script outputting {} | 0 | {} | none | error |
| Node script with stderr + exit 0 | 0 | JSON | text | error |
All hooks execute correctly (verified via log files and side effects). The "hook error" label is purely a display issue.
Expected behavior
Hooks exiting with code 0 should display "hook success" (or no message), matching the behavior of SessionStart and UserPromptSubmit hooks.
Impact
Every tool use (Bash, Read, Edit, Write) generates 8-14 "hook error" lines in the transcript, making it very noisy and hard to distinguish real errors from cosmetic ones.
Environment
- OS: Windows 11 Pro 10.0.26200
- Shell: Git Bash (MINGW64)
- Claude Code: 2.1.96
- Node: v24.x
- Hooks tested with both
nodeandbashcommands
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗