Jakob Christensen / Agent Skills

/tidy-worktrees

Removes merged worktrees and branches, keeps the rest

Featured in Case #003: His Last Commit

Featured in Case #004: The Sign of the Four Sessions

Old worktrees (extra working folders of a git repository) and branches pile up, and it is hard to tell which of them are safe to delete.

This skill removes a worktree or branch only when all its commits are already in the default branch and the worktree has no uncommitted changes. Everything else stays.

It never pushes and never forces a removal. It also leaves locked worktrees and the one you are working in alone. A worktree that holds local files git ignores, such as notes or a .env settings file, is kept too, because those files exist nowhere else. Build and dependency folders do not count.

Start it with /tidy-worktrees. It then removes the safe ones without asking. If you want to see the list first, ask which worktrees it would remove. It needs git 2.31 or newer.

Download SKILL.md Read SKILL.md

When the agent uses it

Remove local git worktrees and branches whose work has safely landed in the default branch and whose worktree is clean, and keep everything else. Use when the user asks to tidy up, clean up or remove old worktrees and branches in a git repository, or asks which ones would be removed. Needs only git and runs in any tool. Not for pushing unpushed work, not for the single worktree a session just finished with, not for remote branches and not for archiving sessions in an app.

Install

Download the skill, drag it into your AI's chat and write "Install this skill."