Skip to content

feat: add Claude CLI OAuth support for subscription accounts#249

Open
wade56754 wants to merge 2 commits intoop7418:mainfrom
wade56754:feat/cli-oauth-subscription-support
Open

feat: add Claude CLI OAuth support for subscription accounts#249
wade56754 wants to merge 2 commits intoop7418:mainfrom
wade56754:feat/cli-oauth-subscription-support

Conversation

@wade56754
Copy link

Summary

  • Add a new "Claude CLI (Subscription)" provider preset that allows Pro/Max/Team subscription users to use CodePilot without an API key
  • Leverages Claude CLI's built-in OAuth tokens stored in ~/.claude/ — users just need to run claude login first
  • New cli_oauth auth style clears all ANTHROPIC_* env vars so the Claude CLI subprocess falls back to its own OAuth flow

Problem

Currently CodePilot requires either an API key or a third-party provider configuration. Users with Anthropic Pro/Max/Team subscriptions who have already authenticated via claude login cannot use their subscription — they get "Claude Code process exited with error" because no credentials are injected.

Changes

File Change
provider-catalog.ts New cli_oauth AuthStyle + vendor preset definition
provider-resolver.ts toClaudeCodeEnv() cli_oauth branch: clears ANTHROPIC_* vars, lets CLI use own OAuth
provider-resolver.ts hasCredentials returns true for cli_oauth
provider-resolver.ts inferAuthStyleFromProvider reads __AUTH_STYLE marker from env_overrides
provider-presets.tsx New "Claude CLI (Subscription)" quick-add button (first position)
PresetConnectDialog.tsx Injects __AUTH_STYLE marker for cli-oauth preset

How it works

  1. User clicks "Claude CLI (Subscription)" in provider settings — no fields to fill, just Connect
  2. Provider record created with empty api_key, empty base_url, env_overrides_json: {"__AUTH_STYLE":"cli_oauth"}
  3. When spawning Claude Code subprocess, toClaudeCodeEnv() detects cli_oauth → clears all ANTHROPIC_* env vars
  4. Claude CLI finds no API key → uses its own OAuth tokens from ~/.claude/

Test plan

  • npm run typecheck — passes
  • npm run test:unit — 374 tests pass, 0 fail (including 82 provider-resolver tests)
  • Manual test: select "Claude CLI (Subscription)", verify Claude Code uses OAuth auth
  • Manual test: switch between CLI OAuth and API key providers, verify no credential leaks

🤖 Generated with Claude Code

…/Team)

Users with Anthropic Pro/Max/Team subscriptions can now use CodePilot
without an API key by selecting the new "Claude CLI (Subscription)" provider.
This leverages Claude CLI's built-in OAuth tokens stored in ~/.claude/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 11, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

- Reorder Claude CLI candidate paths: user directories (~/.npm-global,
  ~/.bun) now take priority over system paths (/usr/local/bin) to avoid
  picking up stale system-wide installations
- Add instrumentation.ts with undici EnvHttpProxyAgent so server-side
  fetch calls (Telegram Bridge, etc.) respect HTTP_PROXY env vars

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant