Move or rename Claude Code projects without losing session history, memory, and context.
When you move or rename a project directory, Claude Code loses all your session history because sessions are keyed to the absolute path of your project. You end up with orphaned data in ~/.claude/projects/ and a fresh start.
claudepath fixes this by updating all path references in Claude Code's data files after a move.
# With pipx (recommended — isolated install)
pipx install claudepath
# With pip
pip install claudepathbrew tap Mahiler1909/tools
brew install claudepathMoves the directory on disk and updates all Claude Code references:
claudepath mv ~/old/location/my-project ~/new/location/my-projectIf you already moved the directory yourself, just update Claude's references:
claudepath remap ~/old/location/my-project ~/new/location/my-projectSee exactly what would change without modifying anything:
claudepath mv ~/old/path ~/new/path --dry-runclaudepath listUpdate to the latest version — auto-detects whether you installed via Homebrew or pipx:
claudepath updateYou can also force a specific method:
claudepath update --brew
claudepath update --pipx
claudepath update --pipList and restore from automatic backups:
claudepath restore --list # see available backups
claudepath restore # restore the latest backup
claudepath restore 20260227_145300 # restore a specific backupIf you opened Claude Code at the new location before running claudepath remap, Claude Code will have already created a new project directory there. Use --merge to combine the sessions from both directories:
claudepath remap ~/old/path ~/new/path --mergeWithout --merge, claudepath will fail with a clear error suggesting you add the flag.
claudepath help
claudepath mv --help| File / Directory | What changes |
|---|---|
~/.claude/projects/{encoded-dir}/ |
Renamed to match new path |
sessions-index.json |
originalPath, projectPath, fullPath updated (proper JSON parsing) |
{session}.jsonl files |
cwd and file path references updated (line-by-line, handles large files) |
Subagent .jsonl files |
Same as above, recursive |
~/.claude/history.jsonl |
project field updated for all matching entries |
usage-data/session-meta/*.json |
project_path updated (token usage & analytics) |
Note:
file-history/,todos/,tasks/, andshell-snapshots/are keyed by session UUID, not by project path — they don't need updating.
| Flag | Description |
|---|---|
--dry-run |
Preview all changes without writing anything |
--no-backup |
Skip creating a backup before modifying files |
--yes / -y |
Skip the confirmation prompt |
--merge |
Merge sessions when destination already has Claude data |
--verbose / -v |
Show detailed file-by-file processing output |
--claude-dir <path> |
Override the Claude data directory (default: ~/.claude) |
| Variable | Description |
|---|---|
NO_COLOR |
Disable colored output (set to any value) |
FORCE_COLOR |
Force colored output even when not a TTY |
By default, claudepath creates a backup before making any changes:
~/.claude/backups/claudepath/{timestamp}/
The backup includes:
- The full project data directory (
~/.claude/projects/{encoded}/) ~/.claude/history.jsonl- Affected
usage-data/session-meta/*.jsonfiles (token usage & analytics) - When using
--merge: both the source and destination project directories
If any step fails, claudepath automatically restores from the backup. Use --no-backup only if you already have your own backup or want to skip the extra time.
Claude Code stores project data in ~/.claude/projects/ using an encoded directory name: every / in the absolute path is replaced with -.
/Users/foo/my-project → -Users-foo-my-project
This means moving /Users/foo/old-name to /Users/foo/new-name requires:
- Renaming
-Users-foo-old-nameto-Users-foo-new-name - Updating all path strings inside the data files
MIT