[BUG] ConfigChange hook emitting blocking decision is not respected by claude code CLI
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [ ] I am using the latest version of Claude Code
What's Wrong?
I've created a ConfigChange hook that checks if the settings.json files are valid JSON (common pitfall: editing the settings mid-session) and the hook is supposed to block if it isn't.
Through the hook script's logging utility I can see that it does fire and does report broken JSON. Testing the hook from the command line shows the same behavior.
Both emitting a JSON decision to STDOUT, and exiting with code 2 fails to interrupt the session in the face of a broken settings.json
The hook is part of a suite of hooks that are also used on PreToolUse and elsewhere, using the same library code, and all of those work correctly. This seems to be a clear problem in how the CLI handles the return from the ConfigChange hook.
What Should Happen?
The session should immediately interrupt upon a ConfigChange hook outputting a blocking JSON decision or exiting with code 2.
Error Messages/Logs
Steps to Reproduce
- Add a ConfigChange hook to the project settings
.claude/settings.jsonwith the command"exit 2"to output a blocking exit code - Run a claude code session (use a dummy first prompt like 'Hi claude')
- Edit the
.claude/settings.jsonin some way
and
- Add a ConfigChange hook to the project settings
.claude/settings.jsonwith the command"echo '{\"decision\":\"block\",\"reason\":\"none\"}'"to output a blocking decision to STDOUT - Run a claude code session (use a dummy first prompt like 'Hi claude')
- Edit the
.claude/settings.jsonin some way
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.117
Claude Code Version
2.1.196
Platform
Other
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
This is a pretty critical security flaw.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗