Shell functions for syncing Claude Code project context across machines, with local backups.
cc-sync rsyncs a context directory in ~/.claude/projects from a remote machine to the local machine. It derives context directory names from the current working directory, accounting for OS home directory path differences.
For example, ~/code/catbutt will have context at
~/.claude/projects/-home-wesley-code-catbutton Linux and~/.claude/projects/-Users-wesley-code-catbutton macOS.
If the relative path is the same on both machines, only the host is needed:
~/code/catbutt$ cc-sync xicamatlA remote path is necessary when the relative directory differs:
~/code/catbutt$ cc-sync xicamatl:projects/catbuttTo retrieve the context of a renamed project:
~/code/cul-de-chat$ cc-sync localhost:code/catbuttBy default (rsync and therefore) cc-sync is additive, consolidating context across machines. Use --delete to make local match remote exactly.
A backup of the local context directory is created before syncing, except with --dry-run.
-
cc-sync [rsync-options] <host[:path]>- Wraps
rsync -avwith passthrough of recognized rsync options:--dry-run,-n: preview what would be transferred--delete: remove local context not present on remote-z,--compress: compress data during transfer
- Context directories determined with tilde expansions of CWD relative to
~/ - Assumes same relative path on remote unless
:pathis specified.
- Wraps
-
cc-backup- Creates a context backup for current working directory
- Stored in
~/.claude/backups/projects/as{context-dir}_{timestamp}.tar.gz
-
cc-restore- Restores the most recent backup for current working directory
-
cc-pop- Restores the most recent backup for current working directory
- Deletes the backup file after restoration
- Claude Code (
~/.claude/projects/directory must exist) - Read/write access to
~/.claude/projects/and~/.claude/backups/projects/
- Passwordless SSH access to remote machine
rsyncinstalled on both machines
- Source
claude-context.shpath in.zshrcor.bashrcetc.)