wt-cleanuplisted
Install: claude install-skill ThinkVelta/agent-tracker
# Worktree Cleanup
Scan for stale worktrees and orphaned branches, then let the user decide what to clean up. This
is the batch housekeeping counterpart to `/wt-close` (which handles one worktree at a time).
**User input:** $ARGUMENTS
If `--dry-run` is in the arguments, report what would be cleaned up without making any changes.
## Step 1 — Inventory worktrees
```bash
git worktree list --porcelain
```
For each worktree (excluding the main working tree), gather:
- **Branch name**
- **Path on disk** — verify the directory still exists
- **Last commit date:**
```bash
git -C "<path>" log -1 --format="%ct" 2>/dev/null
```
- **Dirty/clean status:**
```bash
git -C "<path>" status --porcelain 2>/dev/null | wc -l | tr -d ' '
```
Classify each worktree:
| Status | Criteria |
| ----------- | ------------------------------------------------------------------- |
| **Stale** | Last commit more than 7 days ago and clean (no uncommitted changes) |
| **Missing** | Directory no longer exists on disk (stale git metadata) |
| **Active** | Recent commits or has uncommitted changes |
## Step 2 — Find stale local branches
First, prune remote-tracking references so git knows which remote branches are gone:
```bash
git fetch --prune
```
Determine which branches must **never** be flagged as orphans:
```bash
# The repo's default branch (main, master, develop, trunk, …) — de