๐Ÿงน #1884 stale-worktree sweep โ€” predicate playground

SessionStart hook that removes sibling directories matching <repo-name>-* left behind by aborted git worktree add attempts (truncation, OOM, force-quit). Without this, the next session's git worktree add fails with "already exists" and needs manual rm -rf. Toggle the four predicates below to see when the sweep fires.

Toggle the predicate inputs

SWEEP โ†’ rmSync(path, recursive: true)

Predicate breakdown โ€” ALL four must hold to sweep

#PredicateWhy
1name matches <repo>-*Only orchestkit-`*` siblings โ€” never touch unrelated dirs
2NOT in git worktree listReal worktrees are registered; orphans aren't
3zero regular files.DS_Store and Thumbs.db ignored; nested empty dirs OK
4mtime > 1 hour oldRace protection โ€” don't kill a worktree-add that's mid-flight

Opt-out

$ ORK_NO_STALE_SWEEP=1 claude
# Skips the hook entirely. Useful if you have known empty -* dirs you
# want to keep (e.g. you're staging a worktree-add manually).

The exact case that motivated this PR

$ ls coding/yonatangross/orchestkit-build-diag
.DS_Store

$ find coding/yonatangross/orchestkit-build-diag -maxdepth 3 -type f
.../orchestkit-build-diag/.DS_Store
# 1 file (just Finder metadata) โ€” qualifies as "empty" once .DS_Store ignored
# created May 20 17:22, "now" May 20 22:36 โ†’ 5h+ old โœ“
# not in `git worktree list` โœ“
# pattern matches `orchestkit-*` โœ“
# โ†’ SWEEPS on next SessionStart