{"slug": "moving-claude-code-sessions-between-a-mac-and-a-linux-box", "title": "Moving Claude Code Sessions Between a Mac and a Linux Box", "summary": "A developer released claude-sync 0.2.0, a TypeScript-on-Bun tool that copies Claude Code sessions between a Mac and a Linux machine over SSH and rsync, rewriting the absolute paths inside each session so `claude --resume` can list them on the other host. The tool addresses the fact that Claude Code stores sessions in `~/.claude/projects/` under folder names derived from the project's absolute path (e.g. `-home-alice-work-shop` versus `-Users-alice-work-shop`) and repeats those paths in the JSONL files' `cwd` and tool-call file paths, so a plain folder copy fails to resume. claude-sync builds on SeiduTakizawa's Python tool claude-hop 0.4.0, keeping its commands and config model while adding a pull cache and stricter merge rules, and ships release binaries for macOS arm64 and Linux x64/arm64 installed via mise.", "body_md": "Article\n\n# Moving Claude Code Sessions Between a Mac and a Linux Box\n\nClaude 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.\n\nI use Claude Code on a Mac laptop and on a Linux box, and I go back and\nforth between them several times a day. A lot of the time the session I\nwant is on the other machine: a long conversation about a bug, with the\nfiles it already read and the decisions it already made. But\n`claude --resume` only knows about the sessions started on the machine\nyou’re sitting at.\n\nSo I built [claude-sync](https://github.com/feniix/claude-sync). It copies\nClaude Code sessions between machines over SSH and rsync, rewrites the\npaths inside them, and merges the prompt history. No cloud, no accounts.\n\n## Why copying the folder doesn’t work\n\nClaude Code keeps sessions in `~/.claude/projects/`, one folder per\nproject. The folder is named after the project’s absolute path, with every\ncharacter that isn’t a letter or a digit turned into `-`:\n\n| Project | Session folder | \n|---|---|\n| `/home/alice/work/shop` | `-home-alice-work-shop` | \n| `/Users/alice/work/shop` | `-Users-alice-work-shop` | \n\nThe sessions inside are JSONL files, and they repeat the same absolute\npaths: the working directory (`cwd`) and the file paths in tool calls. So\nif you copy the folder from the Linux box to the Mac, Claude Code looks\nfor `-Users-alice-work-shop`, doesn’t find it, and `--resume` doesn’t\nlist the session. Rename the folder by hand and the paths inside still\npoint at `/home/alice`.\n\nA copy that actually works has to rewrite both: the folder name and the file contents. claude-sync does that in one pass per file.\n\n## Where it came from\n\nThe idea isn’t mine.\n[claude-hop](https://github.com/SeiduTakizawa/Claude-hop), a Python tool by\n[@SeiduTakizawa](https://github.com/SeiduTakizawa), already did this, and I\nused it for a while. I forked it and opened a\n[pull request](https://github.com/SeiduTakizawa/Claude-hop/pull/1) that\nkeeps a local mirror of the remote’s sessions, so a pull only transfers\nwhat changed.\n\nThen I rebuilt it in TypeScript on Bun. What I wanted:\n\n- One release binary per platform, installed with\n[mise](https://mise.jdx.dev/) , instead of a Python install on every\nmachine.\n- 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.\n- To own the design, so I could change the config, add history merging and so on without going through upstream for every change.\n\nclaude-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.\n\n## Setting it up\n\nYou need `rsync` on both machines and SSH key auth from the machine running\nclaude-sync to the other one. There are release binaries for macOS on\narm64 and Linux on x64 and arm64.\n\n```\nmise use -g github:feniix/claude-sync\nclaude-sync init      # SSH host, connection test, remote home detection\nclaude-sync doctor    # SSH, rsync, clocks, config, cache\n```\n\nIf you already use claude-hop, run `claude-sync import` instead of `init`;\nit takes claude-hop’s remotes and mappings. With `--move-cache` it also\nadopts claude-hop’s pull cache, so the first pull doesn’t transfer\nanything.\n\nThe config lives in `~/.config/claude-sync/config.toml`. A remote is a\nhost plus that host’s home directory. This is the Mac’s side:\n\n```\n[remotes.linux]\nhost = \"linux-box\"        # SSH alias or host\nhome = \"/home/alice\"\n\n[mappings]                # local path = path on the remote\n\"/Volumes/data/src\" = \"/data/src\"\n```\n\nSwapping the home covers everything under `~`, so\n`/Users/alice/work/shop` becomes `/home/alice/work/shop` on the way over\nand back again on a pull. A project outside the home needs a mapping,\nand without one `push` and `pull` refuse that project and print a snippet\nyou can paste into the config. You can also set mappings per remote.\n\n## Day to day\n\n| Command | What it does | \n|---|---|\n| `claude-sync status` | Lists local projects and the name each gets on the remote | \n| `claude-sync diff` | Shows what would move in each direction, writing nothing | \n| `claude-sync push` | Sends local sessions to the remote | \n| `claude-sync pull` | Fetches the remote’s sessions and merges them in | \n\n`push` and `pull` take an optional remote name and project selectors, so\n`.` syncs only the project in the current directory. `--all` syncs with\nevery remote, and `--dry-run` shows the plan without writing anything.\n\nI sync in both directions several times a day, so pulls have to be cheap.\nA full pull keeps a mirror of the remote’s sessions in\n`~/.cache/claude-sync/`, and the next pull only transfers what changed on\nthe remote. When there’s little to do, that takes me about a second\ninstead of minutes.\n\n## What it won’t do to your sessions\n\n- **It never deletes a session file.** Writes go through`rsync -u` : the\nnewer file wins and nothing gets removed. The only`--delete` is on the\npull cache, and that cache is always safe to throw away.\n- **It doesn’t sync while Claude Code is running.** Claude Code writes\na session while it runs, so a sync in the middle of one copies a\nhalf-written file. claude-sync checks before it starts and again right\nbefore a pull merges.`--force` overrides it.\n- **It offers a backup on the first pull** into a machine that already has\nsessions, as a tarball in`~/.claude/backups/` .\n- **It skips temp-directory projects** by default (`/tmp` ,`/var/folders` and their`/private` versions). Coding agents work there, and those\nsessions can’t be resumed anywhere else anyway. On my Mac that’s 520 of\n739 project folders.\n- **It stops on ambiguous mappings.** If two paths on one machine land on\nthe same path on the other, a pull could bring a project back under the\nwrong name.`push` and`pull` stop before anything moves and tell you\nwhich mappings are involved.\n\nOne thing it can’t protect you from: `--resume` keeps writing to the same\nsession file, so if a session gets new turns on both machines between\nsyncs, the newer file wins and the other side’s turns are lost. Sync before\nswitching, or resume with `--fork-session`.\n\n## Prompt history\n\nVersion 0.2.0 added the prompt history, `~/.claude/history.jsonl`, which\nis what ↑ and Ctrl-R recall. Both machines add to that file, so copying\nit would throw away one side’s prompts. claude-sync merges it instead: it\nkeeps both sides’ entries, drops exact duplicates and sorts by time. It only rewrites\neach entry’s `project` path; the prompt text stays exactly as you typed it.\nRemovals don’t carry over, though: a prompt one machine pruned or purged\ncomes back from the other on the next merge, so purge a project on both\nmachines.\n\nBoth merges run on the machine running claude-sync, so the remote only\nneeds `sh` and `rsync`. The merged file replaces the old one while holding\nClaude Code’s own lock, `history.jsonl.lock`, so a prompt you type during\na sync waits a moment instead of getting lost. It’s on by default, and it\nreplaced a script I had in my dotfiles doing the same merge.\n\n## Limits\n\n- 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.\n- It’s macOS and Linux only. The file locks and the timestamp copies\nuse `flock(2)` and`utimensat(2)` .\n- The remote’s home path can only use letters, digits and\n`@ % + = : , . / - _` . rsync 3.2.4 and later quote remote paths\nthemselves, but older rsync and openrsync (macOS’s`/usr/bin/rsync` )\ndon’t, and there’s no single way of quoting that works for both.\n\nclaude-sync is MIT-licensed; there’s a short\n[project page](https://feniix-hq.net/projects/claude-sync/) for it here. The\n[README](https://github.com/feniix/claude-sync#readme) has the full config\nreference and the safety model.", "url": "https://wpnews.pro/news/moving-claude-code-sessions-between-a-mac-and-a-linux-box", "canonical_source": "https://feniix-hq.net/blog/claude-sync/", "published_at": "2026-12-02 00:00:00+00:00", "updated_at": "2026-12-02 18:15:49.870289+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["Claude Code", "claude-sync", "claude-hop", "SeiduTakizawa", "Bun", "TypeScript", "mise", "Anthropic"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/moving-claude-code-sessions-between-a-mac-and-a-linux-box", "markdown": "https://wpnews.pro/news/moving-claude-code-sessions-between-a-mac-and-a-linux-box.md", "text": "https://wpnews.pro/news/moving-claude-code-sessions-between-a-mac-and-a-linux-box.txt", "jsonld": "https://wpnews.pro/news/moving-claude-code-sessions-between-a-mac-and-a-linux-box.jsonld"}}