claude-code-auth
v2.7.2
Published
Claude Code subscription auth provider for OpenCode and Claude Code — multiple Claude accounts via OAuth, with subscription rate limits exposed to OpenCode.
Maintainers
Readme
claude-code-auth
A core-auth provider that signs in to Claude with the real Claude Code OAuth flow and lets you add multiple Claude subscription accounts. Both Claude Code (via the loader proxy) and OpenCode route requests through it, rotating accounts and respecting each one's subscription rate limits — so OpenCode uses your Claude Code subscription instead of a pay-per-token API key.
Under-the-Hood Architecture
flowchart TD
subgraph Driver [claude-code driver — thin layer on core-auth]
HANDLE["handle(request) — Anthropic request rewrite"]
LOGIN["loginFlow() — PKCE OAuth"]
end
subgraph Core [core-auth]
MGR[AccountManager: select / refresh / rotate]
STORE[(accounts.json)]
MGR <--> STORE
end
CC[Claude Code loader proxy] -->|dist/handler.js handle| HANDLE
OC[OpenCode loader] -->|loader.fetch| HANDLE
HANDLE -->|acquire account + token| MGR
HANDLE -->|"Bearer + anthropic-beta: oauth + Claude Code system block"| API[(api.anthropic.com)]
API -->|429 / 529| MGR
LOGIN -->|platform.claude.com OAuth| STOREStructure
src/driver/— driver + OAuth config/login (request prep now round-trips through core-ir, java/claude-provider)oauth/— PKCE flowcommands.ts— slash-commandshandler.ts/index.ts/cli.ts— entries
dist/index.js— OpenCode bundlehandler.js— Claude loader bundlecli.js— CLI bundle
Installation
Via plugin-updater (recommended)
npx plugin-updater@latest init https://github.com/intisy-ai/claude-code-authVia npm
npm install claude-code-authConfiguration
Config file: <configDir>/config/claude-code.json (edit via the loader or /claude-code-config set).
{
"logging": true,
"max_account_attempts": 4,
"account_selection_strategy": "hybrid",
"default_cooldown_seconds": 60,
"max_cooldown_seconds": 900
}| Key | Default |
| --- | --- |
| logging | true |
| max_account_attempts | 4 |
| account_selection_strategy | "hybrid" |
| default_cooldown_seconds | 60 |
| max_cooldown_seconds | 900 |
Commands
| Command | Description | Arguments |
| --- | --- | --- |
| /claude-code-auth-config | View and change claude-code-auth configuration | list | get <key> | set <key> <value> |
| /claude-accounts | List signed-in Claude subscription accounts | |
Dependencies
corecore-authsync-bridge
Logging
Logs are written to <configDir>/logs/YYYY-MM-DD/claude-code-auth-HH-MM-SS.log and are toggled by
this plugin's logging config (default on). Console mirroring is global, off by default,
and controlled by the shared config/settings.json logConsole flag.
License
MIT.
