Individual skill
worktree-cleaner
Inventory the git worktrees of the current repository, classify each one with evidence (merged, PR state, uncommitted or unpushed work, locked, stale, in use by a running session) and remove them one at a time or by group, always asking the user first and verifying every removal. Use when worktrees have piled up (for example one per Claude Code task or thread), when `git worktree list` is long, or when the user asks to clean up, prune or tidy worktrees.
cli-tool/components/skills/git/worktree-cleaner/SKILL.md
Source commit ad81bf053f80b626801decf425f501ba49983d98
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- Yes
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Network or broad shell
- Last checked
- Nov 4, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 33,182
- Repository last updated
- Nov 7, 2026
- License
- MIT
Observed agent integration: No specific integration evidence. Standard SKILL.md installation does not imply verified compatibility.
- anthropic Repository topic
- anthropic-claude Repository topic
- claude Repository topic
- claude-code Repository topic
- agent-skills Repository topic
- ai-agents Repository topic
- claude-code-plugins Repository topic
- cli Repository topic
- mcp Repository topic
- registry Repository topic
- git Declared skill tag
- worktree Declared skill tag
- cleanup Declared skill tag
- maintenance Declared skill tag
- engineering Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
Read excerpt
# Worktree Cleaner
Agents and parallel workflows create one git worktree per task, and nobody removes them. This skill finds them, shows the user what each one holds, and removes only what the user approves, checking the result after every step.
The user decides. You gather evidence, recommend, and execute exactly what was approved. Nothing is removed in bulk without the user seeing the list first.
## Hard rules
1. **Ask before every destructive command.** `git worktree remove`, `git worktree prune`, `git worktree unlock` and `git branch -d/-D` each need the user's approval for that worktree or that named group. Approval of one group does not carry to the next.
2. **Never `--force` on work that would be lost.** If a worktree has uncommitted changes, untracked files, or commits that exist nowhere else, show the exact files and commits and ask a separate, explicit question ("remove it and lose these changes?"). A general "yes, clean everything" is not that confirmation.
3. **Never touch** the main worktree, the worktree you are running in, or a worktree with live processes inside it (another Claude Code session, an editor, a dev server). Report them and move on.
4. **Never delete a remote branch** (`git push --delete`, `git push origin :branch`, API calls). Remote branches are out of scope; mention them in the report if they look stale.
5. **Deleting the local branch is a separate question**, asked after the worktree is gone. Removing a worktree never deletes its branch.
6. **Re-check right before acting.** State changes while you talk to the user: re-run the inventory for that one path immediately before removing it, and stop if the verdict got worse.