Repository navigation
Add worktree and OrbStack modules to disk-cleanup - #266
Merged
Merged
Conversation
The worktrees module lists worktree directories that no git repo tracks and worktrees whose PR merged. With --aggressive it removes leftover directories that hold no checkout, and merged worktrees that would lose nothing: no changes or commits after the merge, no ignored files beyond build output, no open Supacode tab, and no process working in them. Checkouts git no longer tracks are only listed, because git cannot tell whether they hold edits. The orbstack module lists data images OrbStack set aside as corrupt and removes them with --aggressive. Claude-Session: https://claude.ai/code/session_01AovXvYZu2bc85xrmWjjkz2
haacked
marked this pull request as ready for review
October 28, 2026 22:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My disk filled up, partly with worktrees nothing cleans up. Supacode's merged-worktree action is off, so worktrees stay after their PR merges. Some deletions also left directories behind. In posthog worktrees created before its flox manifest set
GOFLAGS=-modcacherw,git worktree remove --forcefails partway on the read-only Go module cache in.flox/cache/go. It drops git's record of the worktree and leaves the files. OrbStack also left a 16Gdata.img.raw.corruptafter a disk-image recovery.This adds two
disk-cleanupmodules.worktreeslists directories under the worktree roots that no git repo tracks, plus worktrees whose PR merged.orbstacklists corrupt OrbStack data images. Both only list by default and delete with--aggressive.The deletion rules lean toward keeping things. A checkout git no longer tracks is only listed, because git can't tell whether it holds edits.
--aggressivedeletes only leftover directories with no.gitinside. A merged worktree stays when it has an open Supacode tab, a process working in it, changes or commits after the merged head, ignored files that aren't build output (such as.notes/or.env), skip-worktree flags, a nested checkout, or a lock Supacode doesn't hold. The module makes directories writable before removing them, so a read-only Go cache can't stop a removal partway.tree-me removeandgit-bclean-localdon't make read-only directories writable yet. The merged check callsghonce per worktree, so a run takes about 40 seconds.Test plan
bin/lib/test-cleanup-worktrees.sh(79 assertions) andbin/lib/test-cleanup-orbstack.sh(7) pass under macOS/bin/bashdisk-cleanup --module worktreeslists real orphans and merged worktrees, and keeps worktrees with open Supacode tabs or.notes/disk-cleanup --module worktrees --aggressiveand confirm only the listed directories go awayhttps://claude.ai/code/session_01AovXvYZu2bc85xrmWjjkz2