Claude still asks to log in after configuration - Claude Code
Quick fix
Add hasCompletedOnboarding: true to ~/.claude.json to skip the login prompt.
Symptom
Section titled “Symptom”配置好 setting.json 文件之后,Claude任然要求登录?怎么办?After configuring the setting.json file, Claude still asks me to log in. What should I do?
On a fresh install or first use, Claude Code enforces the onboarding (guided login) flow. The env settings that cc-switch writes into ~/.claude/settings.json (such as ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN) do take effect, but Claude Code still intercepts and prompts for login when it detects onboarding is incomplete. Configuration in settings.json cannot bypass this check; you must set hasCompletedOnboarding: true in ~/.claude.json to skip the login screen. Additionally, some users hit cases where use custom Api key under /config was mistakenly set to false (routing through the official subscription instead of the API channel), or where read in permissions.ask in settings.json was written in lowercase, which also cause login problems. Issue #1688 covers another variant: after switching back to the official subscription, API Usage Billing is still shown because leftover ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN in the system environment variables override the config file written by cc-switch.
Check or create the ~/.claude.json file and make sure it contains the hasCompletedOnboarding: true field. If the file does not exist, create a minimal file directly.
// ~/.claude.json{"hasCompletedOnboarding": true}If ~/.claude.json already exists and contains other content, use a Python script to safely add the field without breaking the existing content: python3 -c "import json,pathlib; p=pathlib.Path.home()/'.claude.json'; data=json.loads(p.read_text()) if p.exists() else {}; data['hasCompletedOnboarding']=True; p.write_text(json.dumps(data,ensure_ascii=False))"
Reopen the terminal and run claude. If it still shows Not logged in, please run /login, enter /config in Claude Code, check whether the last item use custom Api key is true, and change it to true if it is false.
If none of the above works, check the value of permissions.ask in ~/.claude/settings.json and change lowercase read to Read with a capital first letter.
// ~/.claude/settings.json"permissions": {"ask": ["Read"]}If API Usage Billing still shows after switching back to the official subscription, check whether ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are left over in the system environment variables, clear them manually, and reopen the terminal. Linux/macOS: unset ANTHROPIC_BASE_URL; unset ANTHROPIC_AUTH_TOKEN. Windows cmd: setx ANTHROPIC_BASE_URL "". Windows PowerShell: Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- Does setting hasCompletedOnboarding: true in the cc-switch provider editor work?
- No. Setting this field in the cc-switch provider editor does not write it to ~/.claude.json. You must add hasCompletedOnboarding: true directly in the ~/.claude.json file to skip login.
- What is the principle behind setting use custom Api key to true?
- When true, traffic goes through the API channel (the cc-switch proxy); when false, it goes through the official subscription. If it is mistakenly set to false, Claude Code tries to log in via the official subscription instead of the third-party API.
- Why does API Usage Billing still show after switching back to the official subscription?
- Leftover ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY in the system environment variables may be overriding the config file written by cc-switch. Manually unset these environment variables and reopen the terminal. cc-switch itself only writes config files, not environment variables; leftover environment variables usually come from other software.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.