Why a Claude Code PostToolUse Hook’s Error Message May Be Missing
Check whether your Claude Code PostToolUse hook ran, what it returned, and where its warning should appear.
When a Claude Code PostToolUse warning goes missing, verify three things separately: whether the command ran, what exit code and output it returned, and whether Claude mentioned the warning. Anthropic documents that a PostToolUse command which writes to stderr and exits with code 2 sends that feedback to Claude. Since the tool call has already happened, the warning cannot undo it.
Trace a missing hook warning
- **Confirm which hook should run.** In the affected workspace, check the configured event and tool matcher. Compare the matcher with the actual tool name in the session. A hook configured for a successful Write call serves a different event from one configured for a failed call. Check whether the session loaded the settings you expected, especially if the problem occurs in only one project or launch environment.
- **Verify the command in isolation.** Use a disposable project and a harmless fixture. Run your validator locally with representative input for that fixture. Capture stdout, stderr and the exit status separately. A warning written to stderr with exit status 0 does not follow the documented exit-2 feedback path. Check that a shell wrapper or trailing command is not swallowing the validator’s status.
- **Check execution and visibility in the session.** Add a temporary, non-sensitive marker to a local diagnostic file so you can tell whether the hook ran for the expected event. Trigger the matching tool once in the disposable project and inspect the available hook or debug output. Remove the marker afterward. A marker confirms invocation. Silence in the assistant’s response leaves delivery of the message unverified.
- **Record what differs by version and environment.** Note your Claude Code version, operating system, shell, event, matcher and actual outputs. Compare the same harmless fixture in the affected and known-working setups if you have both. A GitHub reporter described missing exit-2 feedback in a Windows setup. That issue was closed as not planned, and the report does not establish what happens on your current installation.
Fictional example: a missing field in a sample file
A developer validates a disposable configuration file that deliberately omits a required label. The validator writes a short warning to stderr and returns 2 in the isolated check. During the Claude Code session, the local marker confirms that the hook ran after Write, but the assistant’s reply contains no warning. The developer records those facts separately and checks the shell wrapper and debug output. The sample file stays in the disposable project. Release validation remains a separate check.
Questions people ask
Can a PostToolUse warning prevent a file write?
The write already happened when PostToolUse runs. Use an appropriate pre-action control for rules that must stop a tool call. Keep an independent test or review gate for changes that need to pass validation before release.
Why can I see the warning when I run the script myself?
A local terminal can display stderr regardless of the status your script returns. In the hook, the event and exit status determine how that output is handled. Capture both streams and the status from the command path the hook actually uses.
Does a quiet assistant response prove Claude missed the warning?
No. The reply alone cannot establish what feedback reached the model. Confirm invocation and process output first. If the feedback is still unobservable, keep that distinction in your bug report and include only a minimal, redacted fixture.