Skip to content

feat: add scanner for stale and orphaned git worktrees - #74

Merged
guhcostan merged 1 commit into
guhcostan:mainfrom
yahorbarkouski:feat/git-worktrees-scanner
Aug 3, 2026
Merged

feat: add scanner for stale and orphaned git worktrees#74
guhcostan merged 1 commit into
guhcostan:mainfrom
yahorbarkouski:feat/git-worktrees-scanner

Conversation

@yahorbarkouski

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a new git-worktrees scanner that finds stale and orphaned git worktrees left behind by agents and local feature checkouts. These often contain full dependency trees and can reclaim tens of gigabytes, but were invisible to existing cache/node_modules scanners.

Discovery combines a deep home crawl with git worktree registries (so registered worktrees outside the crawl path are still found), plus dedicated agent roots (~/.cursor/worktrees, ~/.claude/worktrees, ~/.codex/worktrees).

The interactive picker and verbose scan output now show a detail column with relative age (17d ago) or orphaned.

Type of change

  • Bug fix
  • New feature (new scanner, command, or option)
  • Improvement to existing feature
  • Chore / dependency update
  • Documentation

Related issue

N/A

Checklist

  • bun run lint passes
  • bun run test passes (no regressions)
  • bun run build succeeds
  • New tests added for new behavior
  • I've tested this on macOS locally

Notes for reviewer

  • Category is risky with supportsFileSelection, so cleanup requires --risky / --unsafe and can be narrowed per worktree.
  • Stale = linked worktree directory mtime older than 7 days; orphaned = gitdir: target missing (always reported).
  • Primary checkouts (.git directories) are never offered for deletion.
  • Sizing uses /usr/bin/du -sk with a JS fallback for speed on large trees.

Usage

mac-cleaner-cli scan -c git-worktrees --verbose
mac-cleaner-cli --risky
mac-cleaner-cli clean -c git-worktrees --unsafe --dry-run

Made with Cursor

Agent and feature worktrees often leave multi-GB checkouts invisible to
existing cache scanners. Discover them via deep home crawl plus git
worktree registries, and surface age/orphan details in interactive selection.
@yahorbarkouski

yahorbarkouski commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

was super useful personally so decided to check if it will help anyone else, let me know if looks good kind man @guhcostan

image

@guhcostan
guhcostan merged commit 9bc7c61 into guhcostan:main Aug 3, 2026
5 checks passed
@guhcostan

Copy link
Copy Markdown
Owner

Thank you @yahorbarkouski!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants