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

  1. Open a Claude Code session (or multiple sessions/tabs)
  2. Add a valid hooks configuration to ~/.claude/settings.json (via any method: manual edit, script, or Claude's Edit tool)
  3. Verify it's present: cat ~/.claude/settings.json | python3 -c "import json,sys; print('hooks' in json.load(sys.stdin))"True
  4. Wait a few seconds or trigger any settings write (permission grant, etc.)
  5. Check again → False — the hooks key has been removed

Expected Behavior

  • The hooks key should persist in settings.json
  • Active sessions should either watch for external file changes and reload, or preserve unknown/unmanaged keys when writing back

Actual Behavior

  • The hooks key is silently stripped every time an active session writes its in-memory settings state back to disk
  • /hooks dialog 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 /hooks dialog itself says "edit settings.json directly" to configure hooks, but settings.json is the file being overwritten

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗