[BUG] /login for OAuth clobbers existing API key authentication
Description
Running /login to authenticate with a claude.ai account (required for /schedule) overrides an existing, working ANTHROPIC_API_KEY session — not just in the current terminal, but across all running Claude Code instances. Every open session switches from API key auth to OAuth, effectively logging the user out everywhere.
Steps to reproduce
- Have multiple Claude Code sessions running, all authenticated via
ANTHROPIC_API_KEY - Run
/loginin any one session to authenticate with a claude.ai account (needed for/schedule) - OAuth login succeeds
- All Claude Code instances lose API key auth and switch to OAuth — not just the session where
/loginwas run
Expected behavior
/login should add OAuth credentials alongside the existing API key auth, not replace it. At minimum, it should only affect the session where /login was run, not globally clobber auth across all instances.
Workarounds
None currently — /login is destructive to all running sessions. Restarting the shell restores API key auth from the environment, but any in-progress work in other sessions is disrupted.
Environment
- macOS (Darwin 24.6.0)
- Auth method:
ANTHROPIC_API_KEYenvironment variable
Related
- #25069 — macOS keychain/OAuth logic preempting
ANTHROPIC_API_KEY
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗