claude-code - 💡(How to fix) Fix settings.json partial rewrite strips statusLine, enabledPlugins, hooks mid-session

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  • Silient failure: No error or warning is shown — the statusline just disappears, hooks stop working

Root Cause

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.

Fix Action

Fix / Workaround

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.

  • 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
RAW_BUFFERClick to expand / collapse

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING