Project memory & chat history are keyed by absolute path — moving a project dir silently orphans both

Open 💬 6 comments Opened Jun 20, 2026 by autophiliac

What

Claude Code keys both persistent project memory (~/.claude/projects/<mangled-absolute-path>/memory/) and chat history off the project's absolute working-directory path. Move or rename the project folder and the key changes, so a fresh session at the new path loads empty memory/history while the old data is stranded under the now-dead path key.

Why it's a problem

Moving a project directory is a normal, expected operation — reorganising, migrating off a cloud-sync mount, renaming. Absolute-path keying turns it into silent data loss for long-running agents: no warning, no migration path, no fallback.

Real-world hit

During a planned migration (a OneDrive sync mount → ~/Sync), a long-running agent's persistent memory got split across two path-keyed directories: the full set + index remained under the old (now dead) path key, while the new path key held almost nothing. The index developed a broken cross-reference, and a fresh session launched from the new path would have loaded a near-empty memory set — exactly when continuity matters most (handing off to a successor session). It was only caught by a manual audit.

Suggested fixes (any one would help)

  1. A first-class migrate command — claude memory migrate <old> <new> (and the same for history).
  2. Key off a stable project id (e.g. a .claude/project-id file, or the git remote/root) instead of the raw absolute path.
  3. Detect a moved repo (same git root / same .git) and offer to relink the existing memory + history.
  4. Minimum viable: on session start in a directory with no memory, warn if a sibling path-key looks like a renamed/moved version of it.

Environment

Claude Code on macOS (darwin 24.6.0).

View original on GitHub ↗

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