Hooks config in settings.json silently stripped by active sessions
Resolved 💬 3 comments Opened Apr 7, 2026 by Rektoooooo Closed Apr 11, 2026
Bug Description
When adding a "hooks" key to ~/.claude/settings.json while a Claude Code session is running, the hooks configuration is silently removed within seconds. This happens because active sessions keep an in-memory copy of settings and overwrite the file on any save event, dropping the externally-added hooks key.
Steps to Reproduce
- Open a Claude Code session (or multiple sessions/tabs)
- Add a valid
hooksconfiguration to~/.claude/settings.json(via any method: manual edit, script, or Claude's Edit tool) - Verify it's present:
cat ~/.claude/settings.json | python3 -c "import json,sys; print('hooks' in json.load(sys.stdin))"→True - Wait a few seconds or trigger any settings write (permission grant, etc.)
- Check again →
False— thehookskey has been removed
Expected Behavior
- The
hookskey should persist insettings.json - Active sessions should either watch for external file changes and reload, or preserve unknown/unmanaged keys when writing back
Actual Behavior
- The
hookskey is silently stripped every time an active session writes its in-memory settings state back to disk /hooksdialog shows "0 hooks configured" even immediately after adding them- All other keys (
model,permissions,statusLine, etc.) are preserved because they exist in the session's in-memory state
Workaround
Adding hooks to ~/.claude/settings.local.json instead of settings.json works — this file is not overwritten by active sessions.
Environment
- OS: macOS (Darwin 25.3.0)
- Claude Code: Latest version (as of April 2026)
- Shell: zsh
Additional Context
- Confirmed with only a single session open — the current session itself overwrites the file
- The hooks JSON is valid (verified with
python3 -m json.tool) - Multiple methods tried (Edit tool, python script, manual edit) — all get stripped
- The issue is particularly problematic because
/hooksdialog itself says "edit settings.json directly" to configure hooks, but settings.json is the file being overwritten
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗