Relocating a project dir (symlink / new mount) orphans all session history, memory & context — project keyed by raw cwd path

Open 💬 2 comments Opened Jun 26, 2026 by nfodor

Summary

Claude Code stores per-project state (session transcripts, MEMORY.md, todos, scratchpad) under ~/.claude/projects/<slug>, where <slug> is derived from the literal absolute working-directory path. When a project's directory is relocated — e.g. ~/dev becomes a symlink to an external drive /Volumes/SanDisk2/dev, or the tree is moved to a new mount — Claude Code treats it as a brand-new project. The entire prior session history, memory, and context are orphaned under the old path slug, and storage fragments across multiple slugs (-Users-<user>-dev-... vs -Volumes-SanDisk2-dev-...) for what is the same repo.

Repro

  1. Have a project at ~/dev/foo with accumulated session history + MEMORY.md.
  2. Move ~/dev to an external drive and symlink it back (~/dev -> /Volumes/SanDisk2/dev), or otherwise reach the same project via a different absolute path.
  3. Start Claude Code in the project.
  4. A new ~/.claude/projects/<new-slug> is created; prior sessions / memory / todos under the old slug are not carried over; the same conversation can even appear under two different slugs.

Impact

  • Continuity loss across all projects after a directory move.
  • MEMORY.md and recalled context silently not applied (they live under the old slug).
  • Duplicated/fragmented project dirs; very confusing.
  • Compounds with git: stale remote-tracking refs after the move fake "N commits ahead / diverged" until git fetch, and fatal: not a git repository ... GIT_DISCOVERY_ACROSS_FILESYSTEM not set errors appear for repos under the /Volumes mount.

Suggested fix

Key project identity by something stable instead of the raw cwd path:

  • resolve symlinks / realpath consistently when computing the project slug, and/or
  • derive identity from the git remote URL or a persisted .claude/project-id, and/or
  • detect when the same repo appears under a new path and offer to migrate/merge the existing project storage.

Environment

  • macOS (darwin), Claude Code CLI.
  • ~/dev symlinked to an external volume /Volumes/SanDisk2/dev.

View original on GitHub ↗

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