worktree-tidy
Installation
SKILL.md
Worktree Tidy
Keep the number of git worktrees down without losing work. Read references/glossary.md first and use its terms in reports.
TIDY=<this skill's directory>/scripts/worktree_tidy.py is the engine (Python 3.9+, standard library only). It decides what is Stale from facts; you show the report, the user chooses, the script removes and checks again before each removal.
Hard rules
- Remove only what the script reports as
removable, and only after the user confirms the list. Exception: the user may explicitly choose hand-removal of a worktree whoseblockersis exactly["recent"]; pass--allow-recentonly for those paths. This bypasses only the idle threshold, never any other Blocker, alone or combined withrecent. The script still re-assesses blockers and checks dirty and non-regenerable ignored files immediately before removal.removewithout--yesis a dry run; pass--yesonly after confirmation. - Never use
git worktree remove --force,rm -rfon a worktree, or a tool's own delete command (Orca'sworktree rmalso deletes branches). The script uses plaingit worktree remove; tools such as Orca drop the worktree from their sidebar on their next scan. - Removing a worktree keeps its branch. Pass
--delete-branchonly when the user asked for it; the script still deletes a branch only when its Request ismergedorclosedand its tip is reachable from another branch, tag or remote-tracking ref (branchSaved). It re-checks this immediately before deletion; otherwise it keeps the branch and reportsbranchError. - Non-regenerable ignored files block removal (
ignored), because plaingit worktree removecan silently delete ignored files. Never discard them to make a worktree removable. - Never commit, stash or discard changes to make a worktree removable. A
dirtyworktree is reported for the user to handle.
Workflow
- Scan. With no arguments the script scans the repository of the current folder, or the roots in the config file.