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

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
  • 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 / 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:

  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.0.0.tar.gz (28.8 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.0.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for claudepath-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1704e7185516c852791e0f259e303481a8ca3a50f71de1392b2b0dc4f6a21de0
MD5 de98f87cf59066a208706870276b82f5
BLAKE2b-256 20a2aac30dfd538ca5947f6146d0da4bc03e6c0db8835e2bfab232c9616a2e1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudepath-1.0.0.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.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for claudepath-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a72d59aca13a8aa462283ddfd6dcc8eed277767da6a23280fc5d702162eaaadb
MD5 31f4d4a30d4172f05fd1690eaa46165b
BLAKE2b-256 eae5ea69c415773922458afe5d1180a4d7b1b6290bdab6935a7048f238e00034

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudepath-1.0.0-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