PreToolUse hook shows 'error' label even for successful (exit 0) hook runs

Open 💬 12 comments Opened Jan 9, 2026 by rcaferraz

Description

When a PreToolUse hook runs and exits successfully with code 0, Claude Code displays the output with a PreToolUse:Bash hook error prefix, which is misleading since no error occurred.

Steps to Reproduce

  1. Create a PreToolUse hook in .claude/settings.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": ".claude/hooks/my-hook.py"
          }
        ]
      }
    ]
  }
}
  1. Create a hook script that exits 0 (success) without output:
#!/usr/bin/env python3
import json
import sys

input_data = json.load(sys.stdin)
# Allow all commands
sys.exit(0)
  1. Run any Bash command in Claude Code

Expected Behavior

When the hook exits with code 0 and produces no output, there should be no "error" label shown, or it should show something like "PreToolUse:Bash hook" (without "error").

Actual Behavior

Every Bash command shows PreToolUse:Bash hook error in the output, even though the hook succeeded and the command was allowed:

⏺ Bash(git status)
  ⎿  PreToolUse:Bash hook error
  ⎿  On branch main
     ...

Impact

This is cosmetic but confusing - users may think their hooks are failing when they're working correctly.

View original on GitHub ↗

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