Claude Code · tool · fg-0483

Claude Code PreToolUse hook exits 1 but the tool call runs anyway

PreToolUse:Bash hook error notice with 'Failed with non-blocking status code:' and the command still runs

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

Cause

Only exit code 2 blocks. Exit 1, any other code, a script that cannot start, or stdout JSON that fails to parse is a non-blocking error, so the action proceeds.

Fix

Exit 2 with the reason on stderr to block, or return a JSON decision. On Claude Code v2.1.295 or later, set onFailure to block on policy hooks so a broken or missing script fails closed; older versions ignore the field.

Apply

# hook script
echo "Blocked: force push is not allowed" >&2
exit 2
# settings.json hook entry
{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/policy.sh", "onFailure": "block" }

Affects: Claude Code hooks, as of 2026-10; onFailure requires v2.1.295 or later

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp