/clear errors with 'Path does not exist' when referenced worktree directory was removed
Resolved 💬 0 comments Opened Jun 24, 2026 by kyle-enobleon Closed Jun 24, 2026
Summary
Running /clear in a session fails with:
Error: Path "/Users/kyleroot/Code/eNobleon/data-forge/.claude/worktrees/350-emit-per-stage-completion-events" does not exist
The referenced worktree directory has since been cleaned up (the parent .claude/worktrees/ is empty), but /clear still tries to resolve it and bails out instead of recovering gracefully.
Steps to reproduce
- Start a session inside a Claude Code-managed worktree under
.claude/worktrees/<slug>/. - Remove that worktree directory (e.g. after the work merges and the worktree is cleaned up).
- From any session that still references the removed path, run
/clear. /clearerrors instead of clearing.
Expected
/clear should either:
- detect the missing path and clear anyway, or
- detect the missing path and emit a recoverable warning while still clearing session state.
Actual
/clear aborts with a hard error and the session can't be cleared.
Environment
- Claude Code:
2.1.153 - macOS (Darwin 25.5.0)
- Shell: zsh
- Repo state at time of error:
- cwd:
/Users/kyleroot/Code/eNobleon/data-forge .claude/worktrees/exists but is emptygit worktree listshows only the main checkout
Notes
This looks like stale state being persisted somewhere (possibly the session/transcript file) pointing at a worktree path that has since been removed. A defensive existence check before the path is consumed by /clear would fix it.