Directory renames orphan project state in ~/.claude/projects/

Resolved 💬 2 comments Opened Apr 6, 2026 by RaggedR Closed May 16, 2026

Problem

When a user renames a project directory (e.g., mv ~/git/foo ~/git/bar), Claude Code creates a new ~/.claude/projects/ entry for the new path. The old entry is silently orphaned, which means:

  1. Project memories are lost — memories stored under the old path are invisible to sessions opened from the new path
  2. Session history is split — transcripts are scattered across two project directories with no way to see full history
  3. Token/usage accounting breaks — tools that aggregate usage per project see them as separate projects

This happens with any rename, including common cases like fixing a typo in a directory name.

Current behavior

~/.claude/projects/-Users-me-git-old-name/   # has memories, transcripts
~/.claude/projects/-Users-me-git-new-name/   # fresh start, no history

Expected behavior

Claude Code should detect (or allow the user to specify) that a project directory was renamed, and migrate or link the project state. Some options:

  1. Automatic detection — on startup, if the cwd project dir doesn't exist but a similar one does (e.g., same parent, similar name), prompt to migrate
  2. Symlink support — if the project dir is a symlink, follow it
  3. Manual migration command — e.g., claude project migrate old-path new-path
  4. Alias/redirect file — a simple mapping file that says "old-name -> new-name"

Workaround

Currently you can fix this by hand:

cd ~/.claude/projects/
mv -- -Users-me-git-old-name/*.jsonl -Users-me-git-new-name/
# merge memory dir if it exists
cp -r -- -Users-me-git-old-name/memory/* -Users-me-git-new-name/memory/ 2>/dev/null
rm -rf -- -Users-me-git-old-name
ln -s ./-Users-me-git-new-name ./-Users-me-git-old-name

But users shouldn't have to know about the internal directory structure to preserve their project state.

Environment

  • Claude Code CLI
  • macOS / Linux
  • Affects: memories, session transcripts, any project-scoped state

View original on GitHub ↗

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