[Bug] Agent removal fails with misleading "WorktreeRemove hook failed" error when hookBased worktree lacks originalHeadCommit
Bug Description
in claude agents mode, failure when c-x c-x to remove an agent. here's claude's diagnosis:
What's actually happening: this is not your WorktreeRemove hook failing. That script (~/.claude/hooks/worktree-remove.sh) exits 0 on every path — it can't fail. It's the known Claude Code defect I hit on 2026-07-24: worktrees created via the WorktreeCreate hook get a session record with hookBased: true and no originalHeadCommit (verified again just now in ~/.claude.json — the active claude-md-slim record has exactly that shape). The CLI's removal path can't verify worktree state without that commit, refuses to remove, and surfaces the misleading "WorktreeRemove hook failed" toast. Not fixable from the hook side — the hook contract only lets it print a path.
Environment Info
- Platform: darwin
- Terminal: xterm-256color
- Version: 2.1.220
- Feedback ID: dc8dc6d8-3439-4e0a-8ea0-358928dd1340
Errors
[]