Skip to main content

cc-switch

Generate ~/.claude/settings.json from saved provider/model configs — a small CLI that mirrors the credstore pattern.

Non-secret provider shape lives in ~/.claude/cc-switch.json. API keys are never stored there — the config keeps the key's name, and the value is read from credstore at activate time and injected into the current process environment as ANTHROPIC_AUTH_TOKEN. The generated settings.json contains no credential line.

Install

cc-switch is a standalone PyPI package — installed independently of slife (installing slife does not bring cc-switch, and vice versa). Both depend on credstore, which is pulled in automatically.

uv tool install cc-switch
# or, in this repo:
uv sync

Commands

cc-switch set <provider-name>

Create or edit a provider. Prompts for:

  • Base URL (required)
  • API key name — the credstore key holding the secret (required)
  • Supported models (optional; comma, space, or semicolon separated)

If the provider already exists this edits it; otherwise it adds it. The models prompt toggles against the provider's current list: a model you type that is already listed is removed, one that isn't is added (symmetric difference). Typing the same list again undoes the change.

cc-switch set deepseek
# Base URL [..]: https://api.deepseek.com/anthropic
# API key name (credstore key): DEEPSEEK_API_KEY
# Supported models (comma separated; toggles against the current list): deepseek-chat,deepseek-reasoner

No secret value is ever asked for or written — store it first with:

credstore set DEEPSEEK_API_KEY

cc-switch activate <provider-name/model-name>

Writes ~/.claude/settings.json with stock Claude Code defaults, and injects the API key from credstore into the system environment as ANTHROPIC_AUTH_TOKEN (mirroring credstore inject — registry on Windows, shell profile on Unix), so a freshly launched Claude Code session inherits it. The settings file contains no credential.

If the provider's API key is not in credstore, activate fails loudly with a credstore set <key> hint instead of writing an unusable setup.

cc-switch activate deepseek/deepseek-chat

If the model is omitted and the provider has exactly one model, it is used; if several, you are prompted to pick one.

cc-switch activate <provider-name/model-name> --custom

Like activate, but lets you override every model slot first — ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_CLAUDE_CODE_SUBAGENT_MODEL, ANTHROPIC_MODEL, ANTHROPIC_CLAUDE_CODE_EFFORT_LEVEL — one at a time. Enter a value to override, or Enter to keep the default. Overrides are one-shot: they never touch the stored provider config.

cc-switch list

Lists every configured provider/model pair, one per line:

deepseek/deepseek-chat
deepseek/deepseek-reasoner
scnet/scnet-1m

cc-switch list-providers

Shows provider metadata (base URL, API key name, models) without the model-per-line layout of list.

cc-switch remove <provider-name>

Deletes a provider config. Does not touch credstore or settings.json.

Files

Path Purpose
~/.claude/cc-switch.json Provider/model shapes (no secrets)
~/.claude/settings.json Generated by activate
credstore (DEEPSEEK_API_KEY, …) The actual API key values

CC_SWITCH_FILE overrides the config path; the settings path can be overridden for tests.

Security notes

  • The config file holds only metadata — the API key is referenced by name.
  • activate reads the secret from credstore and injects it into the system environment as ANTHROPIC_AUTH_TOKEN (registry on Windows / shell profile on Unix), mirroring credstore inject; it is never written to settings.json.
  • On a TTY, activate prints an activation hint without echoing the secret; when stdout is piped it emits the shell export line for eval.
  • Restart your shell (or start a new terminal) after activating for the env change to take effect in the current session.
  • Secrets are immutable Python str — cc-switch follows credstore's practice of del-ing the reference immediately after use.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cc_switch-0.9.7.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc_switch-0.9.7-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file cc_switch-0.9.7.tar.gz.

File metadata

  • Download URL: cc_switch-0.9.7.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for cc_switch-0.9.7.tar.gz
Algorithm Hash digest
SHA256 1ba76fcaeb1b09fe58475ee46b499e23ba147ab387f49a286479dff302f7d45f
MD5 d0c3c42485a9152e1f21ef0fa1054bb9
BLAKE2b-256 0cb1ed67968a60cc9c06183d027de7ee7a2029aae581de2225a34c549e7ea510

See more details on using hashes here.

File details

Details for the file cc_switch-0.9.7-py3-none-any.whl.

File metadata

  • Download URL: cc_switch-0.9.7-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for cc_switch-0.9.7-py3-none-any.whl
Algorithm Hash digest
SHA256 76f4ce2ea56e266100fefb9ef2758a6474780fdc06c17bd246c43d917f6a1d4a
MD5 f73d18250f0c094b902028bc77372a71
BLAKE2b-256 dc841128bebd99cca27cd5e985fb63004972fdc1f69f280f20aa7715e6f2248d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.9.7 This release

2 files

0.9.6

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page