Config lost after switching: Claude Code / Codex / WSL path check
Quick fix
Switching provider rewrites settings.json. Put hooks/statusLine/enabledPlugins into the shared/general config, not just the local file.
Symptom
Section titled “Symptom”切换 provider 后 hooks 字段丢失,插件及自定义脚本失效The hooks field is lost after switching provider, breaking plugins and custom scripts
cc-switch generates the live config file from the selected provider's configuration and rewrites it when you switch provider or restart proxy routing — ~/.claude/settings.json for Claude Code, ~/.codex/config.toml for Codex. If you write hooks, enabledPlugins, statusLine, permissions, skipDangerousModePermissionPrompt, a Codex project trust_level, and similar fields straight into the local config file without adding them to cc-switch's general / shared config fragment, they are wiped on the next switch.
Some issues cover other variants: a leftover third-party mirror/proxy placeholder can turn a switch into a no-op; Claude Desktop and Claude Code use different config directories, so a hand-created ~/.claude/settings.json may pass a file-exists check without actually taking effect; and Codex unified session history can be silently skipped when an official provider sets model_provider = "openai" explicitly. These are different root causes that all present as config not applying or being overwritten after a switch.
Confirm you are using the Claude Code CLI rather than only Claude Desktop. Claude Code normally reads ~/.claude/settings.json — %USERPROFILE%\.claude\settings.json on native Windows, /home/<username>/.claude/settings.json inside WSL.
Open the provider edit screen in cc-switch, find the shared / general config panel, and use 从当前供应商提取 (extract from current provider) or a similar entry point to pull enabledPlugins, hooks, statusLine, permissions and any other fields you need across providers into the shared config.
Save, switch provider again, and check the live config file kept those fields.
~/.claude/settings.json {"env": { },"enabledPlugins": { },"hooks": { },"statusLine": { }}If it still does not apply after switching, check your cc-switch version. A leftover third-party proxy placeholder making switches ineffective is mentioned among the v3.16.2 fixes — upgrade to v3.16.2 or newer and retry.
On Codex, if you have to re-confirm Hooks trust, Sandbox, or a project trust_level after every switch, move those project-level settings into the cc-switch shared config; otherwise re-confirmation may be needed each time.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 15 real issues
- #479settings.json配置覆盖问题
- #480[Bug] 切换 Provider 后 settings.json 中的 statusLine 配置丢失
- #804切换供应商在vscode中不生效
- #1031请求添加settings.json文件, "保留用户自定义字段"
- #1218>_进入终端不起作用
- #1277[Bug] 非代理模式下切换供应商导致 enabledPlugins 配置丢失
- #1280用过第三方claude code镜像服务之后无法切换提供商
- #2871Workaround: auto-restore settings.json fields (statusLine, permissions, hooks) via PostToolUse hook
- #29793.15Bug:ccs错误写入claude的配置与显示的不同
- #3946切换 provider 后 hooks 字段丢失,插件及自定义脚本失效
- #4897claude桌面版1M上下文的配置问题
- #4947首次安装cc-switch原始 settings.json 被覆盖
- #5887提示Claude 配置文件不存在
- #6324重写 ~/.claude/settings.json 时清空用户配置(enabledPlugins/statusLine 等),导致 Claude Code 插件被禁用
- #6340[Bug][已定位根因] 统一 Codex 会话历史对 OpenAI Official 静默失效:显式 model_provider 使注入被拒、官方历史迁移 gate 永不通过(#4710/#5467 补充)
- Why does switching provider in cc-switch overwrite settings.json?
- A maintainer explained this is by design: the live config file is generated from the selected provider config and rewritten on a switch. Fields you need across providers belong in the shared / general config rather than only in the local settings.json.
- How do I keep enabledPlugins, hooks, and statusLine?
- On the provider edit page in cc-switch, find the shared / general config panel and use 从当前供应商提取 (extract from current provider) to pull enabledPlugins, hooks, statusLine and similar fields out, so they travel with a provider switch.
- I cannot find where to edit the general config.
- Users report you can set up any provider on the cc-switch Claude Code screen, then find the general / shared config panel inside that provider's settings, read the settings.json you already configured, and save it as the default general config.
- Do Claude Desktop and Claude Code share one config?
- No. The issues note Claude Desktop and Claude Code use different configs; cc-switch mainly manages the Claude Code CLI's ~/.claude/settings.json. With only Claude Desktop installed, that directory may not be created at all.
- claudecode.environmentVariables in VS Code does not change after switching provider. What now?
- An issue mentions the matching write feature has to be enabled in cc-switch. If you wrote the plugin config separately in VS Code, that config may not be rewritten. Confirm the relevant sync/write option is on in cc-switch.
- Can a script restore the wiped fields automatically?
- A user offered a temporary workaround: a Claude Code PostToolUse hook that restores statusLine, permissions, hooks and similar fields after each tool call. It is not an official final answer, and there is still a window between the switch and the first tool call.
- Why do I have to re-confirm Hooks trust or Sandbox after a Codex switch?
- Because the related config may be rewritten when you switch provider. Users report that even launching with codex --dangerously-bypass-approvals-and-sandbox --dangerously-bypass-hook-trust still prompts again after a switch. Move the settings you need into the cc-switch shared config.
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.