Files
skills/skills/kvb-cleanup/worktrees.md
T
Kevin Veen-Birkenbach 7199e6bfba feat(kvb-cleanup): take the inventory from pkgmgr gc --report
The /tmp inventory starts from one read-only pkgmgr gc --report pass over /tmp and the write-scope dirs, du -sh only without pkgmgr. The worktree-orphans rule moves into worktrees.md, keeping SKILL.md under its 600-word cap at unchanged token cost.

🎯 Fix: 95 %
💥 Break: 2 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ad2e97aae428fe23e3a4828776ff045766ff9722)
2026-11-12 10:38:54 +00:00

1.3 KiB

Worktrees

Inventory

Per worktree: size (du -sh), dirty state, whether its branch is pushed and whether its HEAD is in an integration line (the default branch and every branch the project merges features into; ask the operator or the project's memory). With pkgmgr, pkgmgr gc --json --sizes --merged-into <line> (one per line) measures it all; its candidates go to the kvb-git-gc skill. At warn or worse, or with worktrees on top of the report, add the largest of kvb-git-worktree-orphans --sizes.

Clean and in a line: medium, its ignored files (node_modules, build output, evidence) are lost. Dirty: a candidate only when every changed, staged and untracked file is a blob at some branch tip and a detached HEAD is reachable from another ref; else it is unique work and stays.

Removal

The way it was made: a slot worktree through the project's teardown target (e.g. make worktree-down), a sidetree through git worktree remove, --force only for a dirty one cleared above. Never in an agent sandbox: its read-only .git/worktrees/<id> mounts make git unregister and then fail with Device or resource busy, container-owned files with Permission denied. Hand the operator in one message, per worktree, its count of find <wt> -not -user "$USER" -prune | wc -l, sudo chown -R "$USER": <wt> where it is not 0, then the removal command.