/ide Command Fails to Recognize Git Worktrees

Resolved 💬 3 comments Opened Sep 22, 2025 by SalesforceRocks Closed Jan 8, 2026

Bug Report: /ide Command Fails to Recognize Git Worktrees

Bug Summary

The /ide command in Claude Code fails to recognize when the current working directory is a git worktree of a project that's already open in the IDE.

Environment

  • Claude Code Version: Current (as of 2025-09-22)
  • IDE: IntelliJ IDEA
  • OS: macOS (Darwin 24.6.0)
  • MCP Integration: JetBrains MCP

Steps to Reproduce

  1. Have a main git repository open in IntelliJ (e.g., ~/myProject)
  2. Create a git worktree in a different directory (e.g., ~/myProject-issue-44)
  3. Navigate to the worktree directory in Claude Code
  4. Run the /ide command
  5. Observe that it fails to recognize the IDE connection

Expected Behavior

The /ide command should:

  • Recognize that the current directory is a git worktree
  • Identify that the parent repository is already open in an IDE
  • Successfully connect to the IDE that has the main repository open
  • Allow IDE operations on files in the worktree

Actual Behavior

The /ide command:

  • Reports "No available IDEs detected"
  • Shows that IDEs are running but "their workspace/project directories do not match the current cwd"
  • Lists the main repository path but doesn't recognize the worktree relationship
  • Fails to establish IDE connection

Error Output

Select IDE
Connect to an IDE for integrated development features.

No available IDEs detected. Make sure your IDE has the Claude Code extension or plugin installed and is running.

Found 3 other running IDE(s). However, their workspace/project directories do not match the current cwd.

• IntelliJ IDEA: /XXXX
• IntelliJ IDEA: /XXXX
• IntelliJ IDEA: /myProject

Workaround

The MCP JetBrains integration still works correctly when explicitly specifying the project path:

mcp__jetbrains__open_file_in_editor with projectPath="/myProject"

Root Cause Analysis

The /ide command appears to be doing a simple string comparison of directory paths instead of:

  1. Checking if the current directory is a git repository
  2. Determining if it's a worktree using git worktree list
  3. Finding the main repository path
  4. Matching against open IDE projects using the main repository path

Suggested Fix

Enhance the /ide command to:

  1. Check if current directory is in a git repository: git rev-parse --show-toplevel
  2. Check if it's a worktree: git rev-parse --git-common-dir
  3. If it's a worktree, get the main repository path: git worktree list --porcelain
  4. Match IDE projects against both the current path AND the main repository path
  5. Establish connection with IDE that has either path open

Impact

  • Severity: Medium
  • Affects: Users working with git worktrees (common workflow for feature branches)
  • Workaround Available: Partially (using MCP directly with explicit project path)

Additional Context

Git worktrees are commonly used for:

  • Working on multiple features simultaneously
  • Testing changes in isolation
  • Keeping separate working directories for different branches
  • Avoiding constant branch switching in the main repository

This is a standard git workflow that should be supported by Claude Code's IDE integration.

---
Date Reported: 2025-09-22
Reported By: User via Claude Code session
Issue Location: /ide command in Claude Code

View original on GitHub ↗

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