Sessions are tied to cwd path, breaking --resume after directory rename

Resolved 💬 3 comments Opened May 20, 2026 by jakshi Closed May 24, 2026

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

View original on GitHub ↗

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