CLI started in VS Code integrated terminal opens 3 blank VS Code windows (Windows)

Status Fixed / completed
Maintainer reply ✓ Yes — blois
Activity 5 comments · opened Mar 5, 2026 · closed Mar 6, 2026
💡 Likely answer: A maintainer (blois, collaborator) responded on this thread — see the highlighted reply below.

Description

When running claude (or claude --dangerously-skip-permissions) from VS Code's integrated terminal (PowerShell) on Windows, 3 blank VS Code windows open every time. This does not happen when running from a standalone terminal (Windows Terminal).

Environment

  • OS: Windows 11 Pro 10.0.26200
  • VS Code extension: anthropic.claude-code v2.1.69
  • CLI: @anthropic-ai/claude-code v2.1.69 (global npm install)
  • VS Code setting: claudeCode.preferredLocation: "panel"

Steps to Reproduce

  1. Open VS Code with the Claude Code extension installed
  2. Open the integrated terminal (PowerShell)
  3. Type claude and press Enter
  4. 3 blank VS Code windows appear immediately

Root Cause (from log analysis)

When the CLI starts inside VS Code's integrated terminal, it connects to the extension's WebSocket MCP server. This triggers a burst of ~62 rapid WebSocket connections (visible in the extension log), each displacing the previous one:

Extension log (window1/exthost/Anthropic.claude-code/Claude VSCode.log):

2026-03-05 06:52:37.757 [info] New WS connection from: /
2026-03-05 06:52:37.757 [info] Disconnecting previous WebSocket client
2026-03-05 06:52:37.757 [info] MCP server connected to transport
2026-03-05 06:52:37.760 [info] New WS connection from: /
2026-03-05 06:52:37.760 [info] Disconnecting previous WebSocket client
2026-03-05 06:52:37.760 [info] MCP server connected to transport
2026-03-05 06:52:37.763 [info] New WS connection from: /
... (62 connections total within ~8 seconds)

This cascade results in 3 new blank renderer processes being spawned by the main VS Code process, each activating the Claude extension and starting its own MCP server on a random port:

window31: Claude code extension is now active? — MCP Server running on port 24700
window32: Claude code extension is now active? — MCP Server running on port 50340
window33: Claude code extension is now active? — MCP Server running on port 43636

The renderer log also shows errors during this period:

2026-03-05 06:52:38.272 [error] [Extension Host] Error sending selection change notification: Error: WebSocket is not open. Cannot send message.

Additional Evidence

  • VS Code main.log shows exactly 3 updateWindowsJumpList entries at the same timestamps as the blank windows
  • The pattern repeats consistently — every CLI start creates a new batch of 3 workspace storage directories (with no workspace.json, confirming they're blank/folderless windows)
  • Groups of 3 extension hosts exit when the blank windows are closed, then 3 new ones spawn on next CLI start

Workaround

Run claude from a standalone terminal (e.g., Windows Terminal) instead of VS Code's integrated terminal. The blank windows do not appear when the CLI is not running inside VS Code's terminal.

View original on GitHub ↗

5 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/30975
  2. https://github.com/anthropics/claude-code/issues/31080
  3. https://github.com/anthropics/claude-code/issues/30879

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

ramdacc · 5 months ago

I've been using the following workaround in the integrated terminal (Powershell) in VS Code:

$env:TERM_PROGRAM=''; $env:VSCODE_INJECTION=''; claude

blois collaborator · 5 months ago

Should be fixed in 2.1.70.

prakhar00007 · 5 months ago

Workaround: Permanent fix for 3 blank VS Code windows on Windows (Git Bash)

Environment:

  • OS: Windows
  • Terminal: Git Bash (integrated in VS Code)
  • Claude Code: v2.1.68+
  • VS Code terminal profile: Git Bash

Root Cause:
VS Code's integrated terminal sets environment variables (TERM_PROGRAM, VSCODE_INJECTION, CLAUDE_CODE_SSE_PORT) that Claude Code detects and uses to connect to the IDE. Each MCP server initialization reads these variables and triggers a new blank VS Code window.

Fix

Create a shell alias that unsets these variables before launching Claude.

Step 1: Create .bashrc with the alias:

echo 'alias claude="CLAUDE_CODE_SSE_PORT= TERM_PROGRAM= VSCODE_INJECTION= command claude"' > /c/Users/<YourUsername>/.bashrc

Step 2: Load it in the current session:

source /c/Users/<YourUsername>/.bashrc

Step 3: Make it persistent across all future terminal sessions by creating .bash_profile:

echo '[ -f ~/.bashrc ] && source ~/.bashrc' > /c/Users/<YourUsername>/.bash_profile
Replace <YourUsername> with your actual Windows username.

How it works

  • The alias overrides the claude command to clear the three environment variables before execution.
  • Using command claude ensures the alias calls the actual claude binary and not itself (avoids infinite recursion).
  • The .bash_profile ensures .bashrc is sourced on every new Git Bash session, including VS Code's integrated terminal.

Result

After applying this fix, typing claude in any VS Code integrated terminal (Git Bash) works normally with zero blank windows. Works across all repos and projects.

Note: This is a workaround until Anthropic ships an official fix. The tradeoff is that clearing these variables disables the Claude Code ↔ VS Code IDE integration (e.g., the extension sidebar connection). If you rely on that, this workaround may not be suitable. For most CLI-only users, there is no downside.
github-actions[bot] · 5 months ago

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.