git-worktree-clean

Solid

Clean up stale git worktrees with merged branch detection and disk usage report

AI & Automation 4,957 stars 661 forks Updated today CC-BY-SA-4.0

Install

View on GitHub

Quality Score: 96/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

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](./git-worktree.md) | [`/git-worktree`](./git-worktree.md) | [`/git-worktree-status`](./git-worktree-status.md) | [`/git-worktree-remove`](./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 tree) git worktree list --porcelain | while read li...

Details

Author
FlorianBruniaux
Repository
FlorianBruniaux/claude-code-ultimate-guide
Created
5 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