Skip to content

Repository files navigation

cc-gate

CI License: MIT

One local endpoint for all your Claude Code backends. Set ANTHROPIC_BASE_URL once, then switch between MiniMax, GLM, Kimi, and Claude without ever editing settings.json again.

Runs entirely on 127.0.0.1 — your requests never transit a third party you didn't choose. Zero runtime dependencies; Bun + strict TypeScript.

Install

git clone https://github.com/sano0007/cc-gate.git && cd cc-gate
bun install
bun run build        # produces a single self-contained binary at dist/cc-gate
# optional: mv dist/cc-gate ~/.local/bin/  (or anywhere on your PATH)

Or run straight from the checkout with bun bin/cc-gate.ts <command>.

Quickstart

  1. Run cc-gate init. An interactive picker appears — arrow keys (or type a few letters to filter) to choose your provider, then enter the API key. "Custom" in the list lets you type a name and base URL by hand. Piping input works too: printf 'claude\nsk-ant-…\n\n' | cc-gate init.

    cc-gate init
  2. Run the proxy. Pass --write-settings once and your ~/.claude/settings.json will point Claude Code at cc-gate, with a timestamped backup of the original.

    cc-gate start --write-settings
  3. (Optional) confirm everything is wired up:

    cc-gate doctor

You only edit ~/.claude/settings.json once — the --write-settings flag is idempotent and creates a settings.json.bak.<timestamp> the first time it runs. Use CLAUDE_SETTINGS_PATH=/path/to/other.json to target a non-default location.

Switching — never touch settings.json again

How Example Effect
/model inside Claude Code /model minimax,MiniMax-M3 this session, immediately
CLI override cc-gate use minimax all sessions, next request
Clear override cc-gate use --clear router rules apply again
Routing rules "background": "glm,glm-4.5-air" in config automatic per request type

cc-gate doctor shows what the proxy sees. GET /health reports the active override.

The override takes effect on the next request; in-flight requests complete on the previously-routed provider.

Commands

  • cc-gate init [--force] — scaffold ~/.cc-gate/config.json (or CC_GATE_DIR/config.json). Pass --force to overwrite an existing config.
  • cc-gate start [--write-settings] — run the proxy on 127.0.0.1 (default port 8787). With --write-settings, patches CLAUDE_SETTINGS_PATH (default ~/.claude/settings.json) so Claude Code points at cc-gate.
  • cc-gate use [provider|--clear] — show/set/clear the active provider
  • cc-gate doctor — validate config, list providers and aliases

v0.1 scope

Anthropic-passthrough only: auth swap, beta-header hygiene, alias mapping, stream watchdog (stalls become clean retryable errors, never hangs). OpenAI translation, observability, and a status dashboard come later — see docs/architecture.md for the full design.

Providers without aliases receive the model's literal name as-is; configure aliases to enable haiku/sonnet/opus slot mapping.

Security notes

  • The proxy binds 127.0.0.1 only and never logs your API keys (doctor masks all but the last 4 characters).
  • cc-gate init writes ~/.cc-gate/config.json with 0600 permissions and never echoes the API key while you type it.
  • Prefer "api_key": "$MY_ENV_VAR" in the config over literal keys — values starting with $ are resolved from the environment at startup.
  • --write-settings always backs up settings.json before touching it.

Development

bun install
bun test             # 113 tests
bun run typecheck    # strict TypeScript
bun run build        # single-binary compile

The full design/architecture doc lives at docs/architecture.md.

License

MIT

About

One local gateway for Claude Code - switch between Claude, GLM, MiniMax, and Kimi backends with /model or one CLI command, never touching settings.json. Loopback-only, zero deps, single binary

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages