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.
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| STORE
src/— TypeScript source (driver/driver + OAuth config/login,oauth/PKCE flow,plugin/request.tsAnthropic rewrite,commands.tsslash-commands,handler.ts/index.ts/cli.tsentries)core-auth/— the shared auth engine (git submodule)core/— sharedintisy-ai/coresubmodule (config + logging + command framework), bundled indist/— Compiled bundles:index.js(OpenCode),handler.js(Claude loader),cli.js(CLI)
Add to ~/.config/opencode/config/plugins.json:
[{ "name": "claude-code-auth", "url": "https://github.com/intisy-ai/claude-code-auth", "enabled": true }]npm install claude-code-authAdd Claude accounts (shared by both apps):
npx claude-code-auth login # repeat to add more accounts
npx claude-code-auth listConfig files are never auto-created on launch — settings are registered with defaults (core
defineConfig) and edited in the loader's Plugins → Configure screen (or/<plugin>-config); a file is written only when you change a value. Global console logging for every plugin is toggled inconfig/settings.json(logConsole: true, the opencode.json-equivalent).
Accounts are stored by core-auth at ~/.config/opencode/accounts.json (and ~/.claude/... for Claude Code). The OAuth client is the public Claude Code installed-app client; override the client id with CLAUDE_CODE_CLIENT_ID if needed.
- OpenCode: registers a custom
claude-codeprovider (SDK@ai-sdk/anthropic); runopencode run -m claude-code/claude-sonnet-4-6. - Claude Code: select
claude-codein the loader's Providers tab; the proxy routes Claude requests through your subscription accounts.
Plugin config (claude-code-auth.json) is editable from chat via /claude-code-auth-config.
Deployed automatically to both apps on load (~/.config/opencode/command/ and ~/.claude/commands/):
| Command | Description |
|---|---|
/claude-code-auth-config |
View/change any config key: list, get <key>, set <key> <value>. 100% of the config is reachable here. |
/claude-accounts |
List signed-in Claude subscription accounts and their enabled state. |
core(required) — bundled git submodule (config + logging + commands); no separate install.core-auth(required) — bundled git submodule (account store + OAuth/rotation engine).sync-bridge(optional) — mirrors the account store to the other app when present.
core-auth writes provider logs under the app config dir (~/.config/opencode/logs/... or ~/.claude/logs/...).
MIT