Session metadata keeps a stale worktreePath/worktreeName after the worktree directory is removed

Open
#95,723 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
cli, tooling

Research direction

Start with the get_session and list_sessions entry points, then trace how EnterWorktree and clean_up_worktrees update session metadata. Reproduce the issue by removing a worktree and querying the session afterward. Done means sessions no longer report worktreePath or worktreeName when the directory has been removed, while existing worktree metadata remains available when valid.

Written by the indexing model from the issue text.

Description

area:core bug

Description

get_session (and the list_sessions entries) continue reporting a worktreePath/worktreeName for a session even after that worktree directory has been removed from disk (e.g. after the branch's PR merges and the worktree is cleaned up, either manually with git worktree remove or via the app's own cleanup). This was observed across multiple completed sessions in the same project:

  • A session with a merged PR still reports worktreePath: /path/.claude/worktrees/intelligent-wright-1c891a — directory confirmed absent on disk, branch confirmed deleted both locally and on origin.
  • Same pattern for another session with a different merged PR.
  • A third session (no PR, never touched the codebase — used only for scheduling a reminder via the /schedule skill) also still reports a worktreePath for a directory that no longer exists.

By contrast, at least one other session in the same project (also a merged PR) correctly has no worktreePath field at all — so the metadata can get cleared, just not consistently.

Impact

Low severity — no data loss observed, since in every case the underlying git work was already safely merged (or, for the scheduling-only session, never existed). But it's misleading: reading session metadata suggests a worktree is still there to resume into, when in fact resuming would presumably need to recreate it from scratch (or silently fail if the branch is also gone).

Repro sketch

  1. Start a session with EnterWorktree (or the app's normal per-task worktree flow).
  2. Merge its PR and remove the worktree (git worktree remove, or via the app's clean_up_worktrees / manual removal).
  3. Call get_session on that session later — worktreePath is still present and points at a now-nonexistent directory.
Dominant language
TypeScript
Stars
147k
Forks
24k
PR merge metrics
PR metrics pending

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.