Only the CLI refreshes the credential
The access token in ~/.claude/.credentials.json is renewed when Claude Code runs. Anything that reads the file without running the CLI sees an expired token and reports what it saw, which is why a model picker can go empty on a box whose login is perfectly good.
The login reached the end of its life
Claude Code warns at startup when a login is close to expiring, with Your login expires in 3 days and a prompt to run /login to renew. Once the stored login expires and cannot be refreshed, every model request fails with Login expired and Please run /login until you sign in again.
Two Claude Code windows refreshed at once
Refreshing rotates the credential, and only one process can do it at a time. Claude Code says so in its own words: Could not refresh your login because another Claude Code process is refreshing it (or exited mid-refresh), with advice to try again in a minute and close other windows if it keeps happening.
Refreshing it yourself is how a login really dies
The refresh token rotates, so a value replayed by two writers, a copied .credentials.json or a restored backup, is refused. Claude Code then reports OAuth token revoked and asks for /login. Nudging the CLI to refresh its own credential is the safe move, and doing the refresh on its behalf is the unsafe one.
/logout resets more than the login
Anthropic documents that logging out also resets your first-launch setup, so the next claude walks you through login and setup again. That is expected after a logout, not a sign that settings were lost.
An environment token keeps winning
CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN all rank above the login that /login saves. Running /login while one is set switches the current session, but every new session reads the variable again. That looks like Claude Code forgetting your login and is really the order it reads credentials in; the API key page covers it in full.
On macOS the Keychain refused the write
Claude Code keeps the login in the macOS Keychain. When the Keychain rejects the write, as it can when locked in an SSH session, Anthropic says Claude Code falls back to ~/.claude/.credentials.json. A Mac reached over ssh can therefore hold a different login from the one you see at the desk.