← ClaudeAtlas

git-worktreelisted

Lists linked worktrees with PR state and cleans up merged ones. Use when asked to "list worktrees", "clean up worktrees", or after shipping a PR to reclaim slots. Do NOT use to enter a worktree from scratch (use `session-worktree`).
erclx/canon · ★ 2 · Code & Development · score 68
Install: claude install-skill erclx/canon
# Git worktree List linked worktrees with their PR state and remove the merged ones. For entry, use `session-worktree`. ## Shipping order - Merge the branch with the smallest shared-file footprint first. A branch touching `CLAUDE.md`, a Claude context entry, or a regenerated `index.md` merges last. - Rebase each sibling worktree on `origin/main` after a PR merges and before the next one merges. Never merge a stale branch. - Run `cleanup` once a PR merges, so the worktree and its local branch go together ## Mode selection Pick exactly one mode from the user's request: - `list`: show every worktree with its branch, PR state, and dirtiness ("list worktrees", "what worktrees do I have") - `cleanup`: remove worktrees whose branches are merged, then prune local branches ("clean up worktrees", "reclaim worktree slots") ## Context Run in parallel: - `git rev-parse --git-dir 2>/dev/null || echo "NO_REPO"` - `git rev-parse --git-common-dir 2>/dev/null || echo "NO_REPO"` - `git worktree list --porcelain 2>/dev/null || echo "NO_REPO"` - `git fetch --prune origin 2>/dev/null || echo "NO_REMOTE"` Resolve `MAIN_ROOT` from the first `worktree` line of `git worktree list --porcelain`. ## Guards - If either `git-dir` command returned `NO_REPO`, stop: `❌ Not a git repository.` ## Enumeration (list and cleanup) Parse `git worktree list --porcelain` into rows. Each row has `path`, `branch`, `head`. Skip the `bare` row if present. For each row, determine merge state of its branch: