[BUG] End-of-session resume hint includes --worktree flag that fails when session crossed into a nested repo's worktree

Resolved 💬 2 comments Opened Apr 30, 2026 by loganrosen Closed Jun 1, 2026

What's Wrong?

When a session is started in a parent repo and cds into a worktree of a nested repo during the session, the end-of-session resume hint includes --worktree <name>, but that command fails with "No conversation found".

The session JSONL is stored under the parent repo's project key (where claude was originally launched), so the printed --worktree flag points Claude Code to look up the session under a project key that doesn't exist.

This is the inverse of #28769 (closed): there, the hint printed without --worktree when one was needed; here, the hint prints with --worktree when it shouldn't.

What Should Happen?

The printed resume command should actually work when copy-pasted. Either:

  • Don't include --worktree in the hint when the session was launched from the parent (not the worktree), or
  • Store the session under the worktree's project key if --worktree is going to be in the hint

Steps to Reproduce

  1. Have a parent repo ~/parent that contains a nested repo at ~/parent/nested
  2. Create a worktree inside the nested repo, e.g. ~/parent/nested/.claude/worktrees/feature-x
  3. From ~/parent, launch claude
  4. During the session, work happens in the nested repo's worktree (cwd moves to ~/parent/nested/.claude/worktrees/feature-x)
  5. Exit. Claude prints:

``
Resume this session with:
claude --worktree feature-x --resume <session-id>
``

  1. Run that exact command from ~/parentNo conversation found with session ID: <id>
  2. Drop --worktree and it resumes fine: claude --resume <session-id>

Investigation

The session JSONL lives at ~/.claude/projects/-Users-<me>-parent/<session-id>.jsonl (parent repo's project key) — confirmed by inspecting the file and the recorded cwd entries, which span both /Users/<me>/parent and /Users/<me>/parent/nested/.claude/worktrees/feature-x.

Compounding: if the same worktree name exists in both the parent and nested repos, --worktree <name> is ambiguous on its own.

Likely related to the worktree path resolution logic discussed in #45179.

Claude Code Version

2.1.123

Platform

Anthropic API

OS

macOS (Darwin 25.4.0)

Related

  • #28769 (closed) — inverse symptom (missing --worktree in hint)
  • #45179 (open) — /resume picker breaks with submodule + secondary worktree; same code path likely involved

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗