claude-code - 💡(How to fix) Fix Bug: /model command overwrites settings.json, wiping statusLine and hooks config [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#46921Fetched 2026-04-12 13:29:38
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×6commented ×1

The /model command (and possibly /effort) performs a full overwrite of ~/.claude/settings.json instead of a merge, which silently destroys user-configured statusLine and hooks settings.

Root Cause

The /model command (and possibly /effort) performs a full overwrite of ~/.claude/settings.json instead of a merge, which silently destroys user-configured statusLine and hooks settings.

Code Example

{
     "env": {},
     "statusLine": {
       "type": "command",
       "command": "bash ~/.claude/statusline-command.sh"
     },
     "hooks": {
       "SessionStart": [{ "hooks": [{ "type": "command", "command": "...", "async": true }] }]
     }
   }
RAW_BUFFERClick to expand / collapse

Description

The /model command (and possibly /effort) performs a full overwrite of ~/.claude/settings.json instead of a merge, which silently destroys user-configured statusLine and hooks settings.

Steps to Reproduce

  1. Configure statusLine and hooks in ~/.claude/settings.json:
    {
      "env": {},
      "statusLine": {
        "type": "command",
        "command": "bash ~/.claude/statusline-command.sh"
      },
      "hooks": {
        "SessionStart": [{ "hooks": [{ "type": "command", "command": "...", "async": true }] }]
      }
    }
  2. Run /model to switch models
  3. Check ~/.claude/settings.json — it now contains only {"env": {}}, all other config is gone

Evidence

  • settings.json birth date: 2026-04-08 13:18:26 — exactly when /model was executed 3 times in quick succession
  • settings.json last modified: 2026-04-11 18:26:33 — overwritten again (no matching user activity, possibly auto-update or background process)
  • The statusline-command.sh script and hooks/peon-ping/ directory remained intact on disk — only the JSON config pointing to them was lost
  • User history log confirms /clear/model × 3 → /effort/clear at the exact moment the file was recreated

Expected Behavior

Commands like /model and /effort should read-modify-write (merge) settings.json, only updating the fields they own, preserving all other user configuration.

Actual Behavior

The file is fully overwritten with a minimal object (e.g., {"env": {}}), destroying statusLine, hooks, and potentially other user-configured fields.

Environment

  • Claude Code version: 2.1.104
  • Platform: Windows 11 (10.0.26200)
  • Installation: standalone (~/.local/bin/claude.exe)

Impact

Users who invest time configuring statusLine scripts and hooks lose their setup silently with no warning and no backup. The data loss is not immediately obvious — users only notice when sounds stop playing or the status bar disappears.

extent analysis

TL;DR

Modify the /model and /effort commands to perform a read-modify-write (merge) operation on ~/.claude/settings.json instead of a full overwrite.

Guidance

  • Review the implementation of the /model and /effort commands to ensure they are reading the existing settings.json file, updating only the necessary fields, and writing the updated file back to disk.
  • Consider adding a backup mechanism for settings.json to prevent data loss in case of errors or overwrites.
  • Verify that the settings.json file is being handled correctly by checking the file's contents before and after executing the /model and /effort commands.
  • Investigate the possibility of adding a warning or prompt to notify users when their custom configurations are about to be overwritten.

Example

// Example of a merged settings.json file
{
  "env": {},
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline-command.sh"
  },
  "hooks": {
    "SessionStart": [{ "hooks": [{ "type": "command", "command": "...", "async": true }] }]
  },
  "model": { /* new model configuration */ }
}

Notes

The exact implementation of the read-modify-write operation will depend on the programming language and libraries being used. It is also important to consider the potential for conflicts or errors when merging user-configured settings with new or updated settings from the /model and /effort commands.

Recommendation

Apply a workaround by modifying the /model and /effort commands to perform a read-modify-write operation, as this will prevent data loss and ensure that user-configured settings are preserved. This approach will also provide a more robust and user-friendly experience.

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