settings.json config lost after switching providers - CC Switch
Quick fix
Use the "Shared Config Snippet" feature to extract and preserve custom fields like hooks/statusLine so they are carried over automatically on switch.
Symptom
Section titled “Symptom”切换后发现 hooks 字段被完全覆盖/丢失,相关插件、自动化脚本、hooks 行为全部失效After switching, the hooks field is found to be completely overwritten/lost, and related plugins, automation scripts, and hooks behavior all stop working
When switching providers, CC Switch rewrites `~/.claude/settings.json` with the selected provider's config; this is intentional design behavior. Since a provider config only contains provider-related fields like env and model, the write keeps only cc-switch built-in fields, and manually added fields such as hooks, enabledPlugins, and statusLine are fully overwritten or cleared. This issue persisted across many versions from v3.8.3 to v3.19.2. v3.11.0 introduced a "partial field merge" mechanism, but it was reverted in v3.11.1 (commit `859f4137`), restoring full-overwrite mode. The maintainer confirmed this is by design and recommends the "Shared Config Snippet" feature to retain shared data. Additionally, some users could not switch providers after using third-party mirrors/routers, possibly related to the "proxy placeholder backup/restore loop" fixed in v3.16.2 — previously, if a proxy left placeholders in the Live config when stopped, switching became a no-op.
In CC Switch, edit the current provider and find the "Shared Config" panel.
Click "Extract from current provider" to extract shared fields such as enabledPlugins, hooks, and statusLine into a shared config.
After saving, when you switch to another provider, the shared config is automatically merged into settings.json, and custom fields are no longer lost.
If you use VSCode and switching has no effect, check whether the "Write common config" option is enabled in CC Switch settings. If plugin config is written separately in VSCode, this feature will not overwrite it; ensure plugin config is not written separately or sync it manually.
If you use Codex and project-related settings like trust_level are lost after switching, you currently need to re-extract the shared config after first confirming each new project, or use a PostToolUse hook to restore them automatically.
Temporary workaround: use a Claude Code PostToolUse hook to automatically restore lost fields. Create a restore script and add a hook entry in settings.json so missing fields are re-added after each tool call.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 15 real issues
- #1280用过第三方claude code镜像服务之后无法切换提供商
- #3946切换 provider 后 hooks 字段丢失,插件及自定义脚本失效
- #5887提示Claude 配置文件不存在
- #480[Bug] 切换 Provider 后 settings.json 中的 statusLine 配置丢失
- #804切换供应商在vscode中不生效
- #4897claude桌面版1M上下文的配置问题
- #479settings.json配置覆盖问题
- #1031请求添加settings.json文件, "保留用户自定义字段"
- #1218>_进入终端不起作用
- #1277[Bug] 非代理模式下切换供应商导致 enabledPlugins 配置丢失
- #29793.15Bug:ccs错误写入claude的配置与显示的不同
- #6324重写 ~/.claude/settings.json 时清空用户配置(enabledPlugins/statusLine 等),导致 Claude Code 插件被禁用
- #2871Workaround: auto-restore settings.json fields (statusLine, permissions, hooks) via PostToolUse hook
- #4947首次安装cc-switch原始 settings.json 被覆盖
- #6340[Bug][已定位根因] 统一 Codex 会话历史对 OpenAI Official 静默失效:显式 model_provider 使注入被拒、官方历史迁移 gate 永不通过(#4710/#5467 补充)
- What should I do if the statusLine config in settings.json disappears after switching providers?
- This is CC Switch's design behavior: settings.json is rewritten on switch. Use the "Shared Config Snippet" feature: edit the provider → Shared Config panel → "Extract from current provider", and shared fields like statusLine will be carried over automatically on switch.
- Can the original settings.json be recovered after being overwritten?
- Yes. On first run, CC Switch reads all config into the default provider, so the original config is fully preserved in the default provider imported at first launch and can be recovered at any time.
- What should I do if claudecode.environmentVariables does not change after switching providers in VSCode?
- Check whether the "Write common config" feature is enabled in CC Switch settings. If plugin config is written separately in VSCode, this feature will not overwrite it; the feature works when plugin config is not written separately.
- What should I do if Claude is unavailable in the terminal opened via the >_ button in the CC Switch UI?
- The built-in terminal's shell environment may differ from your usual terminal, and the node/claude paths may not be configured. It is recommended to run claude directly from a system terminal (PowerShell, iTerm2, etc.); CC Switch writes the config to settings.json, which the system terminal can read normally.
- What should I do if it says "Claude config file does not exist"?
- CC Switch manages the Claude Code CLI config directory (e.g., %USERPROFILE%\.claude\settings.json on Windows), not Claude Desktop. Make sure the Claude Code CLI is installed and the claude command has been run once in a terminal to generate the ~/.claude directory. If you use WSL, CC Switch's config directory must point to the .claude directory in WSL.
- What should I do if enabledPlugins is set to null after switching providers, disabling all plugins?
- v3.11.1 reverted the partial field merge mechanism, causing this issue. You can pass plugin data via common config (shared config snippets), or use proxy mode (in proxy mode, switching does not write to the live config and does not trigger this issue).
- What should I do if project-related settings like Codex's trust_level are lost after switching?
- trust_level is project-related and gets replaced when switching providers. Currently, with shared config snippets you need to extract once for each new project started. You can also consider using a PostToolUse hook for automatic restoration.
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.