Summary
Request native configuration option to prefer subscription auth over environment API key, eliminating the need for env -u ANTHROPIC_API_KEY workaround.
Current Behavior
When ANTHROPIC_API_KEY is set in the environment, Claude Code CLI uses it for authentication instead of the subscription-based OAuth flow.
Problem scenario:
- User has API key set for other tools (Python scripts, direct API calls)
- User wants Claude Code to use their Claude subscription auth
- No native way to tell Claude Code to ignore the env API key
Current workaround:
alias claude='env -u ANTHROPIC_API_KEY /opt/homebrew/bin/claude'
This works but is non-obvious and requires shell knowledge.
Requested Behavior
Add configuration option to prefer subscription auth even when API key is present.
Option A: Config file setting
// ~/.claude/settings.json
{
"auth": {
"prefer_subscription": true
}
}
Option B: CLI flag
claude --prefer-subscription "query"
Option C: Environment variable
export CLAUDE_CODE_PREFER_SUBSCRIPTION=true
Rationale
- Common use case: Power users often have API keys for multiple purposes
- Subscription benefits: Better rate limits, included in plan, no separate billing
- Discoverability: Native config is more discoverable than
env -u trick
Acceptance Criteria
Summary
Request native configuration option to prefer subscription auth over environment API key, eliminating the need for
env -u ANTHROPIC_API_KEYworkaround.Current Behavior
When
ANTHROPIC_API_KEYis set in the environment, Claude Code CLI uses it for authentication instead of the subscription-based OAuth flow.Problem scenario:
Current workaround:
This works but is non-obvious and requires shell knowledge.
Requested Behavior
Add configuration option to prefer subscription auth even when API key is present.
Option A: Config file setting
Option B: CLI flag
claude --prefer-subscription "query"Option C: Environment variable
export CLAUDE_CODE_PREFER_SUBSCRIPTION=trueRationale
env -utrickAcceptance Criteria