claude-code - 💡(How to fix) Fix [BUG] claude --resume <id> cannot find intact transcript after original worktree path is removed [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#57920Fetched 2026-05-11 03:21:55
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

claude --resume <session-id> fails with No conversation found with session ID: <id> after the original project/worktree directory has been removed, even though the transcript JSONL is still present on disk and contains the matching sessionId.

Recreating an empty directory at the original path is sufficient to make the same --resume command find and resume the same transcript again. No git metadata or project files are required in the recreated directory.

This appears related to #5768, but the failure mode here is specifically that deleting or moving the original cwd can orphan an otherwise valid transcript that Claude Code itself still keeps under ~/.claude/projects/.

Root Cause

This affects workflows that use disposable project directories or git worktrees. The CLI prints claude --resume <id> as the continuation affordance, but that command can become unusable after ordinary cleanup even though the transcript still exists and is identifiable by its UUID.

Code Example

set -euo pipefail

# 1. Set up a throwaway repo and worktree.
BASE="/tmp/cc-resume-repro"
rm -rf "$BASE"
mkdir -p "$BASE/repo"
cd "$BASE/repo"
git init -q -b main
echo repro > README.md
git add README.md
git -c user.email=test@test -c user.name=test commit -q -m init
git worktree add -q ../wt

# 2. Start a non-interactive Claude Code session inside the worktree.
cd ../wt
claude -p "say the word pong and nothing else"
# -> pong

# 3. Locate the transcript. On macOS, /tmp may canonicalize to /private/tmp.
REAL_WT="$(pwd -P)"
PROJECT_DIR="$HOME/.claude/projects/${REAL_WT//\//-}"
SID="$(basename "$(ls -t "$PROJECT_DIR"/*.jsonl | head -n 1)" .jsonl)"
echo "$SID"

# 4. Confirm the transcript contains the matching sessionId.
rg "\"sessionId\":\"$SID\"" "$PROJECT_DIR/$SID.jsonl"

# 5. Remove the worktree.
cd "$BASE/repo"
git worktree remove ../wt

# 6. Confirm the transcript JSONL is still on disk.
ls "$PROJECT_DIR/$SID.jsonl"

# 7. Try to resume from a different cwd.
cd /tmp
claude --resume "$SID" -p "still there?"
# -> No conversation found with session ID: <SID>

# 8. Recreate the original path as an empty directory.
mkdir -p "$BASE/wt"
cd "$BASE/wt"
find . -maxdepth 1 -mindepth 1 -print
# -> no output

# 9. Resume the same session from that empty directory.
claude --resume "$SID" -p "reply with only the word yes"
# -> yes
RAW_BUFFERClick to expand / collapse

Summary

claude --resume <session-id> fails with No conversation found with session ID: <id> after the original project/worktree directory has been removed, even though the transcript JSONL is still present on disk and contains the matching sessionId.

Recreating an empty directory at the original path is sufficient to make the same --resume command find and resume the same transcript again. No git metadata or project files are required in the recreated directory.

This appears related to #5768, but the failure mode here is specifically that deleting or moving the original cwd can orphan an otherwise valid transcript that Claude Code itself still keeps under ~/.claude/projects/.

Environment

  • Claude Code: 2.1.138
  • macOS: Darwin 24.6.0
  • Shell: zsh / bash
  • Git worktree created under /tmp (/private/tmp after macOS path canonicalization)

Reproduction

set -euo pipefail

# 1. Set up a throwaway repo and worktree.
BASE="/tmp/cc-resume-repro"
rm -rf "$BASE"
mkdir -p "$BASE/repo"
cd "$BASE/repo"
git init -q -b main
echo repro > README.md
git add README.md
git -c user.email=test@test -c user.name=test commit -q -m init
git worktree add -q ../wt

# 2. Start a non-interactive Claude Code session inside the worktree.
cd ../wt
claude -p "say the word pong and nothing else"
# -> pong

# 3. Locate the transcript. On macOS, /tmp may canonicalize to /private/tmp.
REAL_WT="$(pwd -P)"
PROJECT_DIR="$HOME/.claude/projects/${REAL_WT//\//-}"
SID="$(basename "$(ls -t "$PROJECT_DIR"/*.jsonl | head -n 1)" .jsonl)"
echo "$SID"

# 4. Confirm the transcript contains the matching sessionId.
rg "\"sessionId\":\"$SID\"" "$PROJECT_DIR/$SID.jsonl"

# 5. Remove the worktree.
cd "$BASE/repo"
git worktree remove ../wt

# 6. Confirm the transcript JSONL is still on disk.
ls "$PROJECT_DIR/$SID.jsonl"

# 7. Try to resume from a different cwd.
cd /tmp
claude --resume "$SID" -p "still there?"
# -> No conversation found with session ID: <SID>

# 8. Recreate the original path as an empty directory.
mkdir -p "$BASE/wt"
cd "$BASE/wt"
find . -maxdepth 1 -mindepth 1 -print
# -> no output

# 9. Resume the same session from that empty directory.
claude --resume "$SID" -p "reply with only the word yes"
# -> yes

Expected behavior

When an explicit session ID is passed to --resume, Claude Code should be able to resolve the transcript for the lifetime of the transcript file. Reasonable implementations would include:

  • treating the session ID / JSONL filename as globally unique and resolving it across ~/.claude/projects/;
  • falling back to a global scan when the cwd-derived project directory does not contain the requested session; or
  • storing enough session metadata to make the printed claude --resume <id> continuation command independent of whether the original project directory still exists.

Actual behavior

--resume <id> only finds the transcript when the current cwd maps to the same path-encoded project directory that contains the JSONL.

In the reproduced case:

  • transcript remained at ~/.claude/projects/-private-tmp-cc-resume-repro-...-wt/<SID>.jsonl;
  • the JSONL contained the matching sessionId;
  • claude --resume <SID> from /tmp failed with No conversation found with session ID: <SID>;
  • creating an empty directory at the original worktree path made the same --resume <SID> succeed.

Why this matters

This affects workflows that use disposable project directories or git worktrees. The CLI prints claude --resume <id> as the continuation affordance, but that command can become unusable after ordinary cleanup even though the transcript still exists and is identifiable by its UUID.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When an explicit session ID is passed to --resume, Claude Code should be able to resolve the transcript for the lifetime of the transcript file. Reasonable implementations would include:

  • treating the session ID / JSONL filename as globally unique and resolving it across ~/.claude/projects/;
  • falling back to a global scan when the cwd-derived project directory does not contain the requested session; or
  • storing enough session metadata to make the printed claude --resume <id> continuation command independent of whether the original project directory still exists.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] claude --resume <id> cannot find intact transcript after original worktree path is removed [2 comments, 2 participants]