๐งน #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.
Predicate breakdown โ ALL four must hold to sweep
| # | Predicate | Why |
| 1 | name matches <repo>-* | Only orchestkit-`*` siblings โ never touch unrelated dirs |
| 2 | NOT in git worktree list | Real worktrees are registered; orphans aren't |
| 3 | zero regular files | .DS_Store and Thumbs.db ignored; nested empty dirs OK |
| 4 | mtime > 1 hour old | Race 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