Feature request: Option to prefer subscription auth over ANTHROPIC_API_KEY
Resolved 💬 4 comments Opened Dec 2, 2025 by gmelli Closed Feb 6, 2026
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 -utrick
Acceptance Criteria
- [ ] User can configure Claude Code to prefer subscription auth
- [ ] Configuration persists across sessions
- [ ] Works regardless of ANTHROPIC_API_KEY being set
- [ ] Documentation updated to explain auth precedence
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗