[BUG] Sessions lost when project directory is moved or renamed

Resolved 💬 4 comments Opened Mar 12, 2026 by bishalramdam Closed Apr 22, 2026

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

  1. Open a project at C:\Users\User\Desktop\my-project in VS Code
  2. Have several Claude Code sessions/conversations in that project
  3. Close VS Code
  4. Move the project folder to C:\Users\User\Projects\my-project
  5. Open the project from the new path in VS Code
  6. 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:

  1. Session migration command: e.g., /migrate-sessions <old-path>
  2. Git-based identity: Use git remote URL as project identifier instead of only filesystem path
  3. Manual linking: Let users associate old project paths with new ones in settings

View original on GitHub ↗

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