[BUG] VS Code extension overwrites ~/.claude.json, forcing CLI onboarding on every launch
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?
What's Wrong?
The VS Code extension (anthropic.claude-code) continuously overwrites ~/.claude.json while running, stripping fields like hasCompletedOnboarding, lastOnboardingVersion, projects (including hasTrustDialogAccepted), and installMethod. This forces the CLI to show the full onboarding flow (theme picker, trust dialog) every time it's launched from a VS Code terminal.
The extension rewrites ~/.claude.json on every tool use (updating toolUsage counts), but the rewrite strips fields that the CLI wrote. The userID changes on each rewrite, suggesting the extension creates a fresh config object rather than merging. firstStartTime resets repeatedly (observed 4 resets in a single session). The CLAUDECODE=1 environment variable injected by the extension also blocks CLI launches entirely.
This is a regression — running the extension and CLI side by side in VS Code previously worked without issues.
What Should Happen?
- The extension should merge into
~/.claude.jsonrather than overwriting it, preserving fields written by the CLI - Or: the extension and CLI should use separate config storage so they don't conflict
- The
CLAUDECODE=1env var should not be injected into user-opened terminals (only into extension-managed terminals)
Error Messages/Logs
When trying to launch CLI from VS Code terminal:
Error: Claude Code cannot be launched inside another Claude Code session.
Nested sessions share runtime resources and will crash all active sessions.
To bypass this check, unset the CLAUDECODE environment variable.
After clearing `CLAUDECODE`, full onboarding is shown instead of the normal CLI prompt.
During debugging, `~/.claude.json` was fully reset at least 4 times:
- `firstStartTime` changed from `12:15:48Z` → `14:30:34Z` → `15:19:35Z` (all same day)
- `userID` changed 3 times (3 distinct hashes)
- Fields like `hasCompletedOnboarding`, `projects`, `installMethod` were present after manual edit, then gone seconds later
Steps to Reproduce
- Open VS Code with the
anthropic.claude-codeextension installed and active - Open a PowerShell terminal inside VS Code
- Clear the CLAUDECODE env var:
Remove-Item Env:\CLAUDECODE - Run
claude - Complete the onboarding (theme, trust dialog, login)
- Verify
~/.claude.jsoncontains"hasCompletedOnboarding": true - Wait a few seconds — the extension overwrites the file, losing those fields
- Open another terminal tab, run
claudeagain → full onboarding shown again
Note: The bug also happens with Python files containing CLI scripts.
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.59
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
- Workarounds attempted (none effective): manually setting
hasTrustDialogAccepted: truevia sed (overwritten within seconds), addinghasCompletedOnboarding: true(overwritten), PowerShell profile wrapper to fix config before each launch (overwritten between write and CLI read),CLAUDE_CONFIG_DIRpointing CLI to separate directory (did not help) - Only effective workaround: uninstall the extension entirely and use CLI only
- The v2.1.59 changelog mentions "Fixed config file corruption that could wipe authentication when multiple Claude Code instances ran simultaneously" — this fix does not appear to resolve the issue on Windows when the extension and CLI coexist
- Related issues: #22602, #8385, #14023, #4714, #3833
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗