Sessions are tied to cwd path, breaking --resume after directory rename
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:
/resumefrom the new path returnsNo conversations found to resume.claude --continuefrom the new path returnsNo conversation found to continue.claude --resume <session-id>returnsNo conversation found with session ID: <id>, even though the file still exists on disk under the old slug.
Reproduction
- Start a session in
~/work/foo, do some work. - Exit Claude Code.
mv ~/work/foo ~/work/barcd ~/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:
- On session start, append the session ID to
<git-root-or-cwd>/.claude/sessions(a plain newline-separated text file of UUIDs). - On
/resumeand--continue, read that pointer file first; fall back to today's cwd-slug lookup if absent. - For
--resume <id>, do a global scan of~/.claude/projects/**/<id>.jsonlso 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
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗