Registry / llm-agents / opencode-claude-code-auth

opencode-claude-code-auth

JSON →
library0.1.6jsnpmunverified

This package, `opencode-claude-code-auth`, is an OpenCode plugin designed to restore and manage Anthropic (Claude) authentication methods within the OpenCode ecosystem. It provides three distinct authentication paths: reading local Claude Code session credentials, initiating a browser-based OAuth flow, or utilizing a plain Anthropic API key. The plugin addresses the removal of built-in Anthropic authentication from OpenCode v1.3.x, ensuring continued access to Claude models for users. It is currently at version 0.1.6, indicating active development with frequent minor updates. Key differentiators include its flexible login options, token management (refreshing Claude CLI tokens or using OAuth refresh tokens), and seamless integration into OpenCode's provider system to intercept and manage all Anthropic API traffic. It targets Node.js environments version 20 or higher.

npm install opencode-claude-code-auth
INSTALL
IMPORT
SIG · OPENCODE-CLAUDE-CO
O
opencode-claude-code-auth
llm-agentsjavascriptv0.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

configurePlugin
import { configurePlugin } from 'opencode-claude-code-auth/cli';
While end-users typically interact via the `npx opencode-claude-code-auth configure` CLI, this is a hypothetical programmatic entry point for internal or advanced OpenCode-plugin development to trigger the configuration logic.
AnthropicAuthPlugin
import { AnthropicAuthPlugin } from 'opencode-claude-code-auth';
This represents the main plugin class or entry point that OpenCode's plugin system would internally instantiate. Direct programmatic import by end-user applications is not the primary use case, as interaction is usually through OpenCode's configuration and CLI.
AnthropicProvider
import type { AnthropicProvider } from 'opencode-claude-code-auth/types';
This is a type import for the internal Anthropic provider interface, useful for TypeScript developers who might be extending or understanding the plugin's internal workings within the OpenCode framework. Not for direct end-user consumption.

This quickstart demonstrates how to add the plugin to `opencode.json`, authenticate with Anthropic via the CLI, and then test model access.

{ "plugin": ["opencode-claude-code-auth"] } # Save the above JSON to your opencode.json file # Then, in your terminal: opencode auth login -p anthropic # Follow the prompts to pick a login path (Claude Code session, browser sign-in, or API key). # If OpenCode asks to configure Anthropic models, say yes. # Verify your setup: opencode run "Hello, Claude! What's new?" -m anthropic/claude-sonnet-4-5
Debug
Known issues
breakingOpenCode v1.3.x and newer versions removed built-in Anthropic authentication, making this plugin necessary to restore the functionality. Without it, direct Anthropic integration in OpenCode will fail.
fix
Ensure `opencode-claude-code-auth` is added to your `opencode.json` plugin array and you have completed the `opencode auth login -p anthropic` process.
affects: >=1.3.0 (for OpenCode), all versions (for this plugin)
gotchaThe package requires Node.js version 20 or higher. Running with older Node.js versions will result in execution errors.
fix
Upgrade your Node.js environment to version 20 or newer. Check your Node.js version with `node -v`.
affects: <0.1.0
gotchaWhen using the 'Claude Code session' login path, the plugin relies on the `claude` CLI being installed and configured to read credentials from the macOS Keychain (or `~/.claude/.credentials.json` on Linux/Windows). If the `claude` CLI is not present or its tokens are invalid, this authentication method will fail.
fix
Install the Anthropic `claude` CLI and ensure you are logged in via `claude login`. Alternatively, use the 'Browser sign-in' or 'API key' methods.
affects: all
gotchaToken refresh mechanisms differ significantly between the 'Claude Code session' and 'Browser sign-in' paths. Developers should be aware of these differences, especially in automated environments where manual intervention for refreshes is undesirable.
fix
For 'Claude Code session', ensure the `claude` CLI can be spawned. For 'Browser sign-in', ensure network access to Anthropic's OAuth endpoints for refresh token usage. API key is generally most straightforward for non-interactive use.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'opencode-claude-code-auth'
The `opencode-claude-code-auth` plugin was not correctly specified in `opencode.json` or OpenCode failed to install it automatically.
fix
Verify that `"opencode-claude-code-auth"` is present in the `plugin` array within your `opencode.json` file. Ensure OpenCode has internet access to download npm packages.
Authentication Failed: Anthropic API returned a 401 or 403 error.
Your authentication tokens (session, OAuth, or API key) have expired, are invalid, or lack the necessary permissions.
fix
Run `opencode auth login -p anthropic` again to re-authenticate and refresh your tokens. If using an API key, double-check its validity.
node: --enable-source-maps is not allowed in NODE_OPTIONS
This error typically indicates an incompatible Node.js version, especially when `NODE_OPTIONS` conflicts with internal module loading or features not present in older versions.
fix
Upgrade your Node.js environment to version 20 or higher, as required by the package. Use `nvm install 20` or your preferred Node.js version manager.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
49 hits · last 30 days
node
46
Amazon
1
OpenAI (training)
1
Resources
opencode-claude-code-auth — npm install opencode-claude-code-auth · libregistry