Remove git worktrees from .worktrees/ directory and clean up all traces...
This skill removes git worktrees from the .worktrees/ directory and ensures all traces are completely cleaned up. It can remove a specific worktree by name or present an interactive selection menu when no name is provided.
Use this skill when the user needs to:
The skill uses a bash script (scripts/remove_worktree.sh) that:
/ with -) to match git-worktree-create behavior.worktrees/ directory existsgit worktree remove --force.worktrees/ directory if it becomes emptyscripts/remove_worktree.sh <worktree-name>
Examples:
# Remove worktree by directory name
scripts/remove_worktree.sh hotfix-123
# Remove worktree using original branch name (will be auto-sanitized)
scripts/remove_worktree.sh user.name/AOF-123
# This will remove: .worktrees/user.name-AOF-123
# Both approaches work the same:
scripts/remove_worktree.sh feature/new-feature
scripts/remove_worktree.sh feature-new-feature
scripts/remove_worktree.sh
This will display a numbered list of available worktrees and prompt you to select one.
When called without arguments, the script displays:
No worktree name provided. Available worktrees:
[1] feature-branch
[2] hotfix-123
[3] bugfix-456
Select worktree to remove (number or name):
You can respond with either:
2)hotfix-123)--force flag to handle worktrees with uncommitted changesThe script ensures no traces remain by:
.worktrees/<worktree-name>).worktrees/ directory if emptyThe script will error if:
.worktrees/ directory exists# User has finished work on hotfix-123 worktree
$ scripts/remove_worktree.sh hotfix-123
ā ļø About to remove worktree: .worktrees/hotfix-123
Are you sure? (y/N): y
Removing worktree...
ā
Worktree removed successfully
Pruning worktree administrative data...
ā
Worktree 'hotfix-123' has been completely removed
All traces of the worktree have been cleaned up.