[BUG] Worktree agents edit files in worktree path instead of main repo — changes silently lost
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 Claude Code operates in a git worktree (e.g. .claude/worktrees/optimistic-bhabha), file edits target the worktree copy rather than the main repository. If the user runs dotnet run (or any build/serve command) from the main repo, edits are silently ignored — no error, no warning.
Steps to reproduce:
Start a Claude Code session that creates a worktree (e.g. via EnterWorktree)
Edit a file — e.g. src/MyProject/Services/MyService.cs
The edit lands at .claude/worktrees/<name>/src/MyProject/Services/MyService.cs
User runs dotnet run from the main repo at C:\myproject\src\MyApp
Changes are not picked up — no error surfaced
Expected behavior: Either (a) edits should target the main repo when the user's dev server runs there, or (b) Claude Code should warn when it detects the user is running commands from a different path than where edits are being applied.
Impact: High — causes silent failures that are very difficult to diagnose. The user sees no errors but changes simply don't take effect, leading to wasted debugging cycles.
What Should Happen?
Expected behavior: Either (a) edits should target the main repo when the user's dev server runs there, or (b) Claude Code should warn when it detects the user is running commands from a different path than where edits are being applied.
Error Messages/Logs
Steps to Reproduce
Start a Claude Code session that creates a worktree (e.g. via EnterWorktree)
Edit a file — e.g. src/MyProject/Services/MyService.cs
The edit lands at .claude/worktrees/<name>/src/MyProject/Services/MyService.cs
User runs dotnet run from the main repo at C:\myproject\src\MyApp
Changes are not picked up — no error surfaced
Expected behavior: Either (a) edits should target the main repo when the user's dev server runs there, or (b) Claude Code should warn when it detects the user is running commands from a different path than where edits are being applied.
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Claude 1.1.6679 (f8f4ff) 2026-03-13T18:26:03.000Z
Claude Code Version
Claude 1.1.6679 (f8f4ff) 2026-03-13T18:26:03.000Z
Platform
Other
Operating System
Windows
Terminal/Shell
Other
Additional Information
Using Claude Code for Windows.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗