[BUG] --worktree <name> silently falls back to parent repo cwd when worktree name already exists
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?
claude -w/--worktree <name> is documented as "Create a new git worktree for this session". When the requested name collides with an existing worktree at .claude/worktrees/<name>/, the flag neither attaches to it nor errors visibly — the session silently starts bound to the parent repo's cwd (and parent's checked-out branch). Any edits land on the parent branch, giving the impression the worktree was selected when it wasn't.
What Should Happen?
One of:
- Attach to the existing worktree of that name and
chdirinto it, or - Fail loudly with a message like:
``claude
Error: worktree 'bugfix-blocker' already exists at <path>.
cd into it and run , or choose a different name.``
Error Messages/Logs
Steps to Reproduce
- Have a worktree at
.claude/worktrees/bugfix-blocker/(branchworktree-bugfix-blocker) — created from a previousclaude --worktree bugfix-blockersession, for example. - From the parent repo (on a different branch, e.g.
test):
``bash``
cd /path/to/repo
claude --worktree bugfix-blocker
- Inside the new session:
``bash``
pwd # → /path/to/repo (parent, NOT the worktree)
git branch --show-current # → test (parent's branch)
- Any file edits go to
test, notworktree-bugfix-blocker.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.128 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗