PreToolUse hook shows 'error' label even when hook passes (exit 0)
Resolved 💬 3 comments Opened Apr 6, 2026 by shlee87 Closed Apr 10, 2026
Bug Description
When a PreToolUse hook runs and passes successfully (exit code 0, no stdout/stderr output), the Claude Code UI displays "PreToolUse:Bash hook error" — suggesting the hook failed when it actually passed.
Steps to Reproduce
- Configure a PreToolUse hook for Bash matcher in
.claude/settings.json:
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "bash -c 'exec node \"$(git rev-parse --show-toplevel)/.claude/hooks/my-hook.js\"'",
"timeout": 10
}
]
}
]
- The hook script reads stdin, checks a condition, and exits 0 (pass) with no output.
- Run a Bash tool call (e.g.,
git commit ...).
- The UI shows:
PreToolUse:Bash hook error
- The command still executes (correctly — since the hook passed), but the "error" label is misleading.
Expected Behavior
- Hook passes (exit 0) → no error label shown, or show "hook passed" / no message at all
- Hook blocks (outputs
{"decision": "block", ...}) → show error/blocked label
Actual Behavior
"error" label is shown regardless of whether the hook passed or blocked.
Impact
This is confusing for users — they see "error" on every Bash command that triggers the hook, even when everything is working correctly. It erodes trust in the hook system and makes real errors hard to distinguish from normal operation.
Environment
- Claude Code CLI (macOS)
- Node.js v23.6.1
- Hook type: PreToolUse with Bash matcher
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗