Delete git worktrees by name
Deletes specified worktrees, closes associated iTerm tabs, and cleans up branches.
npx claudepluginhub objectiveous/dots-claude-pluginsDeletes specified worktrees, closes associated iTerm tabs, and cleans up branches.
Usage: /dots-dev:worktree-delete <name1> [name2] [...]
git worktree listcat ~/.claude/worktree-registry.json 2>/dev/null || echo "{}"Delete the worktree(s) specified in the user's command arguments.
If no names provided, show available worktrees and usage info instead.
For each worktree name provided:
Find the worktree path: Look for it in git worktree list output.
Get the branch name: Extract from the worktree list or use git -C <path> branch --show-current.
Close iTerm tab if registered: Check registry for a tab_id, then close it (may fail if already closed):
osascript -e 'tell application "Terminal" to close (first tab of first window whose id is <tab_id>)' 2>/dev/null
Remove the git worktree: git worktree remove <path> --force
Delete the branch: git branch -D <branch-name>
Remove from registry:
jq --arg path "<worktree-path>" 'del(.[$path])' ~/.claude/worktree-registry.json > ~/.claude/worktree-registry.json.tmp && mv ~/.claude/worktree-registry.json.tmp ~/.claude/worktree-registry.json
Show remaining worktrees: Display git worktree list.