Skip to content

Project path migration: moving a directory breaks all sessions #41344

Description

@snowology

Problem

When a user moves their project directory (e.g., C:\Users\me\Documents\Project to C:\Project), all existing sessions become inaccessible. There is no migration path -- sessions are permanently bound to the encoded directory name used at creation time (e.g., C--Users-me-Documents-Project in ~/.claude/projects/).

This is a common operation (reorganizing files, shortening paths, moving to a faster drive) and it silently breaks the user's workflow.

What happens today

  1. User moves project directory to a new location
  2. Opens Claude Code/Desktop from the new path -- works fine, but none of the old sessions appear
  3. User finds an old session in the session list, resumes it -- it loads as a blank session because the project mapping doesn't match
  4. Any interaction in the blank session overwrites the original session file with empty history
  5. The original conversation history is permanently lost with no backup or warning

The encoded project paths in ~/.claude/projects/ (e.g., C--Users-me-Documents-Project vs C--Claude) are treated as completely separate projects with no relationship to each other, even when they contain the same files.

Expected behavior

Near-term: Claude Code should natively understand the full session-to-project mapping -- the project directories, session files, encoded path scheme, and how they relate. When a user moves a directory, Claude should be able to detect the situation (e.g., matching .claude/ contents, same git remote, same CLAUDE.md) and migrate sessions to the new path automatically or with a simple command.

Longer-term: Project path migration should be seamless. Possible approaches:

  • Track projects by identity (git remote, project UUID) rather than filesystem path alone
  • Detect when a project directory has moved and prompt to migrate
  • Provide a claude migrate-project --from <old-path> --to <new-path> command
  • At minimum, warn the user before overwriting a session that has existing history from a different project path

Impact

  • Complete loss of conversation history (not recoverable)
  • Loss of context, decisions, and institutional knowledge built up over many sessions
  • No warning before destructive overwrite occurs
  • Workarounds (directory junctions) are fragile and non-obvious

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions