
You can finally take your claude code history with you when you move/rename projects folders!
Normally, your history is stored based on the project path, if you rename it you lose the ability to --resume or --continue.
This tool copies the history from claude's internal files in ~/.claude/projects/....

Quick start (Claude Code plugin)
The repo is its own plugin marketplace. Inside Claude Code:
/plugin marketplace add FarisHijazi/claude-migrate
/plugin install claude-migrate@farishijazi
That installs the /migrate skill. Then, in the old location:
/migrate /new/path # same machine
/migrate user@host:/new/path # another machine
Create the new path (cp -r /old/path /new/path) either before or after.
Without the plugin system
# install `uv` and `uvx` if you haven't already
# curl -LsSf https://astral.sh/uv/install.sh | sh
uvx git+https://github.com/FarisHijazi/claude-migrate install-skill
Installs the same skill to ~/.claude/skills/migrate/. install-slash-command still
works as an alias. If you have an older ~/.claude/commands/migrate.md, delete it — two
things answering to /migrate drift apart.
CLI Usage
# Preview a copy of the history (default behavior, keeps source)
uvx git+https://github.com/FarisHijazi/claude-migrate migrate /old/path /new/path --dry-run
# Move history (copy + delete source history)
uvx claude-migrate migrate /old/path /new/path --delete-history
# Move the project folder AND its history in one shot
uvx claude-migrate migrate /old/path /new/path \
--folder --delete-history --delete-dir
# Then continue at the new location
cd /new/path && claude --continue
Quick tip
Inside Claude Code with the ! prefix (no AI overhead):
! uvx claude-migrate migrate "$(pwd)" /new/path
Commands
| Command | Description |
|---|
migrate <old> <new> | Migrate history (and optionally the folder) between paths |
rm <path> | Remove history for a directory (add --folder to also delete the directory itself) |
export <project_path> | Export one project's history to a portable .tar.gz archive |
export-all | Export all project histories under ~/.claude/projects/ to one archive |
import <archive> [target] | Unpack and smart-merge into the target path (rewrites paths) |
import-all <archive> | Import an export-all archive into local ~/.claude/projects/ |
sync | Two-way sync with peers in ~/.claude/history-sync.json |
user-messages | Extract just the human-typed messages from the current session |
install-skill | Install the /migrate skill into ~/.claude/skills |
cp <old> <new> | Deprecated alias of migrate |
mv <old> <new> | Deprecated alias of migrate --delete-history |
install-slash-command | Install the /migrate slash command |
All commands support --dry-run / -n.
migrate flags
| Flag | Effect |
|---|
--merge, -m | Smart-merge into existing history at the destination |
--folder | Also copy the actual project folder (errors if destination folder already exists) |
--delete-history | Delete the source history after copy (move semantics for history) |
--delete-dir | Delete the source project folder after copy (requires --folder) |
--replace-userpath [FROM:TO] | Rewrite /Users/<x>/ and /home/<x>/ in chat content. Bare flag auto-detects; pass --replace-userpath=alice:bob to override |
--replace-references | Walk every JSON/JSONL value in the history and rewrite absolute and relative path references inside chat content (see below) |
--replace-references — how path references are rewritten
When you migrate a project, the chat history is full of path strings inside tool calls and prose. With --replace-references, every string value in every JSON/JSONL line is scanned:
- Absolute paths under the old CWD are rewritten under the new CWD. Boundary-protected so
/old/cwd doesn't corrupt /old/cwdbar.
- Encoded forms (e.g.
-Users-alice-projects-foo) are also rewritten.
- Relative paths (
./foo, ../bar/baz) are resolved against the old CWD:
- If they resolve inside the old CWD, they're kept as relative — they still work from the new location.
- If they escape the old CWD (e.g.
../other/file.py), they're pinned to the original absolute path, because the external file didn't move.
Every unique before -> after replacement is printed before being applied. Use --dry-run to preview without writing.
Cross-machine / cross-user
# On the source machine
uvx claude-migrate export-all -o ~/backups/
# Copy the .tar.gz to the target machine, then
uvx claude-migrate import-all ~/backups/claude-history-ALL-*.tar.gz \
--replace-userpath --replace-references