settings.json plugins and hooks lost after switching provider
Quick fix
This is cc-switch's full-snapshot overwrite design. Put the fields you need to keep into the shared / general config and tick write-general-config.
Symptom
Section titled “Symptom”切换模型时, 会重写settings.json的Key, 但是有时候会丢失settings.json的其他Key, 写入时应该和原本settings.json中Key合并, 并且合并时应该实时获取原始配置.Switching model rewrites the Key in settings.json, but sometimes other Keys in settings.json are lost. The write should merge with the Keys already in settings.json, reading the original config live at merge time.
When switching provider, cc-switch does not merge or replace only the env and model fields — it writes the whole settings.json snapshot stored in the database for the target provider back over ~/.claude/settings.json. So plugin config, enabledPlugins, hooks, includeCoAuthoredBy and similar fields that exist only in the current live file, without having entered the shared config fragment / general config, can be overwritten or appear to go missing "at random" when you switch to another provider. Maintainers explained this is deliberate, because field-level merging brought edge cases: nested arrays, no way to tell a field the user deleted from one they never set, and multi-level merge conflicts.
The cluster mixes in other related symptoms: some users report "switch failed, please check the config", where maintainers note the usual causes are malformed config or cc-switch lacking write permission on settings.json. Others mention general config not being written back correctly with proxy takeover on, which maintainers say was fixed in v3.12.2. And some report conversations not being kept after a switch, which maintainers explain is the Claude Code / Codex client reinitialising the session after env changes — cc-switch does not delete sessions.
Open 编辑供应商 / Edit Provider in cc-switch and go to 共享配置面板 / Shared Config Panel.
Click 从当前供应商提取 / Extract from Current Provider to pull enabledPlugins, hooks, statusLine, includeCoAuthoredBy and any other fields you need across providers into the shared config fragment / general config.
~/.claude/settings.json # 将需要保留的字段放入 cc-switch 的通用配置 / 共享配置片段,例如:{"enabledPlugins": {"frontend-design@claude-plugins-official": true,"superpowers@claude-plugins-official": true,"code-review@claude-plugins-official": true,"typescript-lsp@claude-plugins-official": true,"gopls-lsp@claude-plugins-official": true,"pyright-lsp@claude-plugins-official": true},"includeCoAuthoredBy": false}Confirm every provider that needs those fields has 写入通用配置 / Write Shared Config ticked. New providers have it on by default; existing ones may need it enabled by hand.
If switching reports "switch failed, please check the config", check the config JSON is well-formed and that the current user can write settings.json in both the cc-switch config directory and the Claude Code / Codex config directory. Try starting cc-switch as administrator if needed.
If you use proxy takeover and general config is not written back correctly, upgrade to v3.12.2 or newer and retry.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 9 real issues
- #182切换失败,请检查配置
- #258gemini 配置无效
- #582[BUG] 配置目录
- #1184昨天辛苦装一堆claude code插件,切换一下配置全没了。
- #1354配置个供应商后,启动供应商,会将Claude的settings.json文件内的其他内容都清空,只保留env内模型相关的配置
- #1454[BUG反馈] 版本3.12.1 claude 丢失settings.json配置
- #1706settings.json中的插件启用状态丢失
- #1907[Bug] hooks in ~/.claude/settings.json get randomly deleted when switching nodes
- #3418切换模型之后对话不能保留
- Why can cc-switch not replace only the model fields instead of overwriting all of settings.json?
- Maintainers explain it is deliberate. Each provider stores a complete settings.json snapshot, written back as a whole on a switch. Earlier attempts at field-level replacement/merging hit many edge cases — nested arrays, no way to distinguish a field the user deleted from one never set, multi-level merge conflicts — so they moved to full snapshots plus a shared config fragment.
- Where do plugin config, hooks, and includeCoAuthoredBy belong?
- In cc-switch 通用配置 / 共享配置片段 (general config / shared config fragment). Use 从当前供应商提取 (extract from current provider) while editing a provider, then make sure the relevant providers have 写入通用配置 (write general config) ticked.
- Why do hooks go missing "sometimes" rather than on every switch?
- Before switching, cc-switch backfills the live file into the currently active provider, so fields you changed under the current provider may survive for a while. But switching to another provider that lacks those fields overwrites the live file from that provider's snapshot and they disappear.
- Claude Code / Codex conversations are not kept after a switch. Did cc-switch delete the sessions?
- No. Maintainers explain cc-switch only rewrites provider env and never writes to or deletes sessions. Conversations are not kept because the client reinitialises the session after env changes. The original conversation is still in ~/.claude/projects/<cwd>/ and can be continued with claude --resume.
- What do I do about "switch failed, please check the config"?
- Check the config JSON is well-formed first, then that the current user can write settings.json and the related config directories. Maintainers have traced this to the user lacking file write permission — try right-clicking the cc-switch icon and starting it as administrator.
- After changing the config directory, why is settings.json still written to the default directory?
- A maintainer replied that the feature in question writes ~/.claude.json rather than settings.json. If you see a file in the default directory being updated, confirm which config file is actually changing.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.