[BUG] Claude code used full path bypassing worktree edits
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?
I am using claude code inside a worktree using claude --worktree. The worktree is created:
➜ git worktree list
/<path>/<project> 9924f5f [main]
/<path>/<project>/.claude/worktrees/noble-soaring-elephant 9924f5f [worktree-noble-soaring-elephant]
The branch is there. I cannot switch to the worktree or the branch because it is actively used by claude code.
The agent was asked to do an action. The main branch was updated. I am not going to ask an LLM why it did something. It does not know. I did try and it hallucinated how worktrees work. The behavior was incorrect however the tools/subagents were called to a full path of my repo. The edits should be within the isolation of the worktree I opened the harness in. I now have to untie the agents vomit from my work.
From what I can tell the agent used a full path to the directory for the subagent calls. The full path was to the root of the project not the relative path of the agent's worktree.
What Should Happen?
When in a worktree claude code should use either the absolute path to the worktree it is in or a relative path.
Error Messages/Logs
Steps to Reproduce
It is hit or miss behavior. Run claude --worktree ask for an edit and hope it does not stomp on main.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.123
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗