OpenCode plugin that uses your existing Claude Code credentials — no separate login needed.
Claude Code stores OAuth tokens in the macOS Keychain (or ~/.claude/.credentials.json on other platforms). This plugin reads those tokens and writes them to OpenCode's ~/.local/share/opencode/auth.json (on Windows, it writes to both %USERPROFILE%\.local\share\opencode\auth.json and %LOCALAPPDATA%\opencode\auth.json to cover all installation methods), so you don't need to log in twice. It re-syncs every 5 minutes to pick up token refreshes. If a token is near expiry, it runs the Claude CLI to trigger a refresh.
claude at least once)macOS is preferred (uses Keychain). Linux and Windows work via the credentials file fallback.
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.
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 syncs your Claude Code credentials to OpenCode's auth.json and refreshes them in the background.
The plugin checks these in order:
~/.claude/.credentials.json (fallback, works on all platforms)| Problem | Solution |
|---|---|
| "Credentials not found" | Run claude to authenticate with Claude Code first |
| "Keychain is locked" | Run security unlock-keychain ~/Library/Keychains/login.keychain-db |
| "Token expired and refresh failed" | The plugin runs claude CLI to refresh automatically. If this fails, re-authenticate manually by running claude |
| Not working on Linux/Windows | Ensure ~/.claude/.credentials.json exists. Run claude to create it |
| Keychain access denied | Grant access when macOS prompts you |
| Keychain read timed out | Restart Keychain Access (can happen on macOS Tahoe) |
Claude Code-credentials entry) or ~/.claude/.credentials.json fallbackanthropic entry to ~/.local/share/opencode/auth.json (on Windows, writes to both %USERPROFILE%\.local\share\opencode\auth.json and %LOCALAPPDATA%\opencode\auth.json) in OpenCode's native OAuth formatclaude CLI to trigger a refreshMIT