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

@xtruder/opencode-claude-max-plugin

v0.2.9

Published

OpenCode plugin for Claude Max/Pro subscription via @anthropic-ai/sdk - uses Claude Code OAuth credentials

Downloads

137

Readme

@xtruder/opencode-claude-max-plugin

An OpenCode plugin that enables Claude Pro/Max subscription access via the official @anthropic-ai/sdk, using OAuth credentials from Claude Code (~/.claude/.credentials.json).

Usage sidebar and /usage command dialog

Why?

  • Use your Claude subscription — Automatically reads OAuth credentials from Claude Code, no separate API key needed
  • Matches Claude Code exactly — Same headers, billing, tool names, and request format as Claude Code CLI
  • Prompt caching — 98% of input tokens served from cache (system prompt + tools cached globally)
  • All Claude models — Opus 4.6, Sonnet 4.6, Haiku 4.5
  • Extended thinking — Full reasoning support with thinking variants (high/max)
  • Usage tracking — Sidebar widget with live progress bars + /usage command with full details
  • Self-registering — Models are registered automatically, no manual provider config needed

Installation

Add the plugin to your opencode.json (project-level or ~/.config/opencode/opencode.json globally):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@xtruder/opencode-claude-max-plugin"]
}

That's it. The plugin self-registers the anthropic-sdk provider and its models (Haiku 4.5, Sonnet 4.6, Opus 4.6) at startup via the OpenCode config hook. No separate provider block is needed.

In OpenCode, the plugin also replaces the default base system prompt with a Claude-compatible one via experimental.chat.system.transform. This is required for Claude Code OAuth requests to be treated as Claude-native rather than third-party app requests.

Then open OpenCode and run /connect → Other → anthropic-sdk. If Claude Code is installed and you're logged in, credentials are read automatically from ~/.claude/.credentials.json — no API key needed.

TUI Plugin (sidebar + /usage command)

The plugin includes a TUI component that shows subscription usage in the sidebar and registers a /usage slash command. To enable it, add the plugin to your tui.json as well:

Project-level (.opencode/tui.json):

{
  "plugin": ["@xtruder/opencode-claude-max-plugin"]
}

Or globally (~/.config/opencode/tui.json):

{
  "plugin": ["@xtruder/opencode-claude-max-plugin"]
}

The TUI plugin provides:

  • Sidebar widget — Compact progress bars for 5-hour session and 7-day weekly usage
  • /usage command — Opens a dialog with full usage breakdown (per-model, extra usage)
  • Auto-refresh — Polls the usage API every 60s and after each inference call

TUI Configuration

Options can be set in the tui.json plugin entry:

{
  "plugin": [
    [
      "@xtruder/opencode-claude-max-plugin",
      {
        "enabled": true,
        "sidebar": true,
        "poll_interval": 60
      }
    ]
  ]
}

| Option | Type | Default | Description | | --------------- | ------- | ------- | ----------------------------------------- | | enabled | boolean | true | Enable/disable the TUI plugin entirely | | sidebar | boolean | true | Show/hide sidebar usage widget | | poll_interval | number | 60 | Seconds between usage API polls (min: 10) |

Custom model options

If you want to override model settings (e.g. thinking budgets, variants), you can add a provider block alongside the plugin:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@xtruder/opencode-claude-max-plugin"],
  "provider": {
    "anthropic-sdk": {
      "models": {
        "claude-sonnet-4-6": {
          "options": {
            "thinking": { "type": "enabled", "budgetTokens": 1024 }
          },
          "variants": {
            "high": { "thinking": { "type": "enabled", "budgetTokens": 10000 } },
            "max": { "thinking": { "type": "enabled", "budgetTokens": 32000 } }
          }
        }
      }
    }
  }
}

Config-level settings are merged with plugin defaults — you only need to specify what you want to override.

Authentication

Credentials are resolved in order:

  1. ANTHROPIC_API_KEY env var or apiKey provider option
  2. Claude Code credentials — auto-read from ~/.claude/.credentials.json

For Claude Code credentials, log in via claude CLI first (claude auth login).

Features

  • Streaming and non-streaming completions
  • Tool/function calling with Claude Code tool name mapping (taskAgent, etc.)
  • MCP tool name remapping (server_toolmcp__server__tool)
  • Extended thinking with signature passthrough for multi-turn conversations
  • Prompt caching (98% cache hit rate with full OpenCode tool set)
  • CCH request signing — computes xxHash64 body integrity hash to unlock features like fast mode
  • Subscription rate limit detection — fails fast with clear message instead of hanging
  • Long context auto-detection — adds context-1m beta header when request body is large
  • TUI sidebar with live usage bars + /usage slash command with full subscription details

With Vercel AI SDK

The plugin also works as a standalone Vercel AI SDK provider:

import { CLAUDE_CODE_SYSTEM_PROMPT, createAnthropicSDK } from "@xtruder/opencode-claude-max-plugin"
import { streamText } from "ai"

// Uses ~/.claude/.credentials.json automatically
const provider = createAnthropicSDK()
const model = provider.languageModel("claude-sonnet-4-6")

const result = streamText({
  model,
  system: CLAUDE_CODE_SYSTEM_PROMPT,
  prompt: "Hello!",
})
for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}

When using Claude Code OAuth credentials outside OpenCode, you must pass a Claude-compatible system prompt yourself. Exported CLAUDE_CODE_SYSTEM_PROMPT is the prompt used by the OpenCode plugin hook.

Development

bun install
bun run build
bun run test    # integration tests (requires ANTHROPIC_API_KEY or Claude Code credentials)

See RESEARCH.md for detailed reverse-engineering findings on how we matched Claude Code's request format.

License

MIT