Migrate Claude Code project state when your project folder moves — rewires cwd paths across sessions, ~/.claude.json, and worktrees.
Project description
claude-repath
Rewire Claude Code's local state when your project folder moves.
When you move or rename a project directory, Claude Code loses track of its sessions, memory, todos, and worktrees — because the absolute path is hardcoded in four different places. claude-repath patches all of them in one shot.
Why this exists
Claude Code stores per-project state under ~/.claude/projects/<encoded-cwd>/, where the folder name is derived from the project's absolute path. Moving the project folder breaks:
~/.claude/projects/<encoded>/— the encoded folder name no longer matches~/.claude/projects/<encoded>/*.jsonl— each session file has"cwd"hardcoded inside~/.claude.json— theprojectskey is indexed by absolute path- Git worktree sub-projects — each has its own encoded folder AND internal
cwdfields
Anthropic has no official migration command (as of 2026-04), and existing community tools cover at most 6 of the needed layers. claude-repath aims to handle all of them, with special care for Windows paths and worktrees.
Quick start
# Install
pip install claude-repath
# Or run without installing (requires uv)
uvx --from claude-repath claude-repath --help
# INTERACTIVE mode — pick from a list, no path typing needed
claude-repath move
# Explicit mode — preview changes first (ALWAYS recommended)
claude-repath move D:\dev_code\time-blocks D:\dev_code\Life\time-blocks --dry-run
# Actually perform the migration (auto-backs-up first)
claude-repath move D:\dev_code\time-blocks D:\dev_code\Life\time-blocks
# Broader scan — also rewrite cross-project references (use with care)
claude-repath move <old> <new> --scope broad
# If you already moved the folder manually, just rewire state
claude-repath rewire D:\dev_code\time-blocks D:\dev_code\Life\time-blocks
# Health check a project's Claude Code state
claude-repath doctor D:\dev_code\time-blocks
# List all projects Claude Code knows about
claude-repath list
# Roll back a previous migration
claude-repath rollback 20260419-155331
What gets migrated
| # | Layer | Handled |
|---|---|---|
| 1 | Physical project folder (mv) |
✅ |
| 2 | ~/.claude/projects/<encoded>/ directory name |
✅ |
| 3 | .jsonl session files — inline "cwd" fields |
✅ |
| 4 | ~/.claude.json — projects key |
✅ |
| 5 | Worktree-derived project folders (auto-discovered) | ✅ |
| 6 | ~/.claude/git-worktrees.json (if present) |
✅ |
| 7 | Chromium Local Storage/leveldb entries (Desktop app) |
⏳ v0.3+ backlog |
Safety
- Dry-run by default logic: destructive commands require either
--dry-runpreview first or explicit confirmation - Auto-backup: every mutation is snapshotted to
~/.claude/.repath-backups/<timestamp>/ - Process guard: refuses to run if any
claudeprocess is holding the state files - Rollback:
claude-repath rollback <timestamp>restores a previous snapshot
Platform support
| OS | CLI state (~/.claude/) |
Desktop state (Local Storage/leveldb) |
|---|---|---|
| Windows 11 (Git Bash / PowerShell / cmd) | ✅ auto-migrated | 🔍 diagnosed |
| macOS | ✅ auto-migrated | 🔍 diagnosed |
| Linux | ✅ auto-migrated | 🔍 diagnosed |
Windows paths with drive letters (D:\...) and backslashes are first-class — they were the primary motivation for writing this tool. The path matcher accepts both \ and / separators and automatically aligns with ~/.claude.json's forward-slash-stored keys.
About Claude Code Desktop
Claude Code Desktop stores additional session state in Chromium's Local Storage LevelDB:
- Windows:
%LOCALAPPDATA%\claude\Local Storage\leveldb\ - macOS:
~/Library/Application Support/claude/Local Storage/leveldb/ - Linux:
~/.config/claude/Local Storage/leveldb/
claude-repath doctor reports whether this directory exists on your machine but does not migrate it automatically — see Roadmap for planned v0.3+ support. If you use Desktop exclusively and move a project, the Desktop UI's "recent projects" list may show a stale path. Remedy: open the new folder via Desktop's File menu to re-register it.
Comparison to existing tools
At the time of writing (April 2026) there is no official Anthropic
migration command. A handful of community tools exist — claude-repath
is designed to close their gaps:
| Tool | Layers covered | Windows | Worktrees | ~/.claude.json |
Separator tolerance |
|---|---|---|---|---|---|
| arak-git/claude-code-project-mover-py | 6 | ✅ | partial | ✅ | partial |
| justinstimatze/claude-mv | 9 | ❌ | ❌ | ✅ | ❌ |
| lovstudio/cc-mv (npm) | 4 | ? | ❌ | ❌ | ❌ |
| skydiver/claude-code-project-mover | 2 | ❌ | ❌ | ❌ | ❌ |
| claude-repath | 6 + rollback | ✅ | ✅ auto | ✅ | ✅ both |
Development
# Clone & enter
git clone https://github.com/xPeiPeix/claude-repath.git
cd claude-repath
# Install with uv (creates .venv, installs typer + dev deps)
uv sync --all-groups
# Run tests
uv run pytest
# Lint
uv run ruff check
# Run CLI locally
uv run claude-repath --help
Layout:
src/claude_repath/
├── cli.py # typer app (move/rewire/doctor/list/rollback)
├── migrate.py # orchestrator
├── encoder.py # path → folder-name encoding
├── backup.py # manifest-based backup & LIFO rollback
├── utils.py # shared path rewrite helpers
└── layers/
├── projects_dir.py # ~/.claude/projects/<encoded>/ renaming
├── jsonl_cwd.py # .jsonl cwd field rewriting
├── global_json.py # ~/.claude.json projects key
└── worktrees_json.py # ~/.claude/git-worktrees.json
Roadmap
- v0.3 (current) — Wizard-style TUI with three-step flow (pick / locate / preview), two-stage path input (parent directory + project name) with Tab-completion, per-layer change counts in a Rich preview panel, and a live spinner during apply.
- v0.2 — Interactive TUI picker,
--scope narrow|broadflag, Desktop Local Storage diagnostic, cross-platform path handling (Win/macOS/Linux). - v0.4+ (backlog) — Chromium
Local Storage/leveldbauto-migration for Claude Code Desktop users (requires closing Desktop first +plyvel-cibindings + META-protobuf maintenance); interactive TUI variants forrollback/doctor; shell-completion auto-install (typer's built-in).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_repath-0.3.0.tar.gz.
File metadata
- Download URL: claude_repath-0.3.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19e6e3bada0f486b6bb27a16b5b53d948963b388dcd5996a953f16404c02c384
|
|
| MD5 |
eb05460e4a2f9ac3dbd20a1fe2d907f5
|
|
| BLAKE2b-256 |
aba1b31aca5394b9e0d0eef8194d1196fdf599a561fc0d4c25fef6819873ba21
|
Provenance
The following attestation bundles were made for claude_repath-0.3.0.tar.gz:
Publisher:
publish.yml on xPeiPeix/claude-repath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_repath-0.3.0.tar.gz -
Subject digest:
19e6e3bada0f486b6bb27a16b5b53d948963b388dcd5996a953f16404c02c384 - Sigstore transparency entry: 1342667410
- Sigstore integration time:
-
Permalink:
xPeiPeix/claude-repath@848d0a2e5fe91beb37f8ca4b6e4d4c90452c86b2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/xPeiPeix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@848d0a2e5fe91beb37f8ca4b6e4d4c90452c86b2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file claude_repath-0.3.0-py3-none-any.whl.
File metadata
- Download URL: claude_repath-0.3.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aca9a10aa49a3bdcbd41ecf9c0d52c906eca022c7f1fba8d9e53748cbaeb5d64
|
|
| MD5 |
4107c1be714fd8c468ae58da2fba4c3a
|
|
| BLAKE2b-256 |
ac6466a878490e05377abc1917936ece6823d22e0612e343ee196c14f9ccaf08
|
Provenance
The following attestation bundles were made for claude_repath-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on xPeiPeix/claude-repath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_repath-0.3.0-py3-none-any.whl -
Subject digest:
aca9a10aa49a3bdcbd41ecf9c0d52c906eca022c7f1fba8d9e53748cbaeb5d64 - Sigstore transparency entry: 1342667419
- Sigstore integration time:
-
Permalink:
xPeiPeix/claude-repath@848d0a2e5fe91beb37f8ca4b6e4d4c90452c86b2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/xPeiPeix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@848d0a2e5fe91beb37f8ca4b6e4d4c90452c86b2 -
Trigger Event:
release
-
Statement type: