shedix

Move a Claude Code conversation to another machine

Every Claude Code conversation is a file on disk. Copy that file to another machine, put the code next to it, and you can resume the conversation there with its full history. That's how you hand a long session from your laptop to a machine that won't sleep, and back again later.

Where the file lives

Claude Code stores each session as JSON Lines at ~/.claude/projects/<project>/<session-id>.jsonl (sessions docs). <project> is the working directory's path with every character that isn't a letter or a digit replaced by -, which turns each / into a -:

/Users/sam/code/myapp   ->  ~/.claude/projects/-Users-sam-code-myapp/
/home/dev/work/myapp    ->  ~/.claude/projects/-home-dev-work-myapp/

To print the folder name for the directory you're in:

pwd | sed 's/[^a-zA-Z0-9]/-/g'

Very long paths are cut to 200 characters with a hash of the full path added, so check that the folder exists before you rely on the name.

Inside the folder, each .jsonl file is one conversation, named by its session ID. The newest file is usually the one you just used:

ls -t ~/.claude/projects/-Users-sam-code-myapp/ | head -3

Transcripts are kept for 30 days by default (the cleanupPeriodDays setting changes that). The format is internal to Claude Code and changes between versions, so copy the file whole and don't edit it.

Copy the code, then the conversation

The conversation refers to files by their paths, so the project has to exist on the new machine first. Push your branch and clone it there, or copy the working tree with rsync, which also brings untracked files such as .env:

rsync -az --exclude node_modules ./ dev@203.0.113.10:~/work/myapp/

Then copy the session file into the folder that matches the new path:

ssh dev@203.0.113.10 'mkdir -p ~/.claude/projects/-home-dev-work-myapp'
scp ~/.claude/projects/-Users-sam-code-myapp/SESSION_ID.jsonl \
  dev@203.0.113.10:~/.claude/projects/-home-dev-work-myapp/

If you started the conversation in the Claude desktop app, or turned on Remote Control, each line also carries the ID of its claude.ai session (bridgeSessionId). A copy that keeps it takes over that link: open the session from your phone and you get the laptop's conversation, while the new machine's never shows up. Copy it without that field instead:

python3 -c 'import json, sys; [print(json.dumps({k: v for k, v in json.loads(l).items() if k != "bridgeSessionId"}, ensure_ascii=False)) for l in sys.stdin if l.strip()]' \
  < ~/.claude/projects/-Users-sam-code-myapp/SESSION_ID.jsonl \
  | ssh dev@203.0.113.10 'cat > ~/.claude/projects/-home-dev-work-myapp/SESSION_ID.jsonl'

Put it in one folder only. When you resume by ID, Claude Code looks in the current project first and then in every other project on the machine. A copy in a second folder can make it report the session as not found rather than pick one.

Sign in on the new machine

Your sign-in doesn't travel with the conversation, and it shouldn't. On macOS, Claude Code keeps it in the Keychain; on Linux, in ~/.claude/.credentials.json with mode 0600 (authentication docs). Run claude on the new machine and log in. If the machine has no browser, open the login link on any device, and if the browser shows a code after you sign in, paste it at the Paste code here if prompted prompt.

Resume it inside tmux

Start tmux in the project folder so the session outlives your SSH connection, then resume:

ssh dev@203.0.113.10
cd ~/work/myapp
tmux new -s claude
claude --resume SESSION_ID

From the same folder there are other ways in. claude --continue opens the most recent conversation for that directory, claude --resume with no ID shows a picker, and --resume also accepts the absolute path to a .jsonl file. Add --fork-session to continue in a copy with a new ID and leave the original untouched.

Detach with Ctrl-b d and close the laptop. Reattach later with tmux attach -t claude, as the tmux manual describes.

Two habits help. The earlier messages mention paths from your laptop, so start with a line that says where the project lives now. And don't keep working in the old copy on your laptop at the same time: the two files will drift apart into two different conversations. When you want it back, copy the newer file the other way.

What doesn't come along

The file carries the conversation: your messages, Claude's replies, the tool calls and their results, and the model it was using. A lot stays behind:

  • Your sign-in, as above.
  • Files outside the project. Anything the conversation touched elsewhere on your laptop isn't on the new machine.
  • MCP servers. Servers added at local or user scope live in ~/.claude.json on your laptop, and local ones are filed under the old project path (MCP docs). Only project servers in a committed .mcp.json travel with the repository. Add the others again on the new machine.
  • Settings and flags. User settings in ~/.claude/settings.json stay on the laptop. If the session depended on flags such as --mcp-config, --settings or --add-dir, pass them again when you resume.
  • Running work. A command that was still running when you left isn't rerun, and background tasks don't restart. Ask Claude to run them again.
  • Skipped permissions. A session that was in bypassPermissions resumes in the normal starting mode unless you launch with that mode again.

How shedix does it

shedix's guide for agents, /agents.md, includes these exact steps, so you can ask the agent on your laptop to make the move for you. It starts a machine, puts the code in ~/work/<repo>, copies the conversation into ~/.claude/projects/-home-dev-work-<repo>/, and resumes it in a tmux session called claude.

You sign in to Claude Code once, in the machine's own terminal; shedix never sees that sign-in. After that, the Claude Code terminal tab on the machine page attaches to the same tmux session, from any browser or your phone, and the agent keeps working when your laptop is closed.

Close the laptop walks through the hand-off on shedix. Start a machine when you have a session worth moving.