Operate CC Switch (CCS): safely modify and sync its managed configuration — global prompts, skills, MCP servers, providers, and the Codex model catalog — across Codex, Claude Code, Claude Desktop, and other managed apps via cc-switch.db and the managed config files. Use when the user asks to 同步/修改 CCS 或 CC Switch 配置、全局提示词、skill 同步/安装、MCP 配置、供应商配置、修复 CCS 乱码, or whenever CCS-managed files must be edited without being overwritten on the next sync.
3 stars
0 votes
0 copies
17 views
Added September 19, 2026
ai-agentspythongoshellbashsqlnodegitapidatabase
Works with
claude code
claude desktop
terminal
cli
api
mcp
Security analysis
A92/100
mediumInstalls packages at runtime which could introduce malicious dependencies
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of CCSwitch-operations?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/rurilothlorien-ccswitch-operations)
---
name: ccswitch-operations
description: "Operate CC Switch (CCS): safely modify and sync its managed configuration — global prompts, skills, MCP servers, providers, and the Codex model catalog — across Codex, Claude Code, Claude Desktop, and other managed apps via cc-switch.db and the managed config files. Use when the user asks to 同步/修改 CCS 或 CC Switch 配置、全局提示词、skill 同步/安装、MCP 配置、供应商配置、修复 CCS 乱码, or whenever CCS-managed files must be edited without being overwritten on the next sync."
---
# CC Switch Operations
Methodology for safely operating CC Switch (CCS): backup first, stop the app, edit, validate, restart, and re-check.
> **Version compatibility**: designed and tested with CC Switch **4.0.44** and Codex **0.169** (database schema v29). Versions 4.0.39–4.0.44 span v27–v29 (v28 arrived in 4.0.41 with `enabled_codebuddy`, v29 in 4.0.44 with `enabled_zcode`); 4.0.39, 4.0.40, 4.0.42 and 4.0.43 added behavior and fixes without another migration. Schema v20 added Pi MCP, v21 added `enabled_agy`, v22 added `enabled_kimi`, v23 added MCP `enabled_omp`, v24 added MCP/Skills `enabled_dsh` plus internal `session_log_sync.parser_state`, v25 added `enabled_copilot`, v26 added `enabled_workbuddy`, v27 added skill repository hosts for GitLab/Gitea/Forgejo, v28 added MCP/Skills `enabled_codebuddy`, and v29 added `enabled_zcode`. CC Switch 3.20.4 (schema v19), 3.20.1–3.20.3 (schema v18) and 3.20.0 (schema v17) remain readable where the relevant columns exist, but after a migration **older CCS versions refuse to open the database** — keep the automatic backup in `<cc-home>/backups/`. MiniMax Code (`mcode`) needs 3.20.4+; Pi MCP needs 4.0+; Antigravity (`agy`) needs 4.0.18+; Kimi Code (`kimi`) needs 4.0.19+; Oh My Pi (`omp`) needs 4.0.20+; DeepSeek Harness (`dsh`) needs 4.0.22+; GitHub Copilot CLI (`copilot`) needs 4.0.29+; Tencent WorkBuddy (`workbuddy`) needs 4.0.31+; CodeBuddy (`codebuddy`) needs 4.0.41+; ZCode (`zcode`) needs 4.0.44+. The helper detects missing columns and keeps working against older databases. **CC Switch 4.0 removed the common-config snippet**. Run `doctor` to verify schema, 18 app types, flag-column availability, skill repository hosts, the resolved skills directory, DSH/Copilot/WorkBuddy directory resolution, Codex session grouping/auth settings and per-app mode. Other versions may behave differently — see `references/migration.md`. The DSH audit needs **PyYAML** (`pip install pyyaml`); without it the audit states that it did not run instead of guessing.
> **Iron rule**: when unsure, first carefully read this skill (SKILL.md and its references) — do not improvise or guess. If the request is genuinely outside this skill's scope, tell the user and propose concrete recommended actions instead.
## 1. Safety workflow (mandatory for any write)
1. Backup: config files become `*.bak-<yyyyMMdd>-<slug>`; the database is snapshotted with `python scripts/ccs_db.py snapshot` (SQLite backup API). Never take the database with a plain file copy: since CCS 4.0.40 it runs in WAL mode, so a copy of `cc-switch.db` alone can silently drop everything still in `-wal` and come back on an older schema.
2. Stop CCS (the `cc-switch` process) before editing its database; a running CCS can overwrite your edits from memory.
3. Edit (see the sections below; use `scripts/ccs_db.py` for database writes).
4. Validate: TOML with `tomllib`, JSON with `json.load`, database with `python scripts/ccs_db.py check`; inspect Chinese text with `repr()`/`ascii()`.
5. Restart CCS, wait 3–5 seconds.
6. Re-parse the config files and confirm CCS did not rewrite them.
7. Remind the user to restart target apps (config is loaded at startup).
## 2. Encoding safety
- Never pipe Chinese text into Python through a shell that can mangle encoding (Windows PowerShell 5.1 uses the console code page; Chinese can become `?` and corrupt the DB permanently).
- Use `scripts/ccs_db.py` for Chinese-containing DB writes; pass Chinese inline (wide argv) or via UTF-8 files (`--*-file`).
- On Windows PowerShell, save `.ps1` files as UTF-8 with BOM.
- After any write, run `scripts/ccs_db.py check`; it covers user-facing text and JSON/TOML blobs and reports `?` only when it looks like mojibake (not legitimate URL query strings).
## 3. Architecture (details: references/architecture.md)
- Database: `<cc-home>/cc-switch.db` (schema v29 on CCS 4.0.44, v28 on 4.0.41–4.0.43, v27 on 4.0.34–4.0.40, v26 on 4.0.31–4.0.33 and v25 on 4.0.29–4.0.30 — MCP carries `enabled_omp`, `enabled_dsh`, `enabled_copilot`, `enabled_workbuddy`, `enabled_codebuddy` and `enabled_zcode`; Skills carries `enabled_dsh`, `enabled_copilot`, `enabled_workbuddy`, `enabled_codebuddy` and `enabled_zcode`, plus `repo_host` on v27+; Oh My Pi skills are exists-equals-enabled. `session_log_sync.parser_state` is CCS-managed). **Since 4.0.40 the main database runs in WAL mode** (`journal_mode=wal`), so a plain file copy of `cc-switch.db` misses everything still in `cc-switch.db-wal`; always take backups through the helper, which uses the SQLite backup API like CCS itself does. Hand-maintained tables: `providers`, `prompts`, `skills`, `mcp_servers`, `settings`. CCS-managed tables (`model_pricing`, `profiles`, `proxy_*`, `session_log_sync`, `session_usage_dedup`, `usage_daily_rollups`, `skill_repos`, ...) must not be edited by hand.
- `cc-home` discovery: `CC_SWITCH_HOME` env var, else `~/.cc-switch`. `scripts/ccs_db.py` resolves this automatically; `doctor` prints the resolved paths.
- **Three modes (CCS 4.0)**: proxy-capable apps run in **direct / route / stack (aggregation)**. Stack supports **Claude Code, Codex, and Claude Desktop since 4.0.13**, needs the local router, dispatches per selected model and has no failover. Stack state (members, provider keys, `enabled`) lives in the device-local `~/.cc-switch/live-state.json` (NOT under `CC_SWITCH_HOME`, not synced); Claude Code's published models live in `providers.meta.stackModels`, while Claude Desktop uses the provider model-mapping fields and its own model list. `live-state.json` stores the internal value `proxy`; `doctor` maps it to the user-facing `route` label.
- Managed apps (18): codex, claude, claude-desktop, gemini, grokbuild, opencode, openclaw, hermes, pi, mcode, kimi, agy, omp, dsh, copilot, workbuddy, codebuddy, zcode. Switch-mode apps (claude/codex/claude-desktop/gemini/grokbuild) write only the current provider; additive-mode apps (opencode/openclaw/hermes/pi/mcode/kimi/omp/dsh/copilot/workbuddy/codebuddy/zcode) let providers coexist. Pi and Oh My Pi skills are exists-equals-enabled; DSH, Copilot, WorkBuddy, CodeBuddy and ZCode have explicit skill flags. Claude Desktop and OpenClaw are not MCP-synced by CCS. MiniMax Code (`mcode`) keeps providers in `~/.minimax/config.yaml`, CodeBuddy in `models.json`, ZCode in `v2/provider_config.json`, and all three refuse generic provider-edit commands.
- **Kimi Code (`kimi`, CCS 4.0.19+)**: additive providers in `~/.kimi-code/config.toml` (override with `KIMI_CODE_HOME`); MCP → `~/.kimi-code/mcp.json`; skills → `~/.kimi-code/skills`; prompts → `~/.kimi-code/AGENTS.md`; enabled through `enabled_kimi`. Kimi providers are stored as structured `{provider, models}` data, so `provider-block` / `provider-env` / `provider-set-key` refuse them on purpose. No proxy takeover or aggregation.
- **Antigravity CLI (`agy`, CCS 4.0.18+)**: MCP → `~/.gemini/config/mcp_config.json`; skills → `~/.gemini/config/skills`; prompts → `~/.gemini/config/AGENTS.md`; enabled through `enabled_agy`. Agy supports stdio and streamable HTTP MCP but not SSE. Its provider cards are launch-time only: they affect an `agy` process started through “Open terminal with this provider”, not a directly launched `agy`, so the provider-* commands refuse Agy cards. `~/.gemini/config` may also be shared with Antigravity IDE.
- **Oh My Pi (`omp`, CCS 4.0.20+)**: agent directory is `~/.omp/agent` or a selected profile under `~/.omp/profiles/<name>/agent`, with CCS/Oh My Pi directory overrides. Providers are `models.yml`/`models.yaml`; MCP → `mcp.json` (`enabled_omp`); skills → `skills` (exists-equals-enabled, like Pi); prompts → `AGENTS.md`. MCP/Skills may also discover project or foreign entries, so the native total can exceed the CCS panel. Generic provider-edit commands refuse OMP YAML.
- **DeepSeek Harness (`dsh`, CCS 4.0.22+)**: data dir resolves as CCS `settings.json:dshConfigDir` → `DSH_HOME` → `~/.dsh`; the helper's explicit `--dsh-home` overrides all three. Providers and MCP live in `profiles/<web|desktop|headless|acp>/cordis.patch.yml`; provider keys live in `.credentials.yaml`; Skills → `<dsh-home>/skills` (`enabled_dsh`); prompts → `<dsh-home>/AGENTS.md`. Web and Desktop share the provider/MCP list. DSH model inputs accept only `text` and `image`; the helper filters other modalities such as `pdf`. Existing headless profiles get the managed credentials row when a key is stored in `.credentials.yaml`, unless the user already made an explicit choice. MCP supports stdio and Streamable HTTP. Use the dedicated `dsh-provider-*` commands for provider changes; generic provider-edit commands refuse DSH.
- **GitHub Copilot CLI (`copilot`, CCS 4.0.29+)**: data dir `COPILOT_HOME` → `~/.copilot`; BYOK providers live in `providers.json` (`COPILOT_PROVIDERS_CONFIG` overrides the file), MCP → `mcp-config.json`, skills → `skills`, prompts → `copilot-instructions.md`, sessions → `session-state/`; enabled through `enabled_copilot`. Copilot cards are additive and **never go through the CCS router**; each card owns one provider entry plus its models (keyed by card id), and CCS validates the whole document before writing because a bad entry stops Copilot from starting. The provider-* commands refuse Copilot cards. When `COPILOT_PROVIDER_BASE_URL` is set in the environment, Copilot ignores `providers.json` entirely.
- **Tencent WorkBuddy (`workbuddy`, CCS 4.0.31+)**: data dir `WORKBUDDY_CONFIG_DIR` → `~/.workbuddy`; providers are flattened into `models.json` (one entry per model, each with its own url/apiKey, tagged `ccSwitchProviderId`), MCP → `mcp.json`, skills → `skills`, prompts → the account-scoped `MEMORY.md` under `user-<uid>-<scope>`; enabled through `enabled_workbuddy`. Additive only, OpenAI Chat Completions only, and a model id may belong to one card only. Official cards only bind an authorized account. **Fully quit WorkBuddy (including tray/menu bar) before switching accounts**, otherwise it writes the current login back. The provider-* commands refuse WorkBuddy cards.
- Official/bundled MCP servers (for example `openaiDeveloperDocs`) are intentionally absent from the `mcp_servers` table; do not add them.
## 4. Global prompts (prompts table)
- `prompts` stores `app_type` for the 18 managed values and `name='全局'` content with `enabled=1`; the apps exposed by the CCS prompt page can vary by release (Claude Desktop exposes none).
- Update via `scripts/ccs_db.py prompt-set --app-type codex|claude|... --content-file <utf8.txt>`.
- Keep codex and claude contents consistent unless the user explicitly asks otherwise.
## 5. Skills
- The skill identity is the lowercase kebab-case `name` in `SKILL.md`. DSH silently skips invalid names, while the containing folder and repository name may remain branded such as `CCSwitch-operations`.
- Source of truth: `<cc-home>/skills/<name>/SKILL.md` by default; if `settings.json` sets `skillStorageLocation` to `unified`, the skill sources live in `~/.agents/skills/<name>/`. `skills.enabled_*` flags control per-app enablement. `doctor` prints the resolved directory plus its `source`, and `skill-upsert` reads from the same place — never assume `<cc-home>/skills`.
- Install to an app = copy/symlink/junction the skill folder into the app's skills directory (see references/apps.md for per-app paths). The exact link style is controlled by CCS `skillSyncMethod` (auto/symlink/copy).
- Kimi Code stores skills under `~/.kimi-code/skills`; Agy uses `~/.gemini/config/skills`. Both use CCS's ownership checks and do not overwrite an unrelated same-name native skill.
- Oh My Pi uses its active agent directory's `skills` and is enabled by existence. DeepSeek Harness uses `$DSH_HOME/skills` with `enabled_dsh` and CCS ownership checks. GitHub Copilot CLI uses `<COPILOT_HOME>/skills` (`enabled_copilot`), Tencent WorkBuddy uses `<WORKBUDDY_CONFIG_DIR>/skills` (`enabled_workbuddy`), CodeBuddy uses `<CODEBUDDY_CONFIG_DIR>/skills` (`enabled_codebuddy`), and ZCode uses `<ZCODE_HOME>/skills` (`enabled_zcode`).
- After editing a local skill, refresh its `content_hash` with `skill-upsert`. The helper hashes the full skill directory using CCS 4.0.27 semantics and ignores hidden files, `__pycache__/`, and `*.pyc`.
- **Skill repositories (4.0.34+, schema v27)**: skill sources can live on **GitHub, GitLab, Gitea or Forgejo** (including self-hosted instances and Codeberg). `owner/name` notation stays GitHub-style on every site, only public repositories with `https` are accepted, and one `owner/name` pair can be registered on one site only. The site is stored per skill in `skills.repo_host` and per repository in `skill_repos.host`; **NULL reads as `github.com`**, so pre-v27 rows stay valid without a backfill. `skill-upsert --repo-host <site>` records the site for a skill you register yourself; `doctor` prints the host distribution for both tables.
- **Private skill repositories (4.0.36+)**: a non-public repository needs a per-site access token, which CCS stores in the OS credential manager and deliberately excludes from cloud sync. Never copy, print or move those tokens; have the user re-authorise the site inside CCS instead.
- **Skill update is copy-then-replace (4.0.33+)**: CCS copies the new version completely before swapping it in, so an interrupted update keeps the previous copy (#9521). Removing a managed skill still works when its managed copy is already missing (4.0.35, #9669).
- **A stale `-wal` file makes a naive backup lie (4.0.40+)**: CC Switch turned the database to WAL mode, so `cc-switch.db` alone can be older than the state CCS shows. The helper's `snapshot`, `backup_db` and repair backups all use `sqlite3.Connection.backup()` (the same online-backup mechanism as CCS's `rusqlite::backup::Backup`), and `diff` prints `schema user_version: backup=<v> current=<v>` plus a warning when a backup predates the live schema. Never "back up" by copying the `.db` file by hand.
## 6. MCP
- Three places must stay consistent for user-managed MCP servers: `~/.codex/config.toml` (live), the `mcp_servers` table (panel), and the current codex provider's `settings_config.config` text. Use `mcp-upsert` + `provider-block`.
- Claude Desktop MCP configs are separate JSON files (see references/operations.md).
- Codex does not support SSE transport; bridge via `npx -y mcp-remote <url> --transport sse-only` where needed.
- **Pi (CCS 4.0)**: MCP syncs to `~/.pi/agent/mcp.json`; only connection fields are written (Pi's own timeout/tool/OAuth settings survive), turning sync off disables rather than deletes entries, and unsupported servers (SSE transport, special characters in the name) are reported instead of written. Enable with `--enable-pi` / `set-flags --table mcp_servers --pi 1`.
- **Kimi Code (4.0.19+)**: MCP syncs to `~/.kimi-code/mcp.json`; stdio, HTTP and SSE are supported. Enable with `--enable-kimi` / `set-flags --table mcp_servers --kimi 1`.
- **Antigravity (4.0.18+)**: MCP syncs to `~/.gemini/config/mcp_config.json`; stdio and streamable HTTP are supported, SSE is rejected. Enable with `--enable-agy` / `set-flags --table mcp_servers --agy 1`; the shared `~/.gemini/config` directory may also be used by Antigravity IDE.
- **Oh My Pi (4.0.20+)**: MCP syncs to the active OMP agent directory's `mcp.json`; `enabled_omp` controls it. The native MCP/Skills discovery may see more entries than CCS manages.
- **DeepSeek Harness (4.0.22+)**: MCP is stored in the shared web/desktop profile patches; stdio and Streamable HTTP are supported. `enabled_dsh` controls MCP and Skills.
- **GitHub Copilot CLI (4.0.29+)**: MCP syncs to `<COPILOT_HOME>/mcp-config.json`; `enabled_copilot` controls MCP and Skills.
- **Tencent WorkBuddy (4.0.31+)**: MCP syncs to `<WORKBUDDY_CONFIG_DIR>/mcp.json`; `enabled_workbuddy` controls MCP and Skills. MCP entries added by WorkBuddy's own connector manager are left alone.
- **CodeBuddy (4.0.41+)**: MCP is read from exactly one user-scope file, probed in order `<CODEBUDDY_CONFIG_DIR>/.mcp.json` → `mcp.json` (deprecated) → `.codebuddy.json` (legacy); the files are **not merged**, so the first one found wins. `TRANSPORT_FIELDS` are `type`/`command`/`args`/`env`/`cwd`/`url`/`headers`; `enabled_codebuddy` controls MCP and Skills.
- **ZCode (4.0.44+)**: MCP lives in `<ZCODE_HOME>/cli/config.json` under the top-level `mcp.servers` map with standard `type: "stdio" | "sse" | "http"`. CCS forces `enabled: true` into each entry it writes and strips it again when reading, so `apps.zcode` in ZCode's own config is the only real switch; `enabled_zcode` controls MCP and Skills.
- **Codex invalid MCP keys**: Codex rejects `type`, `timeout` and `autoApprove` inside `[mcp_servers.*]`. CCS 4.0.21 stopped writing the latter two, but old live config may retain them. `check --strict` audits all three and `repair --mode mcp-type` removes them from the Codex section without touching sub-tables.
- **MCP connectivity (4.0.25+)**: `doctor --audit` checks structure and three-way configuration consistency, not whether an MCP process can start or a remote endpoint can authenticate. Use the CCS MCP connectivity test; never execute an unknown MCP command just to prove it exists.
## 7. Verification checklist
- `python scripts/ccs_db.py check` passes.
- `python scripts/ccs_db.py check --strict` and `doctor --audit` pass (structural safety + three-way consistency).
- `codex mcp list` shows the expected command/args/env; official/bundled servers may appear without `mcp_servers` rows.
- `settings.json` `currentProvider*` matches `providers.is_current`.
- After CCS restart, config files are unchanged.
- Target apps are fully restarted before judging visibility.
- After any write, confirm the config text did not change beyond the intended edit (byte-level re-check).
## 8. Proactive preflight and known upstream behavior (3.20.0–4.0.44)
- **Proactive preflight**: every mutating command runs a read-only structural audit first, with a scope matched to what it writes (`PREFLIGHT_TARGETS` in the helper): `mcp-upsert` covers providers/config/common/mcp-type, `provider-set-key` adds `keys`, everything else (`provider-block`, `provider-env`, `prompt-set`, `skill-upsert`, `set-flags`, `dsh-provider-set`, `dsh-provider-remove`) covers providers/config/common. Findings are split: **errors** (empty-command stdio MCP servers, unpaired markers, misplaced or out-of-place table headers, live-only sections in a provider card) refuse the write with repair hints, while **warnings** (unreadable `settings_config` / `server_config` rows, DSH `reasoningEfforts` levels DSH would reject, a profile that could not be read) are printed and do not block. `--force` (before the subcommand) downgrades errors to a printed `[PREFLIGHT-FORCED]` warning instead of skipping the audit. `repair` runs the same audit in advisory mode and never blocks: it is the command that clears the damage. `check --strict` exits 2 only on errors; `doctor --audit` prints the same grouped list and always exits 0.
- **`repair --mode live-only` is provider-only**: `[projects]`, `[plugins]`, `[marketplaces]`, `[desktop]`, `[features]`, `[memories]`, `[windows]`, `[shell_environment_policy]`, `[sandbox_workspace_write]` and `[hooks.state]` are **legitimate content of the live Codex config**. Stripping them from `~/.codex/config.toml` is the 2026-08-23 damage class (46 sections, 20 plugins, 11 projects, all marketplaces), so `repair --target config.toml --mode live-only` refuses to run and points at `--target provider --provider-id <id> --mode live-only` (or `--mode both` on a provider). The live config is still audited for header order, obsolete keys, catalog pointer and invalid MCP keys.
- **Provider-edit config mangling (3.20.0–3.20.3, fixed in 4.0.4)**: the old edit page could reorder `config.toml`, strip common-config blocks, misplace markers, and serialize a url-only remote MCP as `type="stdio"` + `command=""` (upstream #6719, closed 2026-10-07). CCS 4.0.4 rewrote config writing to key-field replacement — zero-change saves are byte-identical and the config keeps top-level keys, tables, comments and markers. **Already damaged entries are not auto-fixed**: re-sync the MCP entry (panel off/on) or use this skill's `check --strict` / `repair` / `mcp-upsert`; the edit page is safe on 4.0.4+.
- **Proxy-managed OAuth cards (3.20.2)**: for providers whose token is injected per request by the local proxy — `providers.meta.provider_type` = `xai_oauth` or `github_copilot` — the active `[model_providers.*]` table must carry `requires_openai_auth = false`; CCS 3.20.2 enforces this (presets emit `false`, existing cards self-heal on the next switch). Codex OAuth is deliberately excluded, because the official login *is* its credential. `check --strict` reports the wrong flag value for these cards instead of "no own credentials", and `repair --mode codex-0149 --apply` flips it to `false`.
- **Takeover derives the flag from the login state (3.20.2)**: when proxy takeover writes the active table, it resolves Codex's auth mode (explicit `auth_mode` > personal access token > Bedrock API key > Bedrock access key > `OPENAI_API_KEY` > ChatGPT) and then the credential store — `file` follows whether `auth.json` holds an official login, `ephemeral` is treated as logged out (`false`), and `keyring`/`auto` keep the stored value. A missing, unreadable or corrupt `auth.json` now counts as logged out instead of failing the takeover write.
- Common symptoms: top-level `notify = [...]` displaced, `[plugins]` / `[marketplaces]` blocks stripped, `[mcp_servers]` / `[mcp_servers.node_repl(.env)]` blocks or keys rewritten or reordered.
- **Codex 0.149 config-only compatibility (routing rules aligned with 3.20.3)**: since CC Switch 3.20.1, third-party switching is config-only (key in `[model_providers.*]` as `experimental_bearer_token`, `auth.json` = official login only). `check --strict` detects 0.149-rejected or mis-routed shapes: legacy reserved tables `[model_providers.openai|ollama|lmstudio]`, missing `name`, a top-level `openai_base_url` reroute that actually targets the built-in `openai` provider (selector absent or exactly `openai`), a custom selector whose `[model_providers.<id>]` table is missing, empty/keyless third-party cards, and inline `model_providers = { ... }` declarations (recognized as real tables instead of being misreported as empty). `repair --mode codex-0149` renames reserved tables (and follows the rename with `model_provider` when that table carries the route's own key), backfills `name`, and migrates the `openai_base_url` reroute into the same shape CCS 3.20.3 writes — `[model_providers.cc-switch(-N)]` with `model_provider` pointing at it, `wire_api = "responses"`, `base_url` and the bearer token. A user-authored `cc-switch` table is never overwritten; keyless shapes are reported, not fabricated.
- **Codex cards without `model_provider` (3.20.3)**: takeover now treats a missing selector as the built-in `openai` provider, writes the proxy address to `openai_base_url`, and the shared normalization step rewrites it into `[model_providers.cc-switch(-N)]` with a `PROXY_MANAGED` bearer — previously the address was written to a top-level `base_url` Codex never reads, so the request silently went to `api.openai.com`. Direct (non-takeover) switches still follow the card as-is; that difference is what `check --strict` reports.
- **3.20.3 upgrade checklist**: no database migration (schema stays v18). Universal-provider sync now preserves child settings, but children whose `meta` was wiped by an earlier sync (usage script, common-config opt-out, endpoint auto-select, sort order) must be re-entered — re-check `common-config status`. The Claude → Codex/Gemini/Grok cross-write of proxy retry/timeout values is stopped, but values already copied are not restored — review each app's proxy settings. Kimi's two Codex presets moved to native Responses and DeepSeek's `deepseek-flash` catalog entry gained vision: existing cards keep their snapshot, so change the upstream format / re-import the preset, and switch away and back for catalog changes.
- **Stored Codex API keys (3.20.4)**: CCS 3.20.4 fixed the bug that wiped a saved Codex API key when editing or switching a provider (#7434), but keys already lost are not restored. Cards damaged by it keep the bearer token in the provider text while `settings_config.auth.OPENAI_API_KEY` is empty — `check --strict` / `doctor --audit` report that shape, and `repair --target provider --mode codex-key --apply` restores the key from the provider table (dry-run first; official and proxy-managed OAuth cards are skipped because they are keyless by design). If neither place holds a token, re-enter the key in CCS.
- **MiniMax Code (3.20.4)**: the 10th managed app. Additive providers in `~/.minimax/config.yaml` (`custom_provider`), MCP ↔ `~/.minimax/mcp.json`, skills → `~/.minimax/skills` (Pi-style ownership check), prompts → `~/.minimax/AGENTS.md` (≤32 KiB per prompt). Default model, login, cloud features and session deletion stay with MiniMax Code; CCS adds no proxy takeover/failover/tray/common-config/Profiles. Existing MCP servers and skills are disabled for mcode until you pass `--enable-mcode` / `set-flags --mcode 1`.
- **3.20.4 upgrade checklist**: database migration v18 → v19 (back up before upgrading; older CCS versions then refuse the DB). Cards bound to a deleted ChatGPT account must be re-bound manually before takeover can be enabled again; the "hide AI attribution" toggle must be re-checked (it now also requires `attribution.sessionUrl = false`); AICodeWith Codex cards need their endpoint changed to `/v1`; DeepSeek V4 Pro pricing went back to the peak tier and `Ling-2.6-1T` is treated as text-only; Chat-upstream requests take one prefix-cache miss after upgrade (#7454 / #7319) and then stabilise.
- **CCS 4.0 config ownership**: shared settings now live in the **client config file** and survive provider switches (they are no longer merged from a snippet); a model or effort chosen inside the client reverts to the provider's value on the next switch. Only provider-specific fields belong in a provider card.
- **Stack / aggregation mode (4.0)**: Claude Code, Codex, and Claude Desktop (4.0.13+) can publish several providers' models into one client model list and dispatch per model; it needs the local router, has no failover, and its state is device-local (`~/.cc-switch/live-state.json`, not synced; Claude Code models in `meta.stackModels`). Claude Code needs ≥ 2.1.243; Codex and Claude Desktop aggregate-list changes need a restart, Claude Code's apply immediately; switching models mid-session rebuilds the prompt cache (first turn costs more). Cross-provider Codex sub-agents use `settings.json: codexStackClassicTools` (default true since 4.0.13); Claude Desktop only reads its config at startup, so restart it after mode/router/member changes.
- **Codex extras (4.0.5–4.0.7)**: GitHub Copilot accounts can be used on Codex (router on; protocol auto-selected); optional session-file compression writes `[features] local_thread_store_compression = true` into `config.toml` (7-day-old sessions become `.jsonl.zst`; tools that read raw `.jsonl` may miss them); account/mode changes prompt for a Codex service restart.
- **Codex extras (4.0.9–4.0.13)**: provider cards can set `[agents] default_subagent_model` / `default_subagent_reasoning_effort` and an auto-approval model; aggregation mode keeps a separate sub-agent choice. Existing cards keep their old model windows, so re-import presets or update them manually when a preset change matters. Use `provider-set-key` for dotted keys such as `agents.default_subagent_model`.
- **Quoted TOML table headers (4.0.13)**: CC Switch now recognizes `[model_providers."custom"]`, `[model_providers."my provider"]`, and single-quoted equivalents. `check --strict` and `repair --mode codex-0149` decode quoted key parts for comparison and backfill valid TOML strings; never build `name = "{quoted_id}"` from the raw header.
- **Codex desktop app still needs `~/.codex/auth.json`**: some Codex builds (especially the desktop app / patched CLI) decide "logged in" by the *presence* of `auth.json`. Deleting it — the 3.20.1 config-only ideal — can drop Codex back to the default login screen even when `experimental_bearer_token` is correctly written into `config.toml` (a commented-out token means the file is present but inactive). CCS 3.20.2 fixed only the **takeover** variant of this trap; a **direct** third-party switch with "preserve official login" off still deletes `auth.json`. Keep `auth.json` (with `OPENAI_API_KEY`) and set `preserveCodexOfficialAuthOnSwitch = true` in `~/.cc-switch/settings.json` so CCS never deletes it during a third-party switch; the provider-table `experimental_bearer_token` remains the stored 3.20.1+ shape in the DB.
- **Settings and device-state hardening (4.0.15)**: if `settings.json` has a BOM, a truncated tail, or an incomplete JSON object, 4.0.15 keeps a `settings.json.broken-<time>.bak` and salvages what it can on startup. Settings already reset by an older update cannot be recovered. `doctor` warns instead of silently ignoring malformed `settings.json` / `live-state.json`; it also warns when `preserveCodexOfficialAuthOnSwitch` is not `true`.
- **Deep links and local providers (4.0.9–4.0.12)**: deep links can carry `apiFormat`, Pi providers, and a validated `iconUrl`; values that expand as commands or environment variables are rejected. Local Ollama / LM Studio / llama.cpp / vLLM providers bypass configured proxies for loopback addresses. These are CCS UI/import behaviors; use the skill's DB commands only for entries you intentionally manage.
- **Routing and MCP fixes (4.0.16–4.0.17)**: normal Codex route attach/exit now preserves login and avoids restoring stale credentials; a true direct third-party switch with `preserveCodexOfficialAuthOnSwitch=false` can still remove `auth.json`. Url-only MCP entries now sync to Hermes/OpenCode as HTTP, concurrent multi-select writes no longer overwrite each other, and curly quotes inside TOML string values stay unchanged. Schema remained v20.
- **Antigravity CLI (4.0.18)**: 11th managed app (`agy`), schema v21 adds `enabled_agy`. Providers are terminal-launch scoped; MCP/Skills/Prompts use `~/.gemini/config`. Antigravity MCP rejects SSE. macOS can manage multiple Antigravity accounts, but account selection is not portable across hosts.
- **Kimi Code (4.0.19)**: 12th managed app (`kimi`), schema v22 adds `enabled_kimi`. CLI and desktop share `~/.kimi-code`; providers coexist, MCP/Skills/Prompts sync there, and no proxy or aggregation mode exists. Kimi provider data is the structured `{provider, models}` shape, not the TOML/env shapes supported by the provider-edit commands.
- **Oh My Pi (4.0.20)**: 13th managed app (`omp`), schema v23 adds MCP `enabled_omp`; skills are exists-equals-enabled. Providers use `models.yml`, whose profile/YAML features make generic provider rewrites unsafe.
- **Claude accounts and Codex MCP fixes (4.0.21)**: multiple Claude subscriptions use separate `CLAUDE_CONFIG_DIR` stores managed by Claude Code; never copy credentials. CCS 4.0.21 also stopped writing client-only `timeout` and `autoApprove` into Codex MCP entries.
- **DeepSeek Harness (4.0.22)**: 14th managed app (`dsh`), schema v24 adds MCP/Skills `enabled_dsh` and internal `session_log_sync.parser_state`. Providers/MCP span web/desktop/headless/acp profile patches and `.credentials.yaml`. Codex `[[skills.config]]` array-table handling was also fixed upstream.
- **Native provider editors / thinking levels (4.0.23)**: Kimi, MiniMax and OMP editors show native file syntax; route thinking levels cover more OpenAI/Gemini models; usage speed/first-token fields improve. No schema change. DSH is not an additive provider for direct JSON editing: use `dsh-provider-get/set/remove`.
- **DSH and global-setting hardening (4.0.24–4.0.26)**: DSH filters model inputs to `text`/`image` and restores the credentials store for existing headless profiles. DSH gains a configurable directory (including WSL paths), and the helper resolves it in the same settings-first order. Codex `[agents].max_threads` is a client-global setting that survives provider switches; never place it in a provider card.
- **Config and Skill write hardening (4.0.27)**: config writers follow file symlinks and update the target without replacing the link; Windows dotfiles setups no longer fail with error 1464. Skill update hashes ignore Python bytecode (`__pycache__/`, `*.pyc`) and hidden files. CCS-owned `model_catalog_json` points to an absolute file for native Codex config dirs because newer Codex builds reread custom permissions; WSL/UNC config dirs keep the bare filename. **Since 4.0.29 a Windows Codex desktop that runs Codex in WSL (`[desktop] runCodexInWindowsSubsystemForLinux = true`) also keeps the bare filename** — a `C:\...` path is relative to the Linux binary and the desktop app fails at startup with `os error 2` (#9375). `check --strict` reports both wrong shapes and `repair --target config.toml --mode codex-catalog-path` rewrites the pointer in either direction.
- **Codex 0.167 / CCS 4.0.28**: Codex separates official and third-party sessions by provider id. Direct mode with unified history off makes the inactive group read-only; route/stack keeps third-party routing in the built-in `openai` bucket when a ChatGPT login exists. `unifyCodexSessionHistory` can merge both groups and `codexProxyWithoutOfficialLogin` can pause the official login only in route/stack. Legacy `disable_response_storage` is rejected; run `check --strict` and `repair --mode codex-0167` for live or provider configs. The official-quota guard defaults on once via `localMigrations.codexQuotaProtectionDefaultOnV1`. A local-router `openai_base_url` without a bearer is a valid 4.0.28 route contract, not a legacy misroute.
- **GitHub Copilot CLI and 4.0.29 routing fixes**: Copilot is the 15th managed app (`copilot`), schema v25 adds `enabled_copilot`; BYOK providers live in `providers.json` and never touch the CCS router. 4.0.29 also stopped sending a Windows catalog path to WSL-hosted Codex, stopped rewriting page-context tool results for third-party native Responses upstreams (a 400 without `call_id`), raised the default max output for Anthropic-format upstreams behind the router to 32000, and fixed Mistral 422 on Claude Code routes. No database migration beyond v25.
- **Tencent WorkBuddy, privacy filter and 4.0.30–4.0.31 hardening**: WorkBuddy is the 16th managed app (`workbuddy`), schema v26 adds `enabled_workbuddy`. Providers are flattened into `models.json` entries that each carry their own url/apiKey (`ccSwitchProviderId` marks CCS ownership), MCP → `mcp.json`, prompts → the account-scoped `MEMORY.md`; connectors and WorkBuddy-added models are left alone. Quit WorkBuddy completely before switching accounts or it writes the current login back. 4.0.30 added an optional privacy filter that rewrites emails, phone numbers, ID/bank cards, IPv4 (loopback excluded) and API keys/tokens/private keys **only for route/stack traffic** — direct connections are never filtered, tool results are not filtered by default, and replacements are irreversible, so a filtered file-edit payload will not match the on-disk text. 4.0.31 moves the filter to the last step before the upstream request (covering failover retries and CCS-generated compaction summaries) and now writes `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` with the provider instead of letting a switch clear it (#9451/#9455). Skill symlink failures now report the OS error code.
- **Plugins page (4.0.36+, Antigravity since 4.0.40)**: CCS gained a **Plugins** page for Claude Code, Codex, Grok Build, MiniMax Code, OpenClaw, Pi and Antigravity CLI — install / enable / disable / update / uninstall. Only Claude Code, Codex and Grok Build also let CCS manage plugin marketplaces (Mcode, OpenClaw, Pi and Agy reject marketplace management as unsupported). For **Codex** a disable only flips `enabled` inside `[plugins."<plugin>@<marketplace>"]` in `config.toml` and leaves every other line and comment untouched, and a marketplace is a `[marketplaces.<name>]` table with `source_type` / `source`. Since 4.0.39 the page also stops creating empty directories for apps that are not installed, and on a Codex-desktop-only machine it resolves the bundled CLI instead of reporting "not installed". Treat `[plugins]`, `[plugins.*]` and `[marketplaces]` as **live-config-only** content: they belong in `~/.codex/config.toml`, never in a provider card, and `repair --mode live-only` refuses `--target config.toml` for exactly that reason. The skill does not edit plugins; use the CCS page and only audit the result.
- **Unreadable providers and MCP entries (4.0.37+)**: a provider or MCP row whose stored JSON cannot be parsed is now kept as an **unreadable entry** instead of being treated as an empty config. Such a row is listed as-is, cannot be edited or enabled, is skipped by failover, and rejects any edit; additive apps (OpenCode and friends) refuse a full sync while one exists. Deleting only removes the CCS record, never the app's config file (#9767). `check --strict` and `doctor --audit` report them (`unreadable settings_config` / `unreadable server_config`), and the helper never overwrites them (`mcp-upsert` refuses and points at `--force`; `set-flags` refuses to turn one *on*, while turning it off still works); fix the row in CCS or delete it there and re-enter the provider.
- **Claude Code 1M marker (4.0.37+)**: the 1M context marker CCS writes into Claude Code model names is lowercase `[1m]`. Uppercase `[1M]` is legacy and is rewritten on the next write; do not "fix" it by hand.
- **DSH `reasoningEfforts` validation (4.0.38, #9785; three layers since v1.8.1)**: DSH's `llm-pi-ai` schema accepts `reasoningEfforts: false` or a non-empty map keyed by `off`/`minimal`/`low`/`medium`/`high`/`xhigh`/`max` with `string | null` values. A YAML 1.1 parser turns an unquoted `off: null` into the boolean key `false`, and DSH then discards **the whole provider block**, so every third-party provider disappears from DeepSeek Harness. CCS 4.0.38 normalizes on both read and write: `false` becomes `off` (when `off` is absent), unknown levels and non-`string | null` values are dropped, and an emptied map removes the key. `dsh-provider-set` applies the same normalization, and `check --strict` / `doctor` report a hand-edited profile that still carries a bad key. The helper always quotes `"off"` when rendering YAML so it cannot reproduce the bug.
Since v1.8.1 the audit parses the file with **PyYAML** instead of guessing from the raw text (guessing produced false positives on perfectly legal YAML: bare `high: high`, a flow map, a quoted `"off"` key, `!!str null`, a block scalar, a trailing comment, an anchor). It reports three separate layers: YAML syntax, field schema (unknown level, wrong type, empty string, `null` on a level other than `off`), and model semantics (`{}`, a top-level `null`, or a map offering nothing beyond `off` — DSH refuses each). The same checks cover `modelOverrides` as well as `models`. `dsh-provider-set` now **refuses** input it cannot normalize losslessly instead of silently dropping keys, and validates the candidate provider before writing; a rename of `false` to `off` is reported as `[WARN]`.
- **CCS 4.0.32**: CCS recovers from a crashed internal write instead of leaving a half-written database or config (the failed change rolls back), and unified Codex history keeps each `.jsonl` file's original modification time so old sessions no longer jump to the top of `codex resume` (#3866/#9471). Codex route switches retry once on `Encrypted function output content could not be decrypted` (#9476), Mistral no longer rejects the Responses-only fields (#9507), and an optional background auto-download plus an IP-detection panel were added to settings (UI only).
- **Backups, WAL and the 4.0.39–4.0.40 storage changes**: 4.0.39 added `backup_max_total_mb` (default unlimited, `0` = unlimited; over the limit the oldest backups are pruned and the newest plus any being restored are always kept) next to the existing `backup_interval_hours` (default 24, `0` = off) and `backup_retain_count` (default 10). 4.0.40 then moved the main database to **WAL** (`busy_timeout=5000`, `journal_mode=WAL`, `synchronous=NORMAL`, `temp_store=MEMORY`, `cache_size=-16000`). CC Switch's own backups go through the SQLite online-backup API and file-writing is restricted to the current user on macOS/Linux (4.0.41). Consequence for this skill: **a plain `copy` of `cc-switch.db` can be stale** — verified here, a byte copy reported `user_version=27`/24 skill columns while the live database was v29/26 columns. `snapshot`, the automatic repair backups and `diff` all use `sqlite3.Connection.backup()`, and `diff` now prints `schema user_version: backup=<v> current=<v>` with an explicit warning when the backup predates the live schema. `doctor` prints `db journal_mode:` plus the sidecar files it sees. Old backups in `~/.cc-switch/backups/` that were taken by an older CCS (schema v27 era) stay stale; re-take them with `snapshot` before relying on them.
- **CodeBuddy (4.0.41+)**: CodeBuddy is the 17th managed app (`codebuddy`), schema v28 adds MCP/Skills `enabled_codebuddy`. It is additive and shares one configuration between the desktop app and the CLI, resolved via `CODEBUDDY_CONFIG_DIR` → `~/.codebuddy`. Providers are custom entries in `models.json` with a `custom-local:` model id; that file **must stay strict JSON** (a comment or a trailing comma makes CodeBuddy ignore the whole file) and CCS validates it as a whole document, so `provider-block` / `provider-env` / `provider-set-key` refuse codebuddy. MCP is read from one user-scope file (`.mcp.json` → `mcp.json` → `.codebuddy.json`, first match wins, no merging), skills go to `<CODEBUDDY_CONFIG_DIR>/skills`, and prompts to `CODEBUDDY.md`.
- **ZCode (4.0.44+)**: ZCode is the 18th managed app (`zcode`), schema v29 adds MCP/Skills `enabled_zcode`. Also additive, with `<ZCODE_HOME>` resolved from settings → `~/.zcode` (there is no `ZCODE_HOME` environment variable). Providers live in `<ZCODE_HOME>/v2/provider_config.json` as `config.modelConfigRules` plus `providerOrder`; CCS **never writes provider fields into `v2/config.json`**, and the file is validated as a whole document, so the provider-edit commands refuse zcode. MCP lives in `<ZCODE_HOME>/cli/config.json` under `mcp.servers`, sessions/usage in `<ZCODE_HOME>/cli/db/db.sqlite`, skills in `<ZCODE_HOME>/skills`, and the global prompt is `<ZCODE_HOME>/AGENTS.md`.
- **Antigravity accounts belong to agy (4.0.44+)**: CCS no longer logs in, renews or queries Antigravity for you — add/switch accounts by running `agy` in a terminal and using its own `/logout` and `/login`, and read quota with agy's `/usage`. Tray account switching (4.0.43) binds to the agy-side session, so never try to repair an Antigravity login from CCS files.
- **Other 4.0.39–4.0.44 behavior worth knowing**: 4.0.43 allows **OpenCode 2** side by side with 1.x (separate `@opencode/cli` package; CCS picks the version from where it is actually installed) and fixed OpenClaw configs being corrupted when they contain `/* */` block comments; 4.0.44 makes an unreadable account file get renamed to `.unreadable-<timestamp>` in place instead of being overwritten with an empty table, and raised the local-router single-event limit to 64 MiB; 4.0.42 added GitHub Copilot **Auto** model selection (`copilot-fusion-auto`, needs the local router, works on Copilot Free); 4.0.40 hardened deep-link MCP import, usage scripts and SQL import, and — when the router listens on `0.0.0.0`/`::` — requires a valid Host header even for local requests, so a custom hostname must be entered under "connection address" or requests return 403.
- **Common-config removed (4.0)**: the snippet feature is gone. On schema ≥ v20 the helper **refuses every `common-config` command** and points to the new way: shared keys go into the client config file, provider-specific fields into the card (`provider-block` / `provider-set-key` / `provider-env`). Legacy `common_config_*` rows and `meta.common_config_enabled` stay in the DB but are inert; audits skip them on v20.
- **CCS ≤ 3.20.4 common-config maintenance**: `common-config` only modifies the snippet when explicitly invoked; `enable` requires an idempotence check; `extract` auto-enables after success; `set*` asks whether to sync the current config and enable. Never hand-write temporary scripts to edit the CCS DB directly; DB writes go through `ccs_db.py`.
- **Scope disambiguation**: identify the sync object (configuration / skill files / template) yourself from context and pending changes — do not ask the user unless it is genuinely unresolvable. If the identified scope includes configuration, fall into the config-change iron rules below (provider-first, preflight, backup/stop/validate/restart). Only touch the `common-config` snippet directly on CCS ≤ 3.20.4 and only when the user explicitly says "common config" / "通用配置" / "模板"; never treat a sync of one object as a sync of a different object.
- **Provider-first sync**: a config "sync" without an explicit scope updates the provider config via `provider-set-key`; on CCS ≤ 3.20.4 ask afterwards whether to `common-config extract` to the template, on 4.0+ tell the user that shared keys belong in the client config file instead.
- **Uncertainty handling**: when unsure, first re-read this skill (SKILL.md and its references) — do not improvise. If the request is outside this skill's scope, tell the user and propose recommended actions.
## References
> The DSH audit (`check --strict`, `doctor`, `dsh-provider-set`) imports **PyYAML**. It is the one non-stdlib dependency; when it is missing those commands say the `reasoningEfforts` audit did not run instead of falling back to text guessing, and everything else keeps working. Install it with `pip install pyyaml` (recommended: Python 3.11+).
- references/architecture.md — paths, tables, effect chain
- references/apps.md — the 18 managed apps matrix
- references/operations.md — copy-paste command templates (PowerShell + bash)
- references/pitfalls.md — known pitfalls
- references/migration.md — official CCS version behavior changes
- references/examples/ — sample TOML/JSON/prompt files
## Helper script
- scripts/ccs_db.py — portable CCS DB operations (UTF-8 safe). Subcommands: `mcp-upsert`, `prompt-set`, `skill-upsert` (`--preserve-flags` for existing-skill refreshes, `--repo-host` for GitLab/Gitea/Forgejo sources, reads from the resolved skills SSOT), `provider-block`, `provider-env`, `provider-set-key`, `dsh-provider-get/set/remove`, `set-flags`, `check` (`--strict`), `doctor` (`--audit` / `--compare-backup`, prints 18-app provider counts, journal mode and WAL sidecars, the resolved skills directory with its source, skill repository hosts, DSH/Copilot/WorkBuddy directory resolution, Codex session/auth diagnostics, flag-column availability, user-facing modes, unreadable entries and safety warnings), `snapshot` (WAL-safe, uses the SQLite backup API), `diff` (reports both schema versions and warns when a backup predates the live schema), `repair` (header-order / live-only / codex-0149 / codex-key / mcp-type / codex-catalog-path / codex-0167; `live-only` is provider-target only), `common-config`. `mcp-upsert` / `skill-upsert` / `set-flags` support `agy`, `kimi`, `omp`, `dsh`, `copilot`, `workbuddy`, `codebuddy` and `zcode` with each app's flag semantics. `provider-block` / `provider-env` / `provider-set-key` refuse the structured apps (mcode, kimi, agy, omp, dsh, copilot, workbuddy, codebuddy, zcode) and point at the CCS UI or `dsh-provider-*` instead. `dsh-provider-set` transactionally updates all profile patches, credentials and the DB row, normalizes `reasoningEfforts` to DSH's accepted levels (reporting every rename as `[WARN]`), refuses input it cannot normalize losslessly, and validates the candidate provider before writing; `dsh-provider-remove` reverses it.