[FEATURE] Session/chat history and memory in Claude Code are keyed entirely to the project folder's absolute filesystem path, with no way to preserve continuity when the folder is moved or renamed.
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Claude Code stores project session data under ~/.claude/projects/<encoded-path>/, where <encoded-path> is derived directly from the working directory's absolute path (e.g., C:\Support_Work\Cases\... becomes c--Support-Work-Cases-...). If the underlying folder is later moved or renamed — even without any change to its contents — Claude Code computes a different encoded path and can no longer locate the previous session history or memory. The old data isn't deleted, but it becomes orphaned and inaccessible from the new location.
Impact:
This makes it risky to reorganize folder structures (e.g., renaming a case folder as a support ticket evolves, or moving a project into a different directory tree) without manually losing access to accumulated chat history and memory. There's currently no supported flag, settings.json key, or environment variable to pin a stable project identity independent of the literal path.
Workaround currently in use: none reliable; keeping folder paths static once a session has started, or manually copying the ~/.claude/projects/<old-slug>/ contents to a newly-computed slug after a rename.
Proposed Solution
Consider decoupling session/memory identity from the raw filesystem path — for example, via a small marker file (similar to .git) written into the project directory at first use, containing a stable project ID that Claude Code checks for before falling back to path-based lookup. This would let a project retain its history and memory even after being moved or renamed, as long as the marker file moves with it.
Alternative Solutions
_No response_
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
I open VS Code to work on a local folder code.
I start a chat working in that folder.
I then determine the folder needs to reside in a different location and have to move it.
The chat that had been stored with that work is now lost.
Additional Context
_No response_
3 Comments
Strongly support decoupling project identity from the absolute path. A few additions that broaden the case:
**1. The encoding is also lossy / non-injective — it can silently collide, independent of any move.** Every
/becomes-, which isn't reversible and maps distinct paths to the same key:Directory names containing
-are completely normal, so this isn't hypothetical. A reversible encoding (percent-encode, or hash the absolute path) would at least be correct; the deeper fix is not keying on the path at all, per this issue.2. Worktrees already break this today — and it was reported and closed as not-planned (#33665). There the session writer keys on
cwdwhile memory and/resumekey ongit rev-parse --git-common-dir, so in a git worktree the two diverge: sessions land under one slug,memory/under another, and/resumefinds nothing. Same root disease — path-derived, and inconsistently derived across subsystems.3. This already costs real maintenance. To work around it we've had to build and maintain (a) a
claimcommand that re-homes a conversation's transcript under a different project's slug, and (b) a branch-cleanup step that migrates a worktree's transcripts into the main checkout's slug when the worktree is torn down. Both are reactive patches chasing path changes after the fact — fragile, race-prone, and they shouldn't have to exist.Suggested fix (endorsing the marker-file proposal in this issue):
.claudefile holding an opaque id that the memory store references (1:many) — is enough as a last-resort fallback. Noisy, but robust to rename / move / worktree.git rev-parse --show-toplevelbefore the raw path — it already handles worktrees and remapped container mounts (also #33665's recommendation)./resume), not the current mix.A moved folder can retain its local conversation history when the old project slug is still present; the repair is to reconnect Desktop metadata to the existing transcripts rather than copy files blindly.
Claude Code derives the project slug from the working directory, so a move or rename can leave the old
~/.claude/projects/<old-slug>/files intact while the new path points somewhere else. I builtBasedGPT/claude-code-session-recoveryfor this path-split case. Run:Follow the exact command it prints. If it routes to
repoint_session_to_jsonl.py, review the dry-run output, keep a copy of the metadata and transcript directories, then fully quit Desktop before applying the printed command. The repair reconnects metadata to the transcript location; it does not move or rewrite the JSONL files.That is a manual continuity repair, not a stable project identity feature. Keep the old project directory until the diagnosis and post-repair session-list check are complete.
Hope this helps, if my tools are able to help you, would appreciate a ⭐ :)
Thats nice and all, but should not be necessary, and needs manual mainteinance if something moved on anthropics side