npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@suiramdev/opencode-anthropic-auth

v2.1.0

Published

> [!WARNING] > This plugin comes with no guarantees. You might be banned for breaking the TOS, you might not be. I don't work at Anthropic, nor am I an attorney. > > Use your best judgment and don't try to abuse the subscriptions. Plugins like oh-my-opena

Readme

OpenCode Anthropic Auth Plugin

[!WARNING] This plugin comes with no guarantees. You might be banned for breaking the TOS, you might not be. I don't work at Anthropic, nor am I an attorney.

Use your best judgment and don't try to abuse the subscriptions. Plugins like oh-my-openagent are known to trigger bans. Please be careful when using Ralph loops or insanely heavy usage patterns.

[!IMPORTANT] If you are seeing issues, please try to rm -rf ~/.cache/opencode/packages/@suiramdev and check your opencode.json config to make sure you're on the latest version.

Try this FIRST before making an Issue. Thanks!

An OpenCode plugin that provides Anthropic OAuth authentication, enabling Claude Pro/Max users to use their subscription directly with OpenCode.

[!IMPORTANT] This is a fork of @ex-machina/opencode-anthropic-auth targeting OpenCode v2; it will not load on v1. The v1 plugin API (auth.loader returning a custom fetch) was removed in v2 — see Porting notes. For OpenCode v1, use the upstream package.

Usage

Add the plugin to your OpenCode configuration:

{
  "plugins": ["@suiramdev/opencode-anthropic-auth"]
}

Then connect an account with opencode auth login and pick Claude Pro/Max.

[!TIP] It is STRONGLY advised that you pin the plugin to a version. This will keep you from getting automatic updates; however, this will protect you from nefarious updates.

This holds true for ANY OpenCode plugin. If you do not pin them, OpenCode will automatically update them on startup. It's a massive vulnerability waiting to happen.

Example of pinned version

{
  "plugins": ["@suiramdev/[email protected]"]
}

The plugin's id is suiramdev.anthropic-auth; disable it without removing the entry using "-suiramdev.anthropic-auth".

Authentication Methods

The plugin adds two OAuth methods to OpenCode's built-in anthropic integration:

  • Claude Pro/Max — OAuth flow via claude.ai for Pro/Max subscribers. Uses your existing subscription at no additional API cost.
  • Create an API Key — OAuth flow via console.anthropic.com that creates an API key on your behalf.

OpenCode already ships Manually enter API Key for the anthropic integration, so the plugin no longer registers its own.

Configuration

The plugin supports the following environment variables:

| Variable | Description | |----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ANTHROPIC_BASE_URL | Override the API origin (e.g. for proxying). Must be a valid HTTP(S) URL; only the origin is used, the /v1 prefix is preserved. | | ANTHROPIC_INSECURE | Set to 1 or true to skip TLS certificate verification. Only effective when ANTHROPIC_BASE_URL is also set. Applies process-wide — see the warning below. |

[!WARNING] On v2 the request goes through OpenCode's Effect HTTP client, which offers no per-request TLS control. ANTHROPIC_INSECURE therefore sets NODE_TLS_REJECT_UNAUTHORIZED=0 for the whole OpenCode process, not just Anthropic traffic. Use it only against a local proxy you control.

How It Works

For Claude Pro/Max authentication, the plugin:

  1. Registers an OAuth method on OpenCode's anthropic integration and runs a PKCE flow against Anthropic's authorization endpoint
  2. Exchanges the authorization code for access and refresh tokens, tagged with an auth-mode marker in the credential metadata
  3. Lets OpenCode refresh expired tokens through the method's refresh callback
  4. Repoints the anthropic provider at the plugin's own native provider package
  5. Injects the required OAuth headers and beta flags into API requests
  6. Sanitizes the system prompt for compatibility (see below)
  7. Renames tools to Claude Code's mcp_+PascalCase convention on the way out and back on the way in
  8. Zeros out model costs (since usage is covered by the subscription)

System Prompt Sanitization

The Anthropic API for Max subscriptions has specific requirements for the system prompt to identify as Claude Code. The plugin rewrites the system prompt on each request using an anchor-based approach that minimizes what gets changed:

  1. Identity swap — The OpenCode identity line is removed and replaced with the Claude Code identity.
  2. Paragraph removal by anchor — Any paragraph containing a known URL anchor (e.g. github.com/anomalyco/opencode, opencode.ai/docs) is removed entirely. This is resilient to upstream rewording — as long as the anchor URL appears somewhere in the paragraph, the removal works regardless of surrounding text changes.
  3. Inline text replacements — Short branded strings inside paragraphs we want to keep are replaced (e.g. "OpenCode" → "the assistant" in the professional objectivity section).

Everything else in the system prompt is preserved: tone/style guidance, task management instructions, tool usage policy, environment info, skills, user/project instructions, and file paths containing "opencode". The sanitized system prompt is structured as three blocks in system[]: the billing header, the Claude Code identity line, and the remaining system content.

Porting notes

OpenCode v2 removed the auth plugin surface this project was built on. The v2 equivalents:

| v1 | v2 | |----|----| | auth.methods | ctx.integration.transformmethod.update({ authorize, refresh }) | | Manual token refresh with an inflight-promise guard | OpenCode's own refresh scheduling, via the method's refresh callback | | auth.loader zeroing provider.models[].cost | ctx.catalog.transform | | auth.loader returning a wrapped fetch | A plugin-owned native provider package (src/provider.ts) |

The last row is the interesting one. In v2 the anthropic provider is served by OpenCode's own AnthropicMessages route rather than the Vercel AI SDK, and the plugin API exposes no response-side hook — session.request can mutate an outbound request but nothing can touch the response stream. Prefixing tool names on the way out without un-prefixing them on the way back makes every tool call fail with Unknown tool.

So the plugin points the provider's package at dist/provider.js (a file:// specifier, which OpenCode imports directly). That module rebuilds the stock Anthropic route with one wrapped transport: outbound requests get the Claude Code headers, URL, and body treatment, and inbound SSE frames get the tool prefix stripped back off. src/tests/integration.test.ts drives a real LLM.stream through that stack against a local server to catch breaking changes in those (beta, unstable) internals.

Because that package builds on OpenCode's own runtime, @opencode-ai/ai, @opencode-ai/plugin, @opencode-ai/schema, and effect are pinned to exact versions matching one OpenCode next build. Bump all four together when retargeting a newer OpenCode, and re-run bun test — the integration test is what tells you whether the internals still line up.

Development

Local Testing

Use bun run dev to test plugin changes locally without publishing to npm:

bun run dev

This does three things:

  1. Builds the plugin
  2. Symlinks dist/ into .opencode/plugins/anthropic-auth so OpenCode loads it as a local plugin package. The whole directory is linked, not just index.js, because the plugin resolves provider.js relative to its own module URL.
  3. Starts tsc --watch for automatic rebuilds on source changes

After starting the dev script, restart OpenCode in this project directory to pick up the local build. Any edits to src/ will trigger a rebuild — restart OpenCode again to load the new version.

Ctrl+C stops the watcher and cleans up the symlink. If the process was killed without cleanup (e.g. kill -9), you can manually remove the symlink:

bun run dev:clean

[!NOTE] If you also have the published package in your global OpenCode config, both will load. Disable the published one with "-suiramdev.anthropic-auth" — the two share an id, so the later entry wins.

Publishing

This project uses changesets for versioning and publishing. See the changeset README for more details.

bun change          # create a changeset describing your changes

When changesets are merged to main, CI will automatically open a release PR. Merging that PR publishes to npm.

Registry auth

.github/workflows/publish.yml publishes with provenance and reads NODE_AUTH_TOKEN from the NPM_TOKEN secret. Leave that secret unset to publish via npm trusted publishing (OIDC) instead — the workflow already requests id-token: write.

Trusted publishing cannot bootstrap a package that does not exist yet, so the first version of a newly named package must be published from a machine with npm login credentials:

npm login
bun run release     # build + changeset publish

Afterwards, register suiramdev/opencode-anthropic-auth / publish.yml (no environment) as the package's trusted publisher on npmjs.com, and every later release goes through CI with no long-lived token.

License

MIT