settings.json partial rewrite strips statusLine, enabledPlugins, hooks mid-session

Resolved 💬 1 comment Opened May 26, 2026 by Jwd-gity Closed Jun 27, 2026

Bug Description

Claude Code periodically rewrites ~/.claude/settings.json during a session (not only at startup), stripping fields it didn't explicitly modify — specifically statusLine, enabledPlugins, hooks, and other user-configured fields. This causes the statusline to disappear, hooks to stop firing, and plugins to become disabled mid-session without any user action.

Steps to Reproduce

  1. Configure ~/.claude/settings.json with custom statusLine, enabledPlugins, and hooks
  2. Start a Claude Code session — everything works initially
  3. Use the session normally (interact with tools, change settings via /config, etc.)
  4. At some point during the session, the statusline disappears and hooks stop firing
  5. Inspect settings.json — the statusLine, enabledPlugins, and hooks fields are gone
  6. Restart Claude Code — a SessionStart guard hook can restore them from settings.local.json

Expected Behavior

When Claude Code writes to settings.json, it should perform a complete merge — preserving all existing fields, including those not managed by the current write operation. Fields like statusLine, enabledPlugins, and hooks should never be stripped unless the user explicitly removes them.

Actual Behavior

Claude Code performs a partial rewrite — it reads settings.json, updates only the fields it cares about, and writes back a subset. Any fields not in the current write path are silently dropped.

Root Cause Analysis

The settings write path appears to serialize only the schema fields relevant to the current operation, rather than round-tripping the full settings object. This is confirmed by the existence of community workarounds like settings-guard scripts that restore stripped fields on SessionStart.

Impact

  • Severe for power users: Anyone with custom hooks, plugins, statusLine, or extensive env configuration loses these settings during active sessions
  • Silient failure: No error or warning is shown — the statusline just disappears, hooks stop working
  • Workaround overhead: Requires a background daemon to monitor and restore settings.json every 3 seconds

Environment

  • Claude Code version: v2.1.144 (and likely other versions)
  • OS: Linux (WSL2)
  • Config location: ~/.claude/settings.json

Suggested Fix

Settings writes should use a merge strategy:

  1. Read the full current settings.json
  2. Update only the targeted fields
  3. Write back the complete merged object

This ensures user-configured fields are preserved regardless of which write path triggered the update.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗