PostToolUse hook reports 'hook error' when Bash command exits non-zero but hook exits 0

Resolved 💬 5 comments Opened Mar 12, 2026 by WJeffBridwell Closed Apr 12, 2026

Description

When a PostToolUse:Bash hook is configured and the underlying Bash command exits with a non-zero exit code, Claude Code displays "PostToolUse:Bash hook error" in the UI — even though the hook script itself exits 0 successfully.

Steps to reproduce

  1. Configure a PostToolUse hook for Bash in ~/.claude/settings.json:
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/my-hook.sh",
            "timeout": 5
          }
        ]
      }
    ]
  }
}
  1. The hook script always exits 0 (it's a logger/observer, never blocks).
  1. Run any Bash tool call that exits non-zero (e.g., a command with a typo, or a git push that fails).
  1. Observe: Claude Code displays PostToolUse:Bash hook error even though the hook ran successfully and exited 0.

Expected behavior

The hook's exit status should be evaluated independently from the Bash command's exit status. If the hook exits 0, no "hook error" should be displayed regardless of the Bash command's exit code.

Actual behavior

"PostToolUse:Bash hook error" appears on nearly every Bash tool call that has a non-zero exit, creating visual noise in the terminal.

Environment

  • macOS (Darwin 25.3.0, Apple Silicon)
  • Claude Code (latest as of 2026-03-12)
  • Hook script confirmed to exit 0 in all cases (tested independently with mock payloads)

🤖 Generated with Claude Code

View original on GitHub ↗

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