[BUG] Exit-time resume hint silently skipped when session exits inside a .claude/worktrees/ worktree (transcript check uses cwd-at-exit)
What's Wrong?
On a normal exit, Claude Code prints a resume hint:
Resume this session with:
claude --resume <session-id>
If the session ends while inside a worktree created by the EnterWorktree tool (cwd under <repo>/.claude/worktrees/<name>), the hint is silently skipped. The user sees only:
✢ Cleaning up worktree (no pending changes)…
The session is fully resumable (claude --resume <id> from the launch dir works; it appears in the /resume picker) — only the printed hint is lost, which makes it look like the feature was removed.
Root cause (from reading the bundled source, v2.1.162)
Before printing, the shutdown hint handler verifies the session transcript exists:
function NW_(H){let _=AC()??GY(X8()),q=wJ.join(_,`${H}.jsonl`); /* ... statSync(q) ... */}
The fallback derives the projects dir from the cwd at exit (GY(X8())). Transcripts are stored under the original launch directory's project key. For a session that entered a worktree:
- transcript:
~/.claude/projects/<parent-repo-key>/<id>.jsonl✅ exists - checked path:
~/.claude/projects/<parent-repo-key>--claude-worktrees-<name>/<id>.jsonl❌ statSyncthrows → the hint function returns silently inside its try/catch
Note the user's shell never actually left the launch directory (the worktree cd is internal to the claude process), so the hint would be valid and copy-pasteable — the cwd-based existence check is just looking in the wrong place.
Steps to Reproduce
claudein any git repo- Have the agent call
EnterWorktree(e.g. "create a worktree named t1") /exitwhile still in the worktree
Expected: Resume this session with:\nclaude --worktree t1 --resume <id>
Actual: no hint printed (only the worktree-cleanup spinner line).
Control A — same repo, no worktree: /exit prints the hint normally.
Control B — EnterWorktree → ExitWorktree (keep) → /exit: hint prints correctly, including the --worktree t1 flag. This proves the hint path intends to support worktree sessions — the suppression is a side effect of the wrong path derivation, not a design branch.
Reproduced on both the keep and remove cleanup paths; what matters is cwd still being the worktree at shutdown.
Not a duplicate of
- #28314 / #28769 / #32794 / #55128 — those are about the hint printing with wrong or unusable content (missing/extra
--worktreeflag, cleaned-up worktree). Here the hint does not print at all. - #42596 — that's about Agent-tool
isolation: "worktree"subagent sessions being transient/non-resumable. Here the main interactive session is resumable; only the hint is suppressed. - #48835 / #30906 — resume-time failures. This report is exit-time only.
Suggested fix
Resolve the transcript path from the session's recorded original project dir (the same source the transcript writer uses) rather than cwd-at-exit — or skip the existence check when the session is known persisted.
Environment
- Claude Code v2.1.162 (native build, macOS / Darwin 25.3.0)
- Same code shape present in 2.1.146 — not a recent regression, but newly visible to anyone adopting per-session worktree workflows
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗