[BUG] Anthropic CLI Overwrites and Pins Claude Code Credentials
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code can become "stuck" using API Usage Billing even when the user has an active Claude Pro subscription. This occurs because Claude Code shares the ~/.config/anthropic configuration directory with the Anthropic CLI.
If the Anthropic CLI has created a configuration file at ~/.config/anthropic/configs/default.json with a hardcoded organization_id (e.g., from an "Individual Org" used during testing), Claude Code will honor that pinned organization ID. Crucially, running claude auth login or claude auth logout does not always clear or update this pinned organization_id, leading to a state where the user is logged in with the correct email but routed to the wrong organization/billing path.
In my case, I briefly installed the CLI to try using it for a script, and that alone borked my Claude Code installation in a way that logging in and out could not fix.
What Should Happen?
- Clearer Auth Logic:
claude auth loginshould explicitly prompt for organization selection if multiple organizations are detected, or it should automatically prioritize organizations with an active Claude Pro subscription. - Config Overwrite: Running
claude auth login --claudeaishould overwrite or clear any hardcodedorganization_idin~/.config/anthropic/configs/default.jsonthat conflicts with the subscription-capable organization.
Error Messages/Logs
- Debug Logs: `[ERROR] API error (attempt 1/11): Access token at ~/.config/anthropic/credentials/default.json` has expired and no refresh is available (even after attempting to re-login).
- UI Banner: Shows "API Usage Billing · [Org Name]" despite the user being logged into an account with a Pro subscription.
- Auth Status: `Profile: credentials-file · user_oauth · profile default` (does not indicate that the organization is being overridden by a local config file).
Steps to Reproduce
- Install the Anthropic CLI (I used the recommended native install) and log into a "Default/Individual" organization that does not have a Pro subscription.
- Verify that
~/.config/anthropic/configs/default.jsonnow contains a hardcodedorganization_id. - Open Claude Code and observe that it uses the pinned organization and defaults to API Usage Billing.
- Attempt to fix by running
claude auth logoutandclaude auth login. - Observe that even after a successful login, the
~/.config/anthropic/configs/default.jsonfile remains pinned to the old organization ID, keeping the user stuck on API billing. - (Fix requires manually deleting
~/.config/anthropic/configs/default.json).
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.145 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗