[BUG] /ide fails to connect to VS Code when cwd differs from startup directory (worktree scenario)

Resolved 💬 2 comments Opened Mar 6, 2026 by SureneruS Closed Apr 3, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

When Claude Code is started in the main repo directory but later cds into a git worktree (e.g., via EnterWorktree or manual cd), the /ide command fails to connect to VS Code even when VS Code is open at the current working directory.

The dialog shows:

No available IDEs detected.
Found 1 other running IDE(s). However, their workspace/project directories do not match the current cwd.
  • Visual Studio Code: /path/to/repo/.worktrees/my-feature

pwd confirms the cwd is the worktree path, and VS Code is open at the same path. But /ide appears to match against the original startup directory, not the current cwd.

What Should Happen?

/ide should match against the current working directory, not the startup directory.

Steps to Reproduce

  1. Start Claude Code in the main repo: cd /path/to/repo && claude
  2. During the session, work moves into a worktree (e.g., .worktrees/my-feature) — cwd changes
  3. Open VS Code at the worktree: code .worktrees/my-feature
  4. Run /ide — it finds the VS Code instance but won't connect, saying directories don't match

Is this a regression?

I don't know

Claude Code Version

2.1.70

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Related: #31008 (worktrees share project identity, causing path confusion)

View original on GitHub ↗

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