Blog · Guide
How to move a Claude Code session to a remote server, conversation included
Claude Code keeps each conversation as a JSONL transcript under ~/.claude/projects/<path-slug>/. Moving a session means moving the code (the branch and its uncommitted files) and that transcript, fixing the absolute paths inside it, then running claude --resume on the other machine. You can do it by hand or with a script. Zoes does it from a menu, Hand off to a host…, for the Claude Code and Codex sessions it started.
This guide covers both ways, what each one needs on the server, and when you are better off starting on the server in the first place.
Why move a session instead of starting fresh?
A session that has run for an hour holds context you don't want to explain again: what you asked for, which files it read, what it tried and dropped. Reasons to move it rather than start over:
- Your laptop is about to close, and the agent is mid-task.
- The next step needs a bigger machine: a full build, a long test suite, a GPU.
- The work will run for hours, and you want it on a box that stays up.
If you already know a task will be long, the common setup works fine: ssh to the server, start tmux, run Claude Code there from the start. Nothing needs to move later. Moving is for the session that started on your Mac and outgrew it.
Where does Claude Code keep a session?
Per the Claude Code sessions docs:
- Transcripts are JSONL files at
~/.claude/projects/<project>/<session-id>.jsonl. <project>is the working directory's path with every non-alphanumeric character replaced by-./Users/me/code/appbecomes-Users-me-code-app. A converted name over 200 characters is cut to 200 with a hash of the full path appended.claude --resume <session-id>resumes that session.claude --continuereopens the newest session in the current directory.CLAUDE_CONFIG_DIRmoves the whole store off~/.claude.
The same page warns that the entry format is internal to Claude Code and changes between versions. Anything that edits these files, a script or a tool, can break on a new release.
The transcript records absolute paths: the working directory, and every file the agent read or edited. On a server whose checkout lives at /home/me/code/app, those Mac paths point nowhere. That is why a plain copy is not enough.
How do you move it by hand?
The example moves a session on branch fix-auth from /Users/me/code/app on a Mac to /home/me/code/app on a host called devbox, which already has a clone of the repository.
- Carry the uncommitted files in a WIP commit, and push the branch:
cd ~/code/app git add -A git commit -m "WIP: move to devbox" git push -u origin fix-authWithout a shared remote, bundle the branch and copy the file instead:
git bundle create fix-auth.bundle main..fix-auth, thenscpit andgit fetch ./fix-auth.bundle fix-auth:fix-authon the server. - Find the transcript. It is usually the newest file in the project's folder:
OLD=/Users/me/code/app NEW=/home/me/code/app OLD_SLUG=$(printf %s "$OLD" | sed 's/[^A-Za-z0-9]/-/g') NEW_SLUG=$(printf %s "$NEW" | sed 's/[^A-Za-z0-9]/-/g') ls -t ~/.claude/projects/$OLD_SLUG | head -1 # <session-id>.jsonlThis slug doesn't handle paths long enough to be cut and hashed.
- Copy it to the server under the new folder name, with the paths rewritten:
SID=<session-id> ssh devbox "mkdir -p ~/.claude/projects/$NEW_SLUG" sed "s#$OLD#$NEW#g" ~/.claude/projects/$OLD_SLUG/$SID.jsonl \ | ssh devbox "cat > ~/.claude/projects/$NEW_SLUG/$SID.jsonl"sedalso rewrites lookalikes such as/Users/me/code/app2. Check the result if you have sibling folders with names like that. - On the server, sign in once, check out the branch and undo the WIP commit, so the files are uncommitted again:
ssh devbox claude auth login cd ~/code/app git fetch origin git switch fix-auth git reset HEAD~ - Resume inside that directory, ideally in
tmuxso it survives your SSH connection:tmux new -s fix-auth claude --resume <session-id>
Codex works the same way with different paths. It keeps each conversation as a rollout-…-<id>.jsonl file under ~/.codex/sessions/, in dated folders. Copy it to the same relative path under the server's ~/.codex/sessions, rewrite the paths, sign in with codex login, and run codex resume <id> (see the Codex CLI features page).
People have scripted this. claude-hop is one open-source tool for syncing Claude Code sessions between machines; read its README for what it covers and how. And if you only need the gist, not the full history, /export the conversation and paste the parts that matter into a fresh session on the server.
How does Zoes hand off a session?
Zoes runs agents on other machines through pocketd, its daemon. Since 0.1.58 it can move a session from your Mac to one of those machines.
- Add the machine as a host in Settings › Hosts. Zoes installs pocketd on it over SSH. See Run agents on another machine over SSH.
- Open the session's menu in the sidebar, or its tab's menu, and click Hand off to a host…. From the command palette, the row reads Hand off “<title>” to a host….
- Pick a host. Zoes checks each connected host and marks it Ready, Not ready or Summary only. Under What moves, the sheet lists the branch and its commits, the changed files, and the conversation.
- Click Hand off.
The progress sheet, Handing off to <host>, runs these steps:
- Stop this turn, only if the agent is working.
- Pack the code: one git bundle with the branch, plus a commit of every uncommitted and untracked file. Your worktree and its index are left as they are, and the bundle leaves out commits origin already has.
- Send to <host>, with the bundle's size.
- Make the worktree: a new worktree on the host, in
~/.zoes/worktrees/<repo>/, on the same branch, with the uncommitted files laid back as uncommitted changes, not commits. - Bring the conversation: the transcript, with this Mac's paths rewritten to the host's, written where the agent on the host looks for it. A path that only starts the same, like
app2, stays as it is. - Start <agent>, with the same model and effort, continuing the moved conversation.
- Check the history: waits until the host's session is open on that conversation.
While the conversation uploads, the step shows how many megabytes have arrived, with a bar. From 0.1.59, a host whose pocketd is as new sends it as zstd frames; the pull request that added them measured about 4× fewer bytes on the wire. An older host gets plain pieces at the old speed until you update its pocketd.
The sheet says to keep the Mac awake until it's done. You can hide it; the handoff keeps going. Until the host's agent starts, Cancel handoff stops it and removes the worktree it made on the host.
When something goes wrong
- If the host goes offline, the sheet says <host> went offline and that it retries when the host is back. It does that on its own, or you click Retry now.
- If making the worktree fails, Zoes removes the worktree and the branch it added on the host. If you close a stopped handoff instead of retrying, it removes them too, unless the agent may already have started there.
- The Mac session is not closed. A stopped handoff says Nothing changed on this Mac., or that the session is still here and only its turn stopped.
When it's done, the sheet says the agent made it to the host: It picks up where you left off. You can close this Mac. Open on <host> takes you to the session on the host. The Mac session stays, with its own copy of the conversation.
What does the host need first?
Zoes checks the host before it sends anything. Each problem comes with the command to run there, a Copy button and Open terminal, which opens a shell on the host. Then click Check again.
| What the check finds | Command it gives |
|---|---|
| The project isn't on the host | git clone <origin> ~/code/<repo> |
| The agent isn't signed in on the host | claude auth login or codex login |
| The branch is already on the host with commits this Mac doesn't have, or checked out there | git branch -m <branch> <branch>-old |
| The host isn't answering | None; pocketd must be online |
Zoes doesn't fix the host itself. It finds the host's clone by origin URL, so the folder can be anywhere among the host's projects or at ~/code/<repo>. The session must be on a branch, not a detached HEAD. Files your .gitignore excludes, such as .env or node_modules, don't travel, and the project's setup script doesn't run on the host, so install dependencies there yourself.
What about other agents?
The conversation moves only for Claude Code and Codex, and only for sessions Zoes started, since it needs the agent's own session id to find the transcript. For other agents, and for sessions Zoes didn't start, the host reads Summary only. The code still moves the same way, but the conversation itself doesn't.
Instead, a fresh session starts on the host from a summary. Zoes drafts it from the session's title, branch and changed files, your last request and the agent's last reply, and you edit it before Move code & start. It becomes the new session's first prompt. When it's done, the sheet says a fresh agent is up on the host and that the Mac session stays open.
By hand, tmux or Zoes: how do they compare?
| By hand | ssh + tmux from the start | Zoes hand off | |
|---|---|---|---|
| Moves code, uncommitted files included | Yes, with a WIP commit or a copy | Nothing to move | Yes, untracked files included, ignored files left out |
| Moves the conversation | Yes, you copy the JSONL | Nothing to move | Claude Code and Codex sessions it started |
| Rewrites paths | Yes, with sed; also hits lookalike paths | Not needed | Yes, whole paths only |
| Agents covered | Any whose transcript you can find and fix | Any CLI agent | Claude Code and Codex with the conversation; others start from a summary |
| Needs on the other machine | Clone, agent signed in, SSH | Clone, agent signed in, SSH, tmux | Clone, agent signed in, pocketd (installed over SSH) |
| GUI | No | No | Yes, Mac app |
| Breaks when the transcript format changes | Can | No | Can, like any tool that edits it |
The handoff goes one way: from a session on this Mac to a connected host.
When is plain ssh + tmux better?
If you always work on the server, start there. A session that never moves has no paths to rewrite and no internal format to depend on. ssh, tmux, and the agent CLI are enough, and they work from any terminal.
Zoes can work that way too. Press ⌘K, choose Open folder on a host…, and the host's project shows in your sidebar; its sessions run on the host from the start (docs). Sessions there keep running when you close the window, as Keep coding agents running after you close the window explains. The handoff is for the session you started on your Mac before you knew it would need the server.
Zoes is free and MIT licensed, and runs the Claude Code and Codex you already have.
Star Zoes on GitHub Download for MacFAQ
Does claude --resume work after copying the transcript?
Yes, if the transcript sits in the project folder Claude Code expects for the directory you run it in, and the paths inside it point at that directory. Run claude --resume <session-id> from the project folder on the new machine.
Do I need to commit before moving a session?
Not with Zoes. It packs uncommitted and untracked files into a temporary commit, and lays them back on the host as uncommitted changes. Files your .gitignore excludes stay behind. By hand, you need some way to carry them: a WIP commit you undo on the server, or a copy of the files.
Does it work for Codex?
Yes. Codex keeps each conversation as a rollout JSONL file under ~/.codex/sessions. Zoes carries Claude Code and Codex conversations. For other agents it moves the code and starts a fresh session from a summary.
Is the session on my Mac deleted?
No. Zoes never closes the Mac session. Once the handoff is done, the host has its own copy of the conversation, and the Mac session reads as before. If a step fails, the Mac session is still there.
What OS can the host run?
Zoes hosts can run macOS, Linux or Windows, on arm64 or amd64. The handoff runs git and sh on the host and builds Unix paths, so use a macOS or Linux host for it.