Sessions lost when project directory is moved or renamed

Resolved 💬 2 comments Opened Mar 12, 2026 by bishalramdam Closed Mar 12, 2026

Description

When a project directory is moved or renamed on the filesystem, all previous Claude Code sessions for that project become inaccessible in the VS Code extension. The sessions still exist in ~/.claude/projects/ but are orphaned because Claude Code uses the absolute filesystem path as the project identifier.

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. Move the project to C:\Users\User\Projects\my-project (rename or reorganize)
  4. Open the project from the new path in VS Code
  5. Previous Claude Code sessions are gone — the session history sidebar is empty

Root Cause

Claude Code stores sessions under ~/.claude/projects/<encoded-path>/. The directory name is derived from the absolute path:

~/.claude/projects/C--Users-User-Desktop-my-project/       <- old sessions here
~/.claude/projects/C--Users-User-Projects-my-project/       <- new empty dir created

When the path changes, Claude Code creates a new project directory and has no way to link it to the old one. The old sessions are still on disk but invisible to the extension.

Impact

  • After reorganizing ~134 repos on my machine, I lost access to 63+ sessions across 10+ projects
  • Any project rename (even just changing folder name case) orphans all sessions
  • Common real-world triggers: repo reorganization, directory renaming, moving repos between folders
  • Session data contains valuable context, debugging history, and decisions that users expect to persist

Suggested Solutions

  1. Session migration tool: A command (e.g., /migrate-sessions) that lets users point old project paths to new ones
  2. Git-based identity: Use the git remote URL or repo name as a secondary/primary project identifier instead of only the filesystem path — repos maintain identity across moves
  3. Fuzzy matching on open: When opening a project with no sessions, check if there are orphaned sessions from a path that shares the same repo name/git remote
  4. Manual linking: Allow users to manually associate an old project path with a new one in settings

Environment

  • Claude Code: VS Code extension (latest)
  • OS: Windows 11 + WSL 2 (Ubuntu)
  • Both ~/.claude/ (WSL) and C:\Users\User\.claude\ (Windows) are affected

View original on GitHub ↗

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