opencode-claude-auth: reuse your Claude Code login inside OpenCode
OpenCode plugin that uses your existing Claude Code credentials — no separate login needed.
At a glance
- What is it?
- An OpenCode plugin that registers its own Anthropic auth provider and reads Claude Code credentials from the macOS Keychain or a credentials file. It removes a second login, at the cost of depending on Claude Code's token storage format.
- Who is it for?
- Adopt it if you already run Claude Code on macOS and want OpenCode to inherit that session without a second login; the Keychain path and the multi-account switcher are the parts that make it worth installing there. Skip it if you run a CLIProxyAPI setup, since the README says the two should not be combined, or if you cannot keep Claude Code authenticated because the plugin has no credentials of its own.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 40 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- griffinmartin/opencode-claude-auth1,327 ★ · +56
| Repository | 2026-09-15 | 2026-11-25 |
|---|---|---|
| griffinmartin/opencode-claude-auth | 1.3k | 1.3k |
56 Stars in the last 71 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The double login problem opencode-claude-auth removes
OpenCode talks to Anthropic through a provider, and a provider normally wants an API key or its own OAuth flow. If you already pay for Claude Code and have it authenticated, that second credential is redundant work: another login, another token to rotate, another place a key can leak from. This plugin exists to collapse the two into one. It is aimed at people who run Claude Code and OpenCode on the same machine and would rather not maintain two Anthropic identities.
The scope is deliberately narrow. The README describes it as a "Self-contained Anthropic auth provider for OpenCode using your Claude Code credentials". It does not proxy other providers, does not manage billing, and does not abstract away Anthropic. If you only use OpenCode with an API key and have never installed Claude Code, this plugin has nothing to offer you.
How the plugin intercepts Anthropic requests
The mechanism is a custom fetch handler registered as an auth provider. The plugin does not sit next to OpenCode's built-in Anthropic auth; the README states it handles the full request lifecycle and that "no builtin Anthropic auth plugin required". Every Anthropic API request OpenCode makes passes through that handler, which attaches credentials before the request leaves the process.
Credentials come from a fixed lookup order. On macOS the plugin reads all `Claude Code-credentials*` entries from the Keychain, which is how it detects more than one account. Elsewhere it falls back to `~/.claude/.credentials.json`, or to `$CLAUDE_CONFIG_DIR/.credentials.json` when that environment variable is set. Tokens are cached in memory with a 30-second TTL, so a burst of requests does not mean a burst of Keychain reads.
Refresh is the part worth understanding before you trust it. When a token is near expiry the plugin calls Anthropic's OAuth endpoint directly, which the README notes consumes zero LLM tokens, and only falls back to invoking the `claude` CLI if that direct refresh fails. Separately, it syncs credentials into OpenCode's `auth.json` as a fallback and re-syncs in the background every 5 minutes. On Windows it writes that file in two locations, `%USERPROFILE%\.local\share\opencode\auth.json` and `%LOCALAPPDATA%\opencode\auth.json`, to cover different installation methods.
That design has a consequence worth naming: the plugin is a consumer of Claude Code's credential format, not a party to it. If Anthropic changes where or how Claude Code stores tokens, this plugin breaks until it catches up.
Installing opencode-claude-auth and running a first request
There are two prerequisites and neither is optional: Claude Code installed and authenticated at least once (run `claude`), and OpenCode installed. macOS is the preferred platform because the plugin uses the Keychain; Linux and Windows work through the credentials file fallback.
Installation is a single entry in OpenCode's config. Add the plugin to `~/.config/opencode/opencode.json`:
{
"plugin": ["opencode-claude-auth@latest"]
}The `@latest` tag is what the README recommends, so OpenCode pulls the newest version on startup. There is no manual `npm install` step: OpenCode installs npm plugins with Bun at startup, per its plugin documentation. The package is also published as `opencode-claude-auth` on npm if you want to inspect it before adding it.
After that, use OpenCode as normal. The README's usage section is one line long: run OpenCode and the plugin handles auth automatically, reading your Claude Code credentials, supplying them to the Anthropic API, and refreshing them in the background. If your credentials are not OAuth-based, it falls through to standard API key auth instead of failing.
If you have several Claude Code accounts on macOS, switch between them with:
opencode auth loginPick "Switch Claude Code account" and choose one. The selection persists across sessions. Accounts are labeled by subscription tier (Claude Pro, Claude Max), and when only one account is found the switcher is hidden. To check which models your account can actually reach, the repository provides `pnpm run test:models`, which builds the project first and then runs `scripts/test-models.ts`.
Where opencode-claude-auth breaks, and when to pick something else
The failure modes are all credential-shaped, and the README's troubleshooting table lists them plainly. "Credentials not found" means Claude Code was never authenticated. A locked Keychain is resolved with `security unlock-keychain ~/Library/Keychains/login.keychain-db`. "Token expired and refresh failed" means both the direct OAuth refresh and the `claude` CLI fallback failed, and the fix is to re-authenticate by running `claude` yourself. On Linux and Windows, the common cause is simply that `~/.claude/.credentials.json` does not exist yet.
The structural limitation is that this plugin owns no credentials. Everything it sends originates in Claude Code, so if Claude Code is logged out, uninstalled, or its token storage moves, OpenCode loses Anthropic access too. That is a real coupling, not a theoretical one. It also means the plugin is the wrong tool if you want OpenCode to run against Anthropic independently of a Claude Code installation, for example on a shared or headless machine where nobody logs into Claude Code interactively.
The README points at an alternative for that case: CLIProxyAPI. Instead of intercepting requests inside OpenCode, CLIProxyAPI logs in to the Claude Code account with OAuth itself, refreshes tokens, and exposes a Claude-compatible API on `http://localhost:8317` by default. You then point OpenCode's built-in Anthropic provider at it in `~/.config/opencode/opencode.json`:
{
"provider": {
"anthropic": {
"options": {
"baseURL": "http://localhost:8317",
"apiKey": "your-api-key-1"
}
}
}
}The difference in approach is architectural. CLIProxyAPI is a separate long-running service that holds the session and speaks a Claude-compatible API, which also brings multi-account load balancing and support for other providers such as Codex, Gemini and Grok. opencode-claude-auth is a plugin inside the OpenCode process with no extra daemon. The README is explicit that the two should not be combined and that the plugin should be removed from your `plugin` list when using the proxy setup. If you only need Claude Code credentials in OpenCode and want nothing else running, the plugin is the lighter of the two.
Maintenance, licence and the cost of tracking someone else's auth format
The repository is MIT licensed, which is permissive and places no copyleft obligation on your own code. The practical implication of a permissive licence here is that you can vendor or fork the plugin if upstream stops keeping pace with Anthropic's credential format; nothing in the licence prevents that. This is not legal advice, and the licence text in the repository is the authority.
Maintenance activity is visible in the release history: v2.1.5 on 2026-07-30, v2.1.6 on 2026-08-03, and v2.2.0 on 2026-09-01, with the last push to the default branch on 2026-09-12. The repository is not archived. Because the plugin depends on an external credential format it does not control, upgrade cost is not really about the plugin's own API surface. It is about how quickly a change in Claude Code's Keychain entries or credentials file is absorbed. The `@latest` tag means OpenCode picks up new versions on startup, so you get fixes without a manual step, and you also get regressions without a manual step. Pinning a version in the plugin list is the obvious hedge if you would rather review changes before they land, though the README does not document a pinning workflow or a rollback procedure.
The development tooling is standard for a TypeScript project: `pnpm run build`, `pnpm test`, and a Makefile with targets including `build`, `test`, `test-models`, `lint`, `format`, `clean`, `intercept`, `intercept-all`, `validate-oauth` and `validate-oauth-dry`. The last two are notable because `validate-oauth` performs a live OAuth refresh that rotates the token and writes it back, while `validate-oauth-dry` performs no network request. If you fork the project, that distinction matters.
Editorial conclusion
Adopt it if you already run Claude Code on macOS and want OpenCode to inherit that session without a second login; the Keychain path and the multi-account switcher are the parts that make it worth installing there. Skip it if you run a CLIProxyAPI setup, since the README says the two should not be combined, or if you cannot keep Claude Code authenticated because the plugin has no credentials of its own. Verify first that ~/.claude/.credentials.json or a Claude Code-credentials entry actually exists on your machine, then run pnpm run test:models to confirm your account reaches the models you need.
Frequently asked questions
What is opencode-claude-auth and who is it for?
It is an OpenCode plugin that registers an Anthropic auth provider using your existing Claude Code credentials, so you do not need a separate login or API key. It is for people who already run Claude Code and OpenCode on the same machine, preferably macOS.
How do I install opencode-claude-auth?
Add "opencode-claude-auth@latest" to the plugin list in ~/.config/opencode/opencode.json. No manual npm install is needed because OpenCode installs npm plugins with Bun at startup.
Where does opencode-claude-auth read my Claude Code credentials from?
It checks the macOS Keychain for all Claude Code-credentials entries first, then falls back to ~/.claude/.credentials.json on any platform, or $CLAUDE_CONFIG_DIR/.credentials.json when that environment variable is set.
Can I switch between multiple Claude Code accounts with opencode-claude-auth?
On macOS the plugin detects multiple authenticated accounts automatically and labels each by subscription tier. Run opencode auth login, choose "Switch Claude Code account", and the selection persists across sessions.
Why does opencode-claude-auth say credentials not found?
Claude Code has not been authenticated yet, so run claude once to create the credentials. On Linux and Windows, also confirm that ~/.claude/.credentials.json exists.
How do I check which Claude models opencode-claude-auth supports?
The README lists 14 supported models and recommends running pnpm run test:models to verify them against your own account. The repository's Makefile exposes the same check as make test-models.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/griffinmartin-opencode-claude-auth)Star history chart for your README
[](https://hysenlabs.com/projects/griffinmartin-opencode-claude-auth)Was this useful?