feat(mk): drop a leading "worktree-" from the worktree folder name - #12
Merged
Conversation
Claude Code creates worktrees as .claude/worktrees/<name> on a branch named worktree-<name>. wt now derives the folder the same way, so `wt mk worktree-my-feature` lands in .claude/worktrees/my-feature instead of .claude/worktrees/worktree-my-feature. Both spellings still resolve: _wt_resolve matches the branch name or the folder basename, and completion already does substring matching. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The behavior change is implemented in a single shared helper, is exercised by targeted tests (including the worktree- edge case), and documentation has been updated accordingly.
Pull request overview
This PR aligns wt mk’s default worktree folder naming with Claude Code by stripping a leading worktree- prefix from the folder name (while leaving the branch name unchanged), so both tools share the same .claude/worktrees/<name> layout.
Changes:
- Add
_wt_safe_nameand use it for default worktree folder naming (and{name}expansion) to drop a leadingworktree-after slash-to-dash normalization. - Update
wt mkbehavior and documentation to reflect the new naming rule. - Add/extend Bats tests to ensure both
wt mkand_wt_resolvesupport the new mapping and the edge caseworktree-.
File summaries
| File | Description |
|---|---|
lib/core.sh |
Introduces _wt_safe_name and uses it as the canonical “safe folder name” input to default path expansion. |
lib/commands/mk.sh |
Switches wt mk to compute the destination folder name via _wt_safe_name. |
test/helpers.bash |
Updates test helper wt_dest() to match the new folder-naming logic. |
test/mk.bats |
Adds tests for stripping worktree- and preserving the exact worktree- branch name case. |
test/resolve.bats |
Adds coverage confirming _wt_resolve can find the same worktree via both branch name and folder basename. |
README.md |
Documents the updated default folder naming behavior. |
lib/commands/help.sh |
Updates wt.path help text to describe the new {name} semantics. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code creates worktrees as
.claude/worktrees/<name>on a branch namedworktree-<name>.wt mknow names the folder the same way, sowt mk worktree-my-featurecreates.claude/worktrees/my-feature.Both spellings still resolve —
_wt_resolvematches branch name or folder basename, and completion already does substring matching.🤖 Generated with Claude Code