[BUG] claude silently launches VS Code instead of terminal session when run from subdirectory of trusted project
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
- Install the
anthropic.claude-codeVS Code extension - Run
claudefrom a project root (e.g.C:\project\) — accept the trust prompt; this creates a
session entry under ~/.claude/projects/
- Exit the session (
/exitor Ctrl+C) - In the same
cmd.exewindow,cdinto a subdirectory (e.g.C:\project\src\) - 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": falseto~/.claude/settings.json - You uninstall the
anthropic.claude-codeVS 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 EDITORorVISUALenvironment variables- VS Code AutoRun registry key (
HKCU\Software\Microsoft\Command Processor\AutoRun) - A local
claudebinary override innode_modules/.bin/ - Running from VS Code's integrated terminal
4 Comments
This is a Windows-specific issue where the VS Code extension's
claudecommand takes precedence over the CLI.If it resolves to the VS Code extension's binary, you need to reorder your PATH:
Or invoke the CLI explicitly:
The VS Code extension may be intercepting the
claudecommand via a registered URI handler. Try: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.
C:\Users\varelion\AppData\Roaming\npm\claude
C:\Users\varelion\AppData\Roaming\npm\claude.cmd
Uninstalled VSCode's Claude extension. Removed VSCode from path.
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" />
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
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.