Skip to main content

Move or rename Claude Code projects without losing session history and context

Project description

claudepath

CI Coverage PyPI version Downloads Python versions License

Move or rename Claude Code projects without losing session history, memory, and context.

The Problem

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.

Installation

# With pipx (recommended — isolated install)
pipx install claudepath

# With pip
pip install claudepath

Homebrew (macOS/Linux)

brew tap Mahiler1909/tools
brew install claudepath

Usage

Move a project

Moves the directory on disk and updates all Claude Code references:

claudepath mv ~/old/location/my-project ~/new/location/my-project

Remap after a manual move

If you already moved the directory yourself, just update Claude's references:

claudepath remap ~/old/location/my-project ~/new/location/my-project

Preview changes (dry run)

See exactly what would change without modifying anything:

claudepath mv ~/old/path ~/new/path --dry-run

List tracked projects

claudepath list

Update claudepath

Update to the latest version — auto-detects whether you installed via Homebrew or pipx:

claudepath update

You can also force a specific method:

claudepath update --brew
claudepath update --pipx
claudepath update --pip

Restore from backup

List and restore from automatic backups:

claudepath restore --list       # see available backups
claudepath restore              # restore the latest backup
claudepath restore 20260227_145300  # restore a specific backup

Merge sessions when destination already has Claude data

If 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 --merge

Without --merge, claudepath will fail with a clear error suggesting you add the flag.

Full help

claudepath help
claudepath mv --help

What it updates

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/, and shell-snapshots/ are keyed by session UUID, not by project path — they don't need updating.

Options

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)

Environment Variables

Variable Description
NO_COLOR Disable colored output (set to any value)
FORCE_COLOR Force colored output even when not a TTY

Backup & Rollback

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/*.json files (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.

How Claude Code encodes paths

Claude Code stores project data in ~/.claude/projects/ using an encoded directory name: every character that isn't an ASCII letter or digit (/, ., _, ~, spaces, non-ASCII, …) is replaced with -. Names longer than 200 characters are truncated and suffixed with a base-36 hash of the original path.

/Users/foo/my-project      →  -Users-foo-my-project
/Users/foo/local.tmp/proj  →  -Users-foo-local-tmp-proj

This means moving /Users/foo/old-name to /Users/foo/new-name requires:

  1. Renaming -Users-foo-old-name to -Users-foo-new-name
  2. Updating all path strings inside the data files

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claudepath-1.1.2.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claudepath-1.1.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file claudepath-1.1.2.tar.gz.

File metadata

  • Download URL: claudepath-1.1.2.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claudepath-1.1.2.tar.gz
Algorithm Hash digest
SHA256 460662396aa82c1d43780dbf945177d7e25107d3df8bff4f0bd0c1527883dc54
MD5 2694dc10ccbc3331fc2083b732c7bb91
BLAKE2b-256 ecb76ae047392b6024e308483f959925f4e14196ed7c294ac5f7a88cb0ba1bf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudepath-1.1.2.tar.gz:

Publisher: publish.yml on Mahiler1909/claudepath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claudepath-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: claudepath-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claudepath-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c559f5a44426dbabd310285563affce5a841ffb608a1f2eb37ba6d699b0032b
MD5 50403dd025364bdf28c3ec2ca5656f73
BLAKE2b-256 5daac5067f50391fbc98488911d089fc6650454e8d6cd1e5908f3f92f002f85d

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudepath-1.1.2-py3-none-any.whl:

Publisher: publish.yml on Mahiler1909/claudepath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page