[BUG] Sessions lost when project directory is moved or renamed
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When a project directory is moved or renamed on the filesystem, all previous Claude Code sessions become inaccessible in the VS Code extension. Sessions still exist on disk under ~/.claude/projects/ but are orphaned because Claude Code uses the absolute filesystem path as the project identifier.
After reorganizing ~134 repos on my machine, I lost access to 63+ sessions across 10+ projects. The data is still there but invisible.
Example:
~/.claude/projects/C--Users-User-Desktop-my-project/ <- 15 old sessions here (orphaned)
~/.claude/projects/C--Users-User-Projects-my-project/ <- new empty dir created after move
What Should Happen?
Sessions should follow the project when it's moved or renamed. At minimum, there should be a way to migrate/link old sessions to the new path. Ideally, Claude Code would use git remote URL as a secondary identifier so repo identity persists across moves.
Steps to Reproduce
- Open a project at
C:\Users\User\Desktop\my-projectin VS Code - Have several Claude Code sessions/conversations in that project
- Close VS Code
- Move the project folder to
C:\Users\User\Projects\my-project - Open the project from the new path in VS Code
- Open Claude Code sidebar — previous sessions are gone, history is empty
Is this a regression?
I don't know
Claude Code Version
2.1.72 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
Common real-world triggers:
- Repo reorganization / filesystem cleanup
- Renaming a folder
- Moving repos between directories
Suggested solutions:
- Session migration command: e.g.,
/migrate-sessions <old-path> - Git-based identity: Use git remote URL as project identifier instead of only filesystem path
- Manual linking: Let users associate old project paths with new ones in settings
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗