GeezerVison is showing github.com — Support Claude subscription usage through OpenCode's Claude Code integration · Issue #53 · martinvidovic/opencode-limits
Support Claude subscription usage through OpenCode's Claude Code integration #53DescriptionGoal
Add Claude subscription usage to the native /limits popup through a new in-repository Provider Adapter, including Claude Pro (the reported $20/month plan). This is subscription usage, not Anthropic API-key billing.
Context
The maintainer reports that Claude subscriptions are available again in OpenCode, but through a different integration path. A screenshot supplied on 2026-10-31 shows an OpenCode announcement saying “you can now use your claude subscription in OpenCode.” Commentary in that screenshot describes use of the official Claude SDK with model requests handled by Claude Code itself, rather than the previous direct OAuth approach. These implementation details have not yet been independently verified.
We intend to support this connection mode in opencode-limits. Do not assume the previous Anthropic OAuth credential flow or integration identifier still applies.
Investigation required
- Verify the current OpenCode v2 Claude Code integration, its integration ID, supported versions, and how an active subscription account is exposed to plugins.
- Determine whether supported host APIs expose the credentials or usage capabilities needed for quota retrieval. Identify the usage source, fixed endpoint origins (if applicable), request stages, and limitations.
- Establish which subscription Quota Meters, reset times, and optional Display-only Account Context are actually available. Do not infer quotas from the subscription price or manufacture unavailable values.
- Document any gap in the host API that blocks implementation. Do not work around it by reading Claude Code/OpenCode credential files, keychains, or databases, or by managing credential refresh ourselves.
Acceptance criteria
- Confirm the integration and credential/usage access contract, and record findings and any blockers here.
- Add a Provider Adapter that follows the active Claude subscription account and returns a normalized Usage Snapshot with the available quota windows and reset times.
- Omit disconnected accounts; handle unsupported account modes, unavailable usage, expired authentication, rate limits, and network failures through the shared bounded Provider Failure taxonomy.
- Keep credentials server-side, preserve host-owned authentication/refresh, use SafeRequester for HTTP requests, and isolate failures from other providers.
- Add synthetic tests covering discovery, supported/unsupported connections, normalization, failure handling, cancellation, and secret redaction.
- Update supported-provider documentation and the changelog, run
npm run check, and record sanitized text-only live validation against a Claude Pro subscription before declaring support complete.
Scope
Usage visibility in opencode-limits only. No changes to OpenCode model execution, Claude Code tool bridging, authentication bypasses, or Anthropic API-key billing.
Follow docs/provider-adapters.md. The new integration and usage-access contract still need investigation; this issue is not yet an implementation-ready specification. Activitymartinvidovic commented on Nov 2, 2026 Investigation findings (2026-11-02)
Status: blocked; no adapter or live validation yet.
- OpenCode calls this integration Claude Agent, ID
claude-agent, with external method claude-login. It runs the user’s installed Claude Code via the Claude Agent SDK; the connection only records the choice, and OpenCode never sees the login token. The same integration also supports API keys and cloud logins, so its presence alone does not establish a subscription. Integration implementation, provider specification.
- The provider was introduced in #58782; its merge commit is contained in release v2.2.3 but not v2.2.2. The V2 Claude Agent guide requires local Claude Code 2.1.248 or later and says the integration is unavailable in remote workspaces.
- The documented server plugin API exposes active connections and credential resolution, but no Claude subscription usage capability. Upstream explicitly lists Claude plan
/usage as unsupported; HTTP hooks do not run because Claude Code makes its requests. The SDK probe provides account and model info, and OpenCode records per-response token usage, neither of which establishes quota windows or resets. See probe and usage accounting.
- No supported usage endpoint, request stages, available quota meters, reset times, or display-only account context have been established for this integration. We cannot safely normalize or validate them. The Anthropic Agent SDK overview also states that third-party products need prior approval to offer claude.ai login or rate limits; approval for this project is not established.
Unblock: obtain an approved, documented host/SDK usage capability that identifies the active subscription and exposes its quota and reset data, including failure and cancellation semantics. Then specify the adapter and complete synthetic tests, npm run check, and sanitized Claude Pro live validation. Do not read credential stores, manage refresh, infer quotas from plan price, or treat API-key billing as subscription usage. martinvidovic commented on Nov 12, 2026 Additional findings (2026-11-12)
Status: still blocked. Local inspection of OpenCode 2.2.5 and Claude Code 2.1.309 confirms the earlier findings and adds the following.
Host side
- The integration ships inside OpenCode as the built-in plugin
opencode.provider.claude-agent (not a separately installed plugin). It registers method claude-login with type: "external".
- A connected
claude-agent credential contains only { type: "external", methodID: "claude-login" }. There is no token, expiry, or account metadata.
- In
@opencode/plugin 2.0.18, integration.connection.resolve() returns Credential.Value, which covers only oauth | key. resolveOAuthConnection therefore can never succeed for this integration. With the current contract, the most a reader can do is detect an active connection and return unsupported-auth.
- The integration status probe uses the Agent SDK's
initializationResult().account (tokenSource, apiKeySource) only to set needs_auth. Plugins cannot access it.
Usage source (identified, not usable under current rules)
- Claude Code's own
/usage reads GET https://api.anthropic.com/api/oauth/usage with the Claude Code OAuth token. The response has the windows five_hour, seven_day, seven_day_opus, seven_day_sonnet (each with a utilization percentage and resets_at) plus extra_usage. Claude Code also calls /api/oauth/profile for account and plan context. These map directly to Quota Meters and Display-only Account Context.
- The token lives only in Claude Code's credential store: the macOS Keychain item
Claude Code-credentials, or $CLAUDE_CONFIG_DIR/~/.claude/.credentials.json elsewhere. Reaching it would mean reading a credential store, which this issue rules out. These endpoints are also undocumented.
Potential host capability
- The Agent SDK bundled in OpenCode (
@anthropic-ai/claude-agent-sdk 0.3.301) has a get_usage control request, exposed as query.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET(). Claude Code would make the request with its own credentials, so no token leaves Claude Code. That matches the shape this issue needs.
- OpenCode does not expose this to plugins. The SDK marks it experimental and unstable. Its response shape, failure semantics, and cost (it needs a live Claude Code process) are not established.
Updated unblock path
- Ask upstream OpenCode for a usage capability on the
claude-agent integration, for example through the get_usage control once it is stable, with documented response, failure, and cancellation semantics.
- Then specify the adapter around that capability. It would need either a widened reader contract (a provider-scoped usage capability instead of
connection.resolve()) or a host-provided credential. Either option needs an ADR and an update to docs/provider-adapters.md.
The Anthropic approval question noted earlier is still open.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|