PreToolUse hook shows 'error' label even when hook passes (exit 0)

Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Apr 6, 2026 · 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

  1. 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
      }
    ]
  }
]
  1. The hook script reads stdin, checks a condition, and exits 0 (pass) with no output.
  1. Run a Bash tool call (e.g., git commit ...).
  1. The UI shows: PreToolUse:Bash hook error
  1. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗