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 system 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. When editing, a blank answer keeps the current value. 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). A blank answer leaves the list unchanged, and 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.

settings.json is written first, then the secret is resolved from credstore. If the key is missing — or credstore itself is not installed — activate fails loudly with the appropriate hint, leaving the generated settings file on disk but not injecting a token.

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 each model slot first — ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_CLAUDE_CODE_SUBAGENT_MODEL, and ANTHROPIC_CLAUDE_CODE_EFFORT_LEVEL — one at a time. Enter a value to override, or Enter to keep the default. The main model slot (ANTHROPIC_MODEL) is chosen on the command line, not here. Overrides are one-shot: they never touch the stored provider config.

cc-switch

With no command, lists every configured provider/model pair, one per line:

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

cc-switch list

Shows provider metadata (base URL, API key name, models) — one block per provider.

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.
  • A provider's extra_env (settable via the Python API) may not contain ANTHROPIC_MODEL, ANTHROPIC_BASE_URL, or ANTHROPIC_AUTH_TOKEN — cc-switch owns those slots, and a secret must never reach the plaintext config.
  • 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.

Metadata

Release files for cc-switch 0.9.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cc-switch 0.9.9
File Size Uploaded
cc_switch-0.9.9.tar.gz 22.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cc-switch 0.9.9
File Interpreter ABI Platform
cc_switch-0.9.9-py3-none-any.whl Python 3 none any Details

Total release size: 37.0 kB

Release files / cc_switch-0.9.9.tar.gz

Download URL cc_switch-0.9.9.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8222fa9617bb27eeac9cdb3c0ac4af83e4da71091f74b8f82d61c81c7733e6f6
BLAKE2b-256 checksum
How to use checksums
718ad56240ffa67c0819f0f49b45d389f9d27821d37703dc71fdc549d4fec51b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / cc_switch-0.9.9-py3-none-any.whl

Download URL cc_switch-0.9.9-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a08fb27d1b16dedd24e30cfb295b734847545bdbed9f346fbf3872a8e0cb1dc
BLAKE2b-256 checksum
How to use checksums
60d67cbbaf13f156875ebb3f03a7da184002decd418b82e6ab03c1db6865b4e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.9.11

2 release files

This release

0.9.9 This release

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page