Refuse to reap a checkout with uncommitted work unless forced #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "guard-reap-dirty-worktree"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while reaping four real workspaces.
The hole
spawn reapguarded your commits but not your working tree. It passedherdr worktree remove --forceunconditionally, so uncommitted and untracked files were discarded silently.That's backwards. Unfinished work is precisely the work that hasn't been committed yet — the working tree deserved the stronger guard, not the weaker one.
Every one of the four workspaces I reaped happened to be clean, so nothing was lost. But that was luck. I'd been running
git statusby hand before each reap, which is exactly the check the tool should be doing itself.The fix
Refuse a dirty checkout, list the offending paths (capped at 10), require explicit
--force:Uses
--untracked-files=all, so a brand-new file the agent wrote but never added still counts. Same shape as the existing branch guard: safe by default, destructive only when asked.Verification
--force--forcespawn selftest/openspec validate --allSpec gains two scenarios on the reap requirement.
Context
Reaped this session with the pre-fix version, all verified clean by hand first:
w1Gcpanel-rollout,w1Jtypechecking-modules,w18access-control-lists-slice-1,w1Fcelilo-deployment-cleanup. Work ondict-2(10 commits),e2e-audit(5),audit-fleet-rollout(2) andfix-prod-smoke-failures(1) was left untouched.🤖 Generated with Claude Code