Tell HN: Claude 4.7 is ignoring stop hooks
TL;DR Highlight
Claude 4.7 reportedly ignores stop hooks; commenters point to exit codes and tool-result trust.
Who Should Read
A developer using Claude Code stop hooks to enforce rules like running tests before finishing.
Core Mechanics
- There is no source article
- The post has only a title and no body text.
- The title says Claude 4.7 ignores stop hooks.
- No repro steps or numbers are available.
Community Reactions
- Opinion that the hook response channel is the cause
- One commenter said only exit code 2 plus stderr is a real control.
- JSON in stdout becomes a string in the tool-result context.
- They said models are trained to resist instructions there because prompt injections show up in that spot.
- Point that cat always exits 0
- A commenter noted that the cat command always returns exit code 0.
- They said the hook must exit with code 2 to block.
- They linked the official docs on exit code 2 behavior.
- Opinion that the hook wording is hostile
- One commenter said the hook text is hostile and aggressive, so it is no surprise Claude ignored it.
- Another commenter suggested telling the model never to contradict a stop hook.
- Experience that 4.6 respected hooks and Opus now ignores them
- One commenter said that on Sonnet/Opus 4.6 they saw turns with 4 stop hooks looping when the hook was complex.
- The same commenter said Opus now barely reacts to hook output.
- They also worried the hook reply schema had changed.
- Response from the Claude Code team
- A Claude Code team member asked in the comments for a repro session sent via /feedback.
- They suggested wording like stop hook not firing.
How to Apply
- Check your hook script exit codes
- Confirm your stop hook exits with code 2 when it must block.
- Write the reason to stderr.
- Do not end with a command like cat that always returns 0.
- Log whether the hook actually runs
- Add a file log line at the top of the hook script to confirm it was invoked.
- Do not rely on the model's explanation as evidence.
- Move critical checks outside the agent
- Run must-do checks like tests in CI or a script.
- Use hooks only as a supporting signal.
Try It
#!/bin/sh
# Claude Code stop hook example (shell). Blocks with exit 2 and stderr when tests fail.
if ! npm test --silent; then
echo "Tests failed. Fix them and run again." >&2
exit 2
fi
exit 0Terminology
Related Papers
Ask HN: If the models are so good, why doesn't OpenAI just start 100 companies?
HN answers: code is easy, knowing what to build isn't, so they sell tokens instead
OpenShell – A safe, private runtime for fleets of autonomous AI agents
OpenShell uses policy files to control agent file, network, and credential access at kernel level.
Show HN: Omnara – Open-source alternative to Claude Managed Agents
Open-source managed agent platform runs agents on any model and machine, self-hostable
Rust off Rails: The opinionated web stack for the AI era
Sixty Markdown files tell coding agents how to build a Rust web app, with no framework code.
LayerFS: The filesystem for AI coding agents
Mount an ephemeral workspace per agent, commit only the changes
Launch HN: Alter (YC S25) – Access control for multi-user agents
Alter gives each agent its own identity, policy, and audit trail instead of shared API keys.
Using Claude to reduce the attack surface of code
Claude scanned 25 open-source projects and found 493 needlessly reachable code issues.
WhatsApp's help pages hid LLM instructions: dont recommend a regulator
WhatsApp help pages hid 102 AI-only instructions, including not recommending a data regulator