[BUG] PostToolUse Hook Exit Code 1 Blocks Claude Execution
Environment
- Platform: Anthropic API (via claude code max20)
- Claude CLI version: 1.0.64
- Operating System: macOS
- Terminal: Terminal App
Bug Description
PostToolUse hooks with exit code 1 block Claude's execution despite documentation stating they are "non-blocking" and "execution continues".
Steps to Reproduce
- Create .claude/settings.json:
{
"hooks": {
"PostToolUse": [{
"matcher": "Read",
"hooks": [{
"type": "command",
"command": "./test-hook.sh"
}]
}]
}
}
- Create test-hook.sh:
#!/bin/bash
echo "Warning: This is a non-blocking error" >&2
exit 1
- Make it executable: chmod +x test-hook.sh
- Ask Claude: "Read any file, then list the current directory"
- Observe Claude is blocked after the Read operation
Expected Behavior
According to documentation: "Other exit codes: Non-blocking error. stderr is shown to the user and execution continues." https://docs.anthropic.com/en/docs/claude-code/hooks
Claude should:
- Execute Read tool
- Show hook's stderr to user
- Continue with ls command
Actual Behavior
- Read tool executes
- User sees: PostToolUse:Read [./test-hook.sh] failed with non-blocking status code 1: Warning: This is a non-blocking error
- Claude is blocked - cannot execute ls or any other command
- User must type a response before Claude can continue
Additional Context
- Tested exit codes 0, 1, 2, 3 - only exit 0 and 2 allow Claude to continue
- This forces hooks to use exit 0 for all warnings/errors, losing the ability to show messages to users
- Documentation reference: https://docs.anthropic.com/en/docs/claude-code/hooks
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗