[BUG] --worktree flag replaces "/" with "+" in git branch names
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 using claude -w feature/auth, the "/" in the worktree name is replaced with "+" in the branch name, resulting in worktree-feature+auth.
Previously, "/" was preserved in the branch name (e.g., feature/auth). This changed after the fix for "--worktree hanging silently when the worktree name contained a forward slash".
The "/" → "+" replacement is necessary for the worktree directory name (filesystem constraint), but Git branch names natively support "/" (e.g., feature/auth, bugfix/login). The sanitization should only apply to the directory name, not the branch name.
What Should Happen?
claude -w feature/auth should create a branch with "/" preserved:
- Directory:
.claude/worktrees/feature+auth/(sanitized for filesystem — OK) - Branch:
worktree-feature/auth(Git allows "/" in branch names)
The sanitization should only apply to the directory name, not the branch name.
Error Messages/Logs
Steps to Reproduce
- Run
claude -w feature/auth - Check the branch name:
git branch --show-current - Observe: branch is
worktree-feature+authinstead ofworktree-feature/auth
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.90 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
This breaks team branch naming conventions that use "/" as hierarchy separators (e.g., feature/*, bugfix/*, hotfix/*). The current workaround requires a full WorktreeCreate hook replacement just to fix the branch name.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗