settings.json user config overwritten and lost after switching routing mode in Claude Code
Quick fix
Add custom env vars to CC-Switch Provider JSON, not directly to Claude Code settings.json.
Symptom
Section titled “Symptom”但是只要一切换到 路由模式 上面这段就消失了 被自动覆盖了 导致我设置失效But as soon as I switch to routing mode, the above disappears and is automatically overwritten, causing my settings to fail.
When switching routing modes or changing models, cc-switch rewrites the env field in Claude Code's settings.json. The program fails to preserve other manually added environment variables during write-back, causing custom settings like DISABLE_AUTOUPDATER to be overwritten and lost. Additionally, disabling routing mode resets configurations to their pre-routing state.
Stop editing Claude Code's settings.json file directly on Windows to add custom environment variables.
Open cc-switch, locate the configuration interface for your API provider, and place custom environment variable content directly into that Provider's configuration JSON.
// CC-Switch Provider 配置 JSON{"env": {"DISABLE_AUTOUPDATER": "1","CLAUDE_CODE_ATTRIBUTION_HEADER": "0","CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"}}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- Why did the configuration not take effect when placed under the general configuration section?
- According to official documentation, these environment variable settings only take effect when placed under the env section. However, the env section is automatically overwritten and cleared during routing switches. Placing them in the general configuration section causes them to be ignored automatically.
- Do I need to disable routing mode first if I need to adjust configurations after enabling it?
- No. As long as custom configuration items are written into the cc-switch corresponding Provider's configuration JSON, you can avoid configuration loss due to overwriting after switching Providers via routing, without needing to repeatedly toggle routing mode.
- Do I need to configure both CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC and DISABLE_AUTOUPDATER?
- No. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is equivalent to setting DISABLE_AUTOUPDATER, DISABLE_FEEDBACK_COMMAND, DISABLE_ERROR_REPORTING, and DISABLE_TELEMETRY. Configuring only the former is sufficient; the latter are redundant.
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.