[BUG] claude silently launches VS Code instead of terminal session when run from subdirectory of trusted project

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Mar 30, 2026 · closed Mar 31, 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?

When running claude from a subdirectory of a previously-visited project, the CLI immediately
exits and silently spawns VS Code instead of starting an interactive terminal session. No error is
shown — the command just returns to the prompt and VS Code opens.

What Should Happen?

Claude Code should start an interactive terminal session, identical to the behavior when running from
the project root directory.

Error Messages/Logs

C:\Users\varelion\test\tstest\src>claude

  C:\Users\varelion\test\tstest\src>
  [main 2026-03-30T18:49:05.645Z] update#setState idle
  [main 2026-03-30T18:49:07.382Z] Extension host with pid 17712 exited with code: 0, signal: unknown.

Steps to Reproduce

  1. Install the anthropic.claude-code VS Code extension
  2. Run claude from a project root (e.g. C:\project\) — accept the trust prompt; this creates a

session entry under ~/.claude/projects/

  1. Exit the session (/exit or Ctrl+C)
  2. In the same cmd.exe window, cd into a subdirectory (e.g. C:\project\src\)
  3. Run claude

Result: CLI exits immediately, VS Code opens, extension host starts and exits.

Note: The bug does NOT reproduce if:

  • You run from a brand-new directory with no prior session (trust prompt appears and session starts

normally)

  • You use PowerShell instead of cmd.exe
  • You add "ide": false to ~/.claude/settings.json
  • You uninstall the anthropic.claude-code VS Code extension

This suggests the trigger is: subdirectory of trusted/previously-visited project + VS Code extension
installed + cmd.exe shell.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

N/A, it works on other directories and in powershell in the afflicted directory.

Claude Code Version

v2.1.87

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

Workaround: Adding "ide": false to ~/.claude/settings.json resolves the issue immediately.

Root cause hypothesis: The CLI detects a session entry in ~/.claude/projects/ for the parent
directory and treats the project as trusted/known. When the anthropic.claude-code VS Code extension
is installed, it then auto-defers to VS Code for new CWDs within that project rather than starting a
terminal session. The behavior differs between cmd.exe and PowerShell likely due to differences in
how node.js detects TTY/stdin characteristics in each shell.

Confirmed NOT caused by:

  • %TEMP%
  • ~./.claude
  • /tstest/.claude
  • Hooks in .claude/settings.local.json
  • EDITOR or VISUAL environment variables
  • VS Code AutoRun registry key (HKCU\Software\Microsoft\Command Processor\AutoRun)
  • A local claude binary override in node_modules/.bin/
  • Running from VS Code's integrated terminal

View original on GitHub ↗

4 Comments

yurukusa · 6 months ago

This is a Windows-specific issue where the VS Code extension's claude command takes precedence over the CLI.

where claude   # Windows cmd
which claude   # Git Bash/WSL

If it resolves to the VS Code extension's binary, you need to reorder your PATH:

export PATH="$HOME/.npm-global/bin:$PATH"

Or invoke the CLI explicitly:

npx @anthropic-ai/claude-code

The VS Code extension may be intercepting the claude command via a registered URI handler. Try:

// .vscode/settings.json
{
  "claude-code.interceptCli": false
}

The subdirectory behavior difference is likely because the VS Code extension recognizes the parent as a 'trusted project' and hijacks the CLI invocation to open in the editor instead.

Varelion · 6 months ago
where claude # Windows cmd which claude # Git Bash/WSL

C:\Users\varelion\AppData\Roaming\npm\claude
C:\Users\varelion\AppData\Roaming\npm\claude.cmd

Uninstalled VSCode's Claude extension. Removed VSCode from path.

npx @anthropic-ai/claude-code

This also brings up VSCode.

Interestingly, if I were to delete the Code.exe altogether, and try again, I'm given this prompt:

<img width="1065" height="501" alt="Image" src="https://github.com/user-attachments/assets/b8e7150a-9293-45be-be34-01745e6ec350" />

Varelion · 6 months ago

Found the issue. There was a file in the directory called node.js, and CMD resolves "node" by scanning PTHEXT in the current directory first. node.COM, EXE. BAT. CMD, and eventually .JS

github-actions[bot] · 6 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.