[BUG] Working directory doesn't match selected directory when using worktrees

Resolved 💬 3 comments Opened Dec 2, 2025 by hirscr Closed Dec 6, 2025

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?

Problem: When starting a conversation, I selected my main repository directory from the dropdown, but Claude's environment defaulted to the worktree path (/Users/roberf/.claude-worktrees/Metermaid/competent-elbakyan). This caused Claude to read files from the wrong location.

Expected Behavior: When I select a working directory from the dropdown, Claude should operate from that directory—particularly when reading project files like CLAUDE.md. Git syncing should happen at commit time, not affect where Claude looks for files.

Suggested Fix: Claude should prioritize the user-selected directory. If a file isn't found there immediately, it should search within that directory tree before falling back to the git worktree.

Additional Context: My CLAUDE.md is in a /Docs subfolder, not the root. When Claude didn't find it at the root, it appears to have searched the worktree instead of looking in subdirectories of my selected path first.

I read these issues but they are not the same. :
Issue #3377 - Reports "being in wrong working directory/worktree" as a behavioral issue
Issue #705 - CLAUDE.md not being found correctly with worktrees
Issue #2841 - Can't navigate to worktree directories
Issue #8019 - /ide command fails to recognize worktrees

What Should Happen?

Expected Behavior: When I select a working directory from the dropdown, Claude should operate from that directory—particularly when reading project files like CLAUDE.md. Git syncing should happen at commit time, not affect where Claude looks for files.

Error Messages/Logs

It didnt think it was making an error

Steps to Reproduce

Steps to Reproduce:

  1. Create a git worktree from your main repository (e.g., git worktree add ~/.claude-worktrees/MyProject/branch-name)
  2. Open Claude Code
  3. From the directory dropdown, select the main repository path (not the worktree)
  4. Ask Claude to read a file that exists in both locations but with different content (e.g., CLAUDE.md in a subdirectory)

Observe that Claude reads from the worktree path instead of the selected directory
Actual Result: Claude's environment shows the worktree as the working directory and reads files from there.

Expected Result: Claude should use the directory selected in the dropdown and read files from that location.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.30 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Additional Context: My CLAUDE.md is in a /Docs subfolder, not the root. When Claude didn't find it at the root, it appears to have searched the worktree instead of looking in subdirectories of my selected path first.

View original on GitHub ↗

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