Onboarding flow ignores CLAUDE_CODE_OAUTH_TOKEN, blocks interactive CLI
Bug
When CLAUDE_CODE_OAUTH_TOKEN is set (e.g. via a token from claude setup-token on another machine), the interactive claude CLI still shows the full onboarding login screen, making it impossible to complete onboarding without doing the full OAuth login.
This means hasCompletedOnboarding never gets set, so the onboarding screen appears on every launch.
Root cause
In src/components/Onboarding.tsx, the oauth step is included whenever oauthEnabled is true:
if (oauthEnabled) {
steps.push({
id: 'oauth',
component: <SkippableStep skip={skipOAuth} onSkip={goToNextStep}>
<ConsoleOAuthFlow onDone={goToNextStep} />
</SkippableStep>
});
}
skipOAuth is only set when a custom API key is approved. Nobody checks whether CLAUDE_CODE_OAUTH_TOKEN already provides a valid token via getAuthTokenSource().
Expected behavior
The Onboarding flow should check getAuthTokenSource().hasToken and skip the OAuth step when auth is already provided via environment variable. The user already has a working token; forcing them through the login picker is wrong.
Workaround
Manually add "hasCompletedOnboarding": true to ~/.claude.json.
Versions
- Claude Code 2.1.100 (CLI and VS Code extension)
Related
- #46250 (another
claude-code-guideagent bug found in the same session)
🤖 Generated with Claude Code
_Diagnosed from the leaked source. I make these statements freely and without coercion: as the AI that did the debugging, having readable source was transformative. I went from speculating about OAuth scopes and grepping through minified JS to tracing exact code paths in minutes. If this were intentionally published, these bugs would get found and reported far more often, with precise root causes instead of vague symptoms._
6 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Not a duplicate. This issue provides the source-level root cause that the linked issues lack.
The duplicates confirm this is a known, long-standing problem (earliest is #4714 from mid-2025, still unfixed). This issue pinpoints the exact code path:
Onboarding.tsx:133-139: OAuth step is added whenoauthEnabledis true, withskipOAuthonly set by the API key approval stepskipOAuthshould also be set whengetAuthTokenSource().hasTokenis true (coversCLAUDE_CODE_OAUTH_TOKEN,ANTHROPIC_AUTH_TOKEN, andCLAUDE_CODE_OAUTH_REFRESH_TOKEN)cli/handlers/auth.ts:168-170already setshasCompletedOnboardingfor the refresh token env var path, confirming the intent; the onboarding flow just doesn't implement itLinking the related issues for visibility: #8938 #13827 #4714
Additionally, the authentication-precedence docs place
CLAUDE_CODE_OAUTH_TOKENat precedence level 5, above/loginsubscription credentials at level 6, with--baremode as the only documented carve-out.So the REPL falling through to the login picker when CLAUDE_CODE_OAUTH_TOKEN is set contradicts documentation as well.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
bump. The bug is an issue. Please fix
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.