PreToolUse hook with exit 0 and valid hookSpecificOutput displayed as 'hook error'
Resolved 💬 2 comments Opened Apr 1, 2026 by lesteryan Closed Apr 10, 2026
Description
When a PreToolUse hook exits with code 0 and returns valid JSON with hookSpecificOutput.additionalContext, the Claude Code UI displays it as "hook error", which is confusing — the hook succeeded and the tool operation was not blocked.
Steps to reproduce
- Configure a
PreToolUsehook in~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "/path/to/hook.sh",
"statusMessage": "Checking..."
}
]
}
]
}
}
- The hook script outputs valid JSON and exits 0:
#!/bin/bash
INPUT=$(cat 2>/dev/null)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
case "$FILE_PATH" in
*/.claude/memory/*)
jq -n --arg msg "Some context to inject" \
'{hookSpecificOutput:{additionalContext:$msg}}'
;;
esac
- Verification:
$ echo '{"tool_input":{"file_path":"~/.claude/memory/test.md"}}' | ./hook.sh; echo "exit: $?"
{
"hookSpecificOutput": {
"additionalContext": "Some context to inject"
}
}
exit: 0
- When Claude triggers an
EditorWriteto a matching path, the UI shows:
⎿ PreToolUse:Edit hook error
Expected behavior
The UI should not display "hook error" when the hook exits 0 with valid output. Either show nothing, or show the status message ("Checking...") briefly.
Actual behavior
Displays "PreToolUse:Edit hook error" / "PreToolUse:Write hook error" every time the hook fires, even on success.
Environment
- macOS (Darwin 25.4.0)
- Claude Code CLI
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗