Skip to content
Back to skills

Cleanup

ASecurity

Remove the worktrees and local branches already merged into the integration branch, and the leftovers (agent worktrees, orphan directories). Use when the user asks to clean up worktrees or branches.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 21, 2026
developmentgogit

Security analysis

A100/100

Scanned October 21, 2026

npx -y skills add antoine-tena/kiln --skill cleanup --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cleanup?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cleanup
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/antoine-tena-cleanup/badge)](https://www.skillsdirectory.com/skills/antoine-tena-cleanup)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cleanup
description: Remove the worktrees and local branches already merged into the integration branch, and the leftovers (agent worktrees, orphan directories). Use when the user asks to clean up worktrees or branches.
---

From the root of the repo, never switching the branch of the main tree. Integration branch: the
one the project's `CLAUDE.md` names, otherwise `develop` if it exists, otherwise `origin`'s
default branch.

1. `git fetch -q --prune origin`, then `git worktree prune`.
2. For each worktree of `git worktree list --porcelain` (except the main tree): note its branch,
   whether it has changes (`git -C <wt> status --porcelain`) and whether its branch is merged
   (`git merge-base --is-ancestor <branch> origin/<integration>`). A detached worktree (agents):
   check whether its HEAD is in `origin/<integration>`.
3. Show a table: worktree, branch, merged?, changes?, last commit. Sort into "removable" (merged
   and clean) and "to keep or decide"; in the latter, flag as probably forgotten a worktree not
   merged with no commit for more than two weeks, or with uncommitted changes, and ask what to
   do with it (finish, keep, remove).
4. **Ask for confirmation**, then for the removable ones: `git worktree remove <wt>` and
   `git branch -d <branch>` (never `-D`, never `--force` on a worktree with changes).
5. Local branches without a worktree that are merged: offer `git branch -d` the same way. Never
   delete a remote branch without explicit agreement.
6. Sum up what was removed and what remains.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.