[BUG] Windows: CLI spawns 3 empty VSCode windows on startup — root cause is `code` CLI calls from integrated terminal

Resolved 💬 4 comments Opened Mar 5, 2026 by nevercast Closed Mar 6, 2026

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?

Running claude from the VSCode integrated terminal spawns 3 empty VSCode windows on startup. This is caused by the CLI's auto-install of the VSCode extension, which invokes the code CLI. On Windows, each code CLI call from the integrated terminal opens a new empty window as a side effect.

Root Cause Analysis

Through extensive diagnostics, I've confirmed the following:

It is NOT version-specific:

  • Happens on Claude Code 2.1.66, 2.1.68, and 2.1.69
  • Happens on VSCode 1.109.5 and 1.110.0
  • Happens with or without the Claude Code VSCode extension installed

It is NOT caused by MCP servers:

  • MCP servers are connected and working (Azure DevOps MCP in my case) — they neither cause nor prevent the 3-window behaviour
  • #30848 attributed the windows to MCP server initialization (3 MCP servers = 3 windows), but this is coincidental — the number of empty windows does not correlate with MCP server count

It is NOT caused by environment variables:

  • Setting TERM_PROGRAM=vscode, VSCODE_INJECTION=1, and other VSCode env vars in a standalone CMD terminal does NOT trigger the bug
  • The bug only occurs inside the VSCode integrated terminal

It IS caused by code CLI calls from the integrated terminal:

  • Running code --version from the VSCode integrated terminal opens an empty window (confirmed independently of Claude)
  • Running code --uninstall-extension anthropic.claude-code from the integrated terminal opens an empty window
  • The CLI auto-installs the extension on startup using the code CLI, triggering multiple empty windows

Workaround:

Setting CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL=1 in ~/.claude/settings.json completely eliminates the empty windows:

{
  "env": {
    "CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL": "1"
  }
}

Note: this also appears to disable /ide connectivity ("No IDEs were found"), even when the extension is manually installed. So this is a workaround, not a proper fix.

The proper fix might be one of:

  1. Don't shell out to code CLI from the integrated terminal
  2. Use code --reuse-window or equivalent flags that prevent new window creation
  3. Don't auto-install the extension on every startup if it's already installed (the officialMarketplaceAutoInstallAttempted state flag exists but doesn't prevent re-attempts)

What Should Happen?

Starting Claude Code from the VSCode integrated terminal should not spawn any extra VSCode windows.

Error Messages/Logs

No error messages — windows open silently. VSCode's storage.json accumulates entries in backupWorkspaces.emptyWindows with timestamps ~2-3 seconds apart, matching the window creation pattern.

Steps to Reproduce

  1. Install Claude Code (native, any recent version)
  2. Open VSCode on Windows
  3. Open the integrated terminal
  4. Run claude
  5. Three empty VSCode windows appear within ~10-15 seconds of startup

To confirm the root cause independently: Run code --version from the VSCode integrated terminal — it will open an empty window.

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.69 (also reproduced on 2.1.66)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

Shell: Git Bash, Cmd, and PowerShell (all inside VSCode)
Windows 11 Pro 10.0.26200
VSCode: 1.110.0 (also reproduced on 1.109.5)

Unclear if this is a regression, as may have always existed but been masked by window.restoreWindows: "all" (the default) causing empty windows to blend in with restored windows.

Behaviour in VSCode related to old issue:

Behaviour in Claude Code related to the following issues:

  • #30848 (open, regression label — same symptom but incorrectly attributed to MCP servers)
  • #30946 (about to be auto-closed as duplicate)
  • #30921 (closed as duplicate)
  • #21039 (closed as inactive — root issue never fixed)

Additional finding: code.exe vs code.cmd PATH resolution

The VSCode issue linked above (227186) was closed as "as-designed" — the maintainer noted that Code.exe is the Electron app (opens a window), while bin\code.cmd is the proper CLI wrapper (uses IPC).

Inside the VSCode integrated terminal, the install root (Microsoft VS Code\) is prepended to PATH before Microsoft VS Code\bin\, so code resolves to Code.exe first. In a standalone terminal, only Microsoft VS Code\bin\ is on PATH (via the user PATH registry), so code correctly resolves to the CLI wrapper.

If Claude Code's auto-install logic calls code and it resolves to Code.exe inside the integrated terminal, each invocation would open a new window and return no output — potentially explaining the 3 windows as 3 retry attempts.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗