git-worktree-clean
FeaturedClean up stale git worktrees with merged branch detection and disk usage report
AI & Automation 5,772 stars
755 forks Updated today CC-BY-SA-4.0
Install
Quality Score: 96/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Git Worktree Clean
Batch cleanup of stale git worktrees. Safely removes merged branches, reports disk usage, and handles unmerged branches interactively.
**Core principle:** Auto-clean merged worktrees, interactive review for unmerged, always report what was reclaimed.
**Part of:** [Worktree Lifecycle Suite](../../commands/git-worktree.md) | [`/git-worktree`](../../commands/git-worktree.md) | [`/git-worktree-status`](../../commands/git-worktree-status.md) | [`/git-worktree-remove`](../../commands/git-worktree-remove.md)
## Process
1. **List All Worktrees**: `git worktree list`
2. **Classify Each**: merged vs unmerged vs protected
3. **Calculate Disk Usage**: Per-worktree size
4. **Auto Mode**: Remove all merged worktrees (safe)
5. **Interactive Mode**: Review unmerged worktrees one by one
6. **Database Cleanup Reminder**: List DB branches to clean
7. **Report**: Summary of actions taken and space reclaimed
## Flags
| Flag | Effect |
|------|--------|
| `--dry-run` | Preview what would be cleaned, no changes |
| `--all` | Include unmerged worktrees (interactive confirmation each) |
| `--force` | Remove all worktrees without confirmation (dangerous) |
## Worktree Discovery
```bash
# Get main branch name
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
MAIN_BRANCH=${MAIN_BRANCH:-main}
# Protected branches (never auto-clean)
PROTECTED="main master develop staging production"
# List all worktrees (skip main working...
Details
- Author
- FlorianBruniaux
- Repository
- FlorianBruniaux/claude-code-ultimate-guide
- Created
- 7 months ago
- Last Updated
- today
- Language
- Python
- License
- CC-BY-SA-4.0
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Featured
git-worktree-remove
Safely remove a git worktree with branch cleanup and safety checks
5,772 Updated today
FlorianBruniaux AI & Automation Featured
git-worktree
Create isolated git worktrees for feature development without switching branches
5,772 Updated today
FlorianBruniaux AI & Automation Listed
worktrees
Audits and optionally prunes git worktrees: current repo by default, cross-repo scan under ~/dev/ with --all. Use when the user says '/worktrees', 'audit worktrees', or 'prune worktrees'.
15 Updated yesterday
domengabrovsek