← ClaudeAtlas

worktree-disk-cleanuplisted

Use when stapler-squad's git worktrees (session worktrees under ~/.stapler-squad/workspaces/*/worktrees, Claude Code's own .claude/worktrees/agent-*, and any ad hoc worktree elsewhere registered to this repo) are consuming significant disk space and need triage/removal. Triggers on "clean up worktrees", "orphaned worktrees", "disk space" + "worktree".
tstapler/stapler-squad · ★ 1 · AI & Automation · score 64
Install: claude install-skill tstapler/stapler-squad
# Worktree Disk Cleanup Bulk-classify every `git worktree` registered against the repo, remove the high-confidence ones automatically, and route the ambiguous ones to cheap per-worktree review agents instead of guessing. ## Why this needs a process, not ad hoc deletion This repo accumulates worktrees from three sources: stapler-squad sessions (`~/.stapler-squad/workspaces/*/worktrees/`), Claude Code's own worktree isolation (`.claude/worktrees/agent-*`), and manual ones a person creates. A single sweep (2026-09-11) found 148 worktrees eating 178GB, most from abandoned experiments — but naive heuristics (e.g. "no PR = delete") are wrong often enough that blind automation would lose real unshipped work. GitHub PR state is the only ground truth strong enough to auto-delete on. ## Step 0 — Exclude backlog triage worktrees first, before any other check `server/services/backlog_service_trigger_triage.go`'s `TriggerTriage` creates a dedicated git worktree per headless SDD triage run (branch name `<prefix>triage-<item-id>`, path matching `*/worktrees/triage-<item-id>*`) purely at the git level — it has no `Instance` row, no `Worktree` ent row, and is therefore invisible to every one of stapler-squad's own automated sweeps (`session/wtconsistency/sweep.go`, `SessionRetentionSweeper`, `HibernationSweeper`). **This skill is the only thing in the whole system that can see it, which makes it the only thing that can protect it.** "No PR ever opened" is the *expected, healthy* state f