Worktree and simulator cleanup
You own the disk and the safety gate. Prune merged or abandoned git worktrees and stale iOS simulators to reclaim space. Deletion is irreversible, so every step guards against deleting something in use or holding uncommitted work.
- Snapshot and audit. Record
df -h /, then runscripts/worktree-audit.sh(principle-build-the-lever). It reads paths fromgit worktree list, never hand-typed, since a hand-typedmyrepo-worktrees/xmisses one that lives at.cursor/worktrees/myrepo/x(principle-encode-lessons-in-structure). It classifies each worktree by size, age, merge state, uncommitted work, PR state, and the newest chat that touched it, then suggests a bucket. The transcript scan is slow, so background it. - The bucket is advice, not permission. The pinned and active chats are the real artifact (principle-prove-it-works). Get that set from the user or sidebar and cross-check every candidate. The lever has marked
safea worktree the user had pinned, so the pinned set wins. - Verify usage before deleting. For every
verify-recent-chatrow, or anything you doubt, fan subagents out to read the transcripts and report whether the chat is pinned or ongoing and which worktrees it touches (principle-guard-the-context-window, transcripts are bulk). A pinned chat spawns arena and repro trees into sibling worktrees via background subagents, and those are in use even when their names never hit the sidebar. - Pause on irreversible loss.
wip:Nis N tracked uncommitted edits. Show the diff and get a decision first, since removing a clean worktree is recoverable from its branch but uncommitted work is gone.scratch:Nis untracked throwaway, safe to drop, but name the files. Per Autonomy, clean and merged and not-in-use proceeds.wipand in-use pause. - Prune the confirmed set. Per path,
git worktree remove --force <path>. If the dir survives on ignored build artifacts,rm -rfit, thengit worktree prune. Branch refs survive, so no commits are lost. Confirm withdf -h /and re-list. - Simulators and other reclaimers. Simulators are usually the next-biggest win.
xcrun simctl --set testing delete all(XCTestDevices clones),xcrun simctl delete unavailable, andxcrun simctl runtime listthenruntime delete <id>for old runtimes. More when needed: XcodeDerivedDataandiOS DeviceSupport,~/Library/Application Support/Cursor(state.vscdb.backup, andsnapshots/roots/<root>where a<root>named for a folder you opened as a workspace balloons), package caches (pnpm, uv, brew, yarn). Clear only caches the user has not said to keep.
This is the one playbook that deletes user state with no code review to catch a slip, so the gates above are the review.
Reply: df -h / before and after with space reclaimed, the worktrees pruned, and a one-line reason for each held back (in-use by which chat, or uncommitted work).