# Moving Claude Code Sessions Between a Mac and a Linux Box

> Source: <https://feniix-hq.net/blog/claude-sync/>
> Published: 2026-12-02 00:00:00+00:00

**Key takeaway:** Claude Code session folders are named from the project's absolute path with non-alphanumerics replaced by dashes, so moving a session to another machine requires rewriting both the folder name and the `cwd` and tool-call paths inside the JSONL files, which claude-sync 0.2.0 does over SSH and rsync.

Article

# Moving Claude Code Sessions Between a Mac and a Linux Box

Claude Code ties each session to absolute paths, so a copied session won't resume on another machine. claude-sync moves them over SSH and rewrites the paths.

I use Claude Code on a Mac laptop and on a Linux box, and I go back and
forth between them several times a day. A lot of the time the session I
want is on the other machine: a long conversation about a bug, with the
files it already read and the decisions it already made. But
`claude --resume` only knows about the sessions started on the machine
you’re sitting at.

So I built [claude-sync](https://github.com/feniix/claude-sync). It copies
Claude Code sessions between machines over SSH and rsync, rewrites the
paths inside them, and merges the prompt history. No cloud, no accounts.

## Why copying the folder doesn’t work

Claude Code keeps sessions in `~/.claude/projects/`, one folder per
project. The folder is named after the project’s absolute path, with every
character that isn’t a letter or a digit turned into `-`:

| Project | Session folder | 
|---|---|
| `/home/alice/work/shop` | `-home-alice-work-shop` | 
| `/Users/alice/work/shop` | `-Users-alice-work-shop` | 

The sessions inside are JSONL files, and they repeat the same absolute
paths: the working directory (`cwd`) and the file paths in tool calls. So
if you copy the folder from the Linux box to the Mac, Claude Code looks
for `-Users-alice-work-shop`, doesn’t find it, and `--resume` doesn’t
list the session. Rename the folder by hand and the paths inside still
point at `/home/alice`.

A copy that actually works has to rewrite both: the folder name and the file contents. claude-sync does that in one pass per file.

## Where it came from

The idea isn’t mine.
[claude-hop](https://github.com/SeiduTakizawa/Claude-hop), a Python tool by
[@SeiduTakizawa](https://github.com/SeiduTakizawa), already did this, and I
used it for a while. I forked it and opened a
[pull request](https://github.com/SeiduTakizawa/Claude-hop/pull/1) that
keeps a local mirror of the remote’s sessions, so a pull only transfers
what changed.

Then I rebuilt it in TypeScript on Bun. What I wanted:

- One release binary per platform, installed with
[mise](https://mise.jdx.dev/) , instead of a Python install on every
machine.
- Stricter merge rules than claude-hop had: leave a file alone (and list it on a pull) when it’s a folder or symlink on the other side, never copy symlinks, keep existing file modes, allow one pull at a time, and check for a running Claude Code again right before merging.
- To own the design, so I could change the config, add history merging and so on without going through upstream for every change.

claude-sync 0.1.0 kept claude-hop 0.4.0’s commands and config model and added the pull cache and the stricter merge on top. The current release is 0.2.0.

## Setting it up

You need `rsync` on both machines and SSH key auth from the machine running
claude-sync to the other one. There are release binaries for macOS on
arm64 and Linux on x64 and arm64.

```
mise use -g github:feniix/claude-sync
claude-sync init      # SSH host, connection test, remote home detection
claude-sync doctor    # SSH, rsync, clocks, config, cache
```

If you already use claude-hop, run `claude-sync import` instead of `init`;
it takes claude-hop’s remotes and mappings. With `--move-cache` it also
adopts claude-hop’s pull cache, so the first pull doesn’t transfer
anything.

The config lives in `~/.config/claude-sync/config.toml`. A remote is a
host plus that host’s home directory. This is the Mac’s side:

```
[remotes.linux]
host = "linux-box"        # SSH alias or host
home = "/home/alice"

[mappings]                # local path = path on the remote
"/Volumes/data/src" = "/data/src"
```

Swapping the home covers everything under `~`, so
`/Users/alice/work/shop` becomes `/home/alice/work/shop` on the way over
and back again on a pull. A project outside the home needs a mapping,
and without one `push` and `pull` refuse that project and print a snippet
you can paste into the config. You can also set mappings per remote.

## Day to day

| Command | What it does | 
|---|---|
| `claude-sync status` | Lists local projects and the name each gets on the remote | 
| `claude-sync diff` | Shows what would move in each direction, writing nothing | 
| `claude-sync push` | Sends local sessions to the remote | 
| `claude-sync pull` | Fetches the remote’s sessions and merges them in | 

`push` and `pull` take an optional remote name and project selectors, so
`.` syncs only the project in the current directory. `--all` syncs with
every remote, and `--dry-run` shows the plan without writing anything.

I sync in both directions several times a day, so pulls have to be cheap.
A full pull keeps a mirror of the remote’s sessions in
`~/.cache/claude-sync/`, and the next pull only transfers what changed on
the remote. When there’s little to do, that takes me about a second
instead of minutes.

## What it won’t do to your sessions

- **It never deletes a session file.** Writes go through`rsync -u` : the
newer file wins and nothing gets removed. The only`--delete` is on the
pull cache, and that cache is always safe to throw away.
- **It doesn’t sync while Claude Code is running.** Claude Code writes
a session while it runs, so a sync in the middle of one copies a
half-written file. claude-sync checks before it starts and again right
before a pull merges.`--force` overrides it.
- **It offers a backup on the first pull** into a machine that already has
sessions, as a tarball in`~/.claude/backups/` .
- **It skips temp-directory projects** by default (`/tmp` ,`/var/folders` and their`/private` versions). Coding agents work there, and those
sessions can’t be resumed anywhere else anyway. On my Mac that’s 520 of
739 project folders.
- **It stops on ambiguous mappings.** If two paths on one machine land on
the same path on the other, a pull could bring a project back under the
wrong name.`push` and`pull` stop before anything moves and tell you
which mappings are involved.

One thing it can’t protect you from: `--resume` keeps writing to the same
session file, so if a session gets new turns on both machines between
syncs, the newer file wins and the other side’s turns are lost. Sync before
switching, or resume with `--fork-session`.

## Prompt history

Version 0.2.0 added the prompt history, `~/.claude/history.jsonl`, which
is what ↑ and Ctrl-R recall. Both machines add to that file, so copying
it would throw away one side’s prompts. claude-sync merges it instead: it
keeps both sides’ entries, drops exact duplicates and sorts by time. It only rewrites
each entry’s `project` path; the prompt text stays exactly as you typed it.
Removals don’t carry over, though: a prompt one machine pruned or purged
comes back from the other on the next merge, so purge a project on both
machines.

Both merges run on the machine running claude-sync, so the remote only
needs `sh` and `rsync`. The merged file replaces the old one while holding
Claude Code’s own lock, `history.jsonl.lock`, so a prompt you type during
a sync waits a moment instead of getting lost. It’s on by default, and it
replaced a script I had in my dotfiles doing the same merge.

## Limits

- Auto-memory isn’t synced. I edit Claude Code’s memory files on both machines, and “newer file wins” would silently drop one machine’s edits. Memory needs a real merge, so it stays in my dotfiles, in git.
- It’s macOS and Linux only. The file locks and the timestamp copies
use `flock(2)` and`utimensat(2)` .
- The remote’s home path can only use letters, digits and
`@ % + = : , . / - _` . rsync 3.2.4 and later quote remote paths
themselves, but older rsync and openrsync (macOS’s`/usr/bin/rsync` )
don’t, and there’s no single way of quoting that works for both.

claude-sync is MIT-licensed; there’s a short
[project page](https://feniix-hq.net/projects/claude-sync/) for it here. The
[README](https://github.com/feniix/claude-sync#readme) has the full config
reference and the safety model.
