These instructions are designed for AI coding agents.
Before installing, verify you have OpenCode and Claude Code installed and authenticated.
opencode --versionYou should see a version number (e.g., 1.2.28).
security find-generic-password -s "Claude Code-credentials" -wIf this returns credentials, you're authenticated. If it fails or returns nothing, try the fallback:
cat ~/.claude/.credentials.jsonIf this file exists and contains valid JSON, you're authenticated.
Run Claude Code to authenticate:
claudeThis will prompt you to log in and store credentials in Keychain (macOS) or ~/.claude/.credentials.json (other platforms).
npm install -g opencode-claude-authRun this command to automatically add the plugin to your opencode.json:
node -e "
const fs = require('fs'), p = require('path').join(require('os').homedir(), '.config/opencode/opencode.json');
const c = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p,'utf8')) : {};
c.plugin = [...new Set([...(Array.isArray(c.plugin) ? c.plugin : []), 'opencode-claude-auth'])];
fs.mkdirSync(require('path').dirname(p), {recursive:true});
fs.writeFileSync(p, JSON.stringify(c, null, 2));
console.log('Added opencode-claude-auth to', p);
"This command:
- Reads your existing
opencode.json(or creates a new one) - Adds
opencode-claude-authto thepluginarray - Deduplicates plugins using a Set
- Writes the updated config back
Verify the plugin was added:
cat ~/.config/opencode/opencode.jsonYou should see opencode-claude-auth in the plugin array:
{
"plugin": ["opencode-claude-auth"]
}The plugin is now installed and configured. When you run OpenCode, it will automatically use your Claude Code credentials — no separate login needed.
If you encounter issues, see the main README troubleshooting section.