Skip to content

[BUG] VS Code extension overwrites ~/.claude.json, forcing CLI onboarding on every launch #29029

Description

@LouisDeGroelard-Apex

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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?

  1. The extension should merge into ~/.claude.json rather than overwriting it, preserving fields written by the CLI
  2. Or: the extension and CLI should use separate config storage so they don't conflict
  3. The CLAUDECODE=1 env 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

  1. Open VS Code with the anthropic.claude-code extension installed and active
  2. Open a PowerShell terminal inside VS Code
  3. Clear the CLAUDECODE env var: Remove-Item Env:\CLAUDECODE
  4. Run claude
  5. Complete the onboarding (theme, trust dialog, login)
  6. Verify ~/.claude.json contains "hasCompletedOnboarding": true
  7. Wait a few seconds — the extension overwrites the file, losing those fields
  8. Open another terminal tab, run claude again → 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:idebugSomething isn't workinghas reproHas detailed reproduction stepsplatform:vscodeIssue specifically occurs in VS Codeplatform:windowsIssue specifically occurs on WindowsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions