claude-code - 💡(How to fix) Fix Sessions are tied to cwd path, breaking --resume after directory rename

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…

Fix Action

Fix / Workaround

The transcript is still at ~/.claude/projects/-Users-me-work-foo/<id>.jsonl. The only workaround today is to manually mv the jsonl into the new slug directory and sed the embedded cwd paths inside the file.

RAW_BUFFERClick to expand / collapse

Problem

Claude Code stores session transcripts in ~/.claude/projects/<slug-derived-from-cwd>/<session-id>.jsonl, where the slug is the cwd path with / replaced by -. Both /resume (UI) and claude --resume <session-id> look up sessions via this cwd-derived slug.

This means renaming or moving the working directory orphans every prior session for that project:

  • /resume from the new path returns No conversations found to resume.
  • claude --continue from the new path returns No conversation found to continue.
  • claude --resume <session-id> returns No conversation found with session ID: <id>, even though the file still exists on disk under the old slug.

Reproduction

  1. Start a session in ~/work/foo, do some work.
  2. Exit Claude Code.
  3. mv ~/work/foo ~/work/bar
  4. cd ~/work/bar && claude --resume <id> → "No conversation found".

The transcript is still at ~/.claude/projects/-Users-me-work-foo/<id>.jsonl. The only workaround today is to manually mv the jsonl into the new slug directory and sed the embedded cwd paths inside the file.

Why this is surprising

--resume <session-id> reads like a global lookup by a content-addressable key (the UUID), but it's actually scoped by cwd. Users reasonably expect a UUID-keyed flag to work from anywhere.

Proposed fix (minimal)

Decouple session lookup from cwd path. One small-footprint option:

  1. On session start, append the session ID to <git-root-or-cwd>/.claude/sessions (a plain newline-separated text file of UUIDs).
  2. On /resume and --continue, read that pointer file first; fall back to today's cwd-slug lookup if absent.
  3. For --resume <id>, do a global scan of ~/.claude/projects/**/<id>.jsonl so the UUID is a true global key.

Properties of this design:

  • Pointer file is KB-sized, just UUIDs — safe to commit, sync, or .gitignore.
  • No secrets leave ~/.claude/.
  • Backward compatible: existing slug-based layout is preserved as a fallback.
  • Survives mv, git mv, worktree clones, symlinks.
  • Non-git dirs simply fall back to current behavior.

Alternative

Key the session directory by git remote get-url origin hash instead of cwd path, falling back to cwd slug for non-git dirs. Rename-proof for the common (git) case.

Environment

  • Claude Code CLI
  • macOS (Darwin 25.4.0), bash

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING