OpenCode plugin that uses your existing Claude Code credentials — no separate login needed
# Add to your Claude Code skills
git clone https://github.com/griffinmartin/opencode-claude-authSelf-contained Anthropic auth provider for OpenCode using your Claude Code credentials — no separate login or API key needed.
The plugin registers its own auth provider with a custom fetch handler that intercepts all Anthropic API requests. It reads OAuth tokens from the macOS Keychain (or ~/.claude/.credentials.json on other platforms), caches them in memory with a 30-second TTL, and handles the full request lifecycle — no builtin Anthropic auth plugin required.
It also syncs credentials to OpenCode's auth.json as a fallback (on Windows, it writes to both %USERPROFILE%\.local\share\opencode\auth.json and %LOCALAPPDATA%\opencode\auth.json to cover all installation methods). If a token is near expiry, it runs the Claude CLI to trigger a refresh. Background re-sync runs every 5 minutes.
claude at least once)macOS is preferred (uses Keychain). Linux and Windows work via the credentials file fallback.
No comments yet. Be the first to share your thoughts!
Paste this into your AI agent (Claude Code, Cursor, Copilot, etc.):
Fetch https://raw.githubusercontent.com/griffinmartin/opencode-claude-auth/main/installation.md and follow every step exactly as written.
brew tap griffinmartin/opencode-claude-auth https://github.com/griffinmartin/opencode-claude-auth.git
brew install opencode-claude-auth
Then add to the plugin array in your opencode.json:
{
"plugin": ["opencode-claude-auth"]
}
npm install -g opencode-claude-auth
Then add to the plugin array in your opencode.json:
{
"plugin": ["opencode-claude-auth"]
}
Just run OpenCode. The plugin handles auth automatically — it reads your Claude Code credentials, provides them to the Anthropic API, and refreshes them in the background. If your credentials aren't OAuth-based, the plugin falls through to standard API key auth.
15 supported models. Run pnpm run test:models to verify against your account.
| Model | | -------------------------- | | claude-3-haiku-20240307 | | claude-haiku-4-5 | | claude-haiku-4-5-20251001 | | claude-opus-4-0 | | claude-opus-4-1 | | claude-opus-4-1-20250805 | | c...