[FEATURE] Transfer session to another claude code instance
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Feature Request: Portable / transferable sessions between Claude Code instances
Summary
Provide a first-class way to transfer a Claude Code CLI session: its full transcript, resumability, and associated project memory from one machine to another, so that claude --resume <session-id> works on a different host than the one the session started on.
Problem
Session transcripts are stored as machine-local JSONL files under ~/.claude/projects/<path-derived-dir>/<session-id>.jsonl, with no built-in sync or export/import. The existing machine-independence features don't cover the common infra-team workflow:
- Cloud sessions /
--remote/--teleportmove execution onto Anthropic's cloud sandbox â^@^T unusable when the work requires the local environment (GPUs, mounted NFS datasets, internal APIs reachable only from the pod). - Remote Control (
--remote-control) only steers a running local session from a browser/phone; it dies with the original machine. CLAUDE_CONFIG_DIRpointed at shared storage is undocumented/partially implemented (GH #25762, #3833, #30538) and unsafe over NFS.- The only workaround today is hand-tarring
~/.claudebetween hosts â^@^T which is fragile, unofficial, and dangerous by default because~/.claudealso contains live credentials (.credentials.json); a naive copy to shared storage or S3 leaks auth tokens.
Proposed Solution
claude session export <session-id> [--out file]produces a self-contained, credential-free archive (transcript, project memory, optionally plans/file-history).claude session import <file>on another machine egisters it soclaude --resume <session-id>just works (validating/re-mapping the working-directory path).
Alternative Solutions
opt-in encrypted session sync via the user's Anthropic account, keeping execution local.
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
I run long, stateful engineering sessions with Claude Code on ephemeral GPU dev pods (Kubernetes). Mid-project, the pod gets replaced e.g. moving from a 1-gpu H100 pod to an 8-gpu^WH100 pod to scale up a training run. The repo, shared NFS, and datasets all carry over; the session — hours of accumulated context: architectural decisions, verified numerical results, in-flight experiment state, agent memory — does not. Losing it means re-explaining the project or relying on hand-written handoff docs, which are lossy compared to the actual transcript. Pods are never concurrent, so this is a pure migrate-and-resume scenario, not a sync problem.
3 Comments
The credential-safe export/import gap is real and the workaround you describe (hand-tarring ~/.claude) is exactly as fragile as it sounds. The credentials.json co-location problem is what makes any naive sync approach dangerous.
A few things worth noting from hands-on experience running multi-session workflows across machines:
The proposed export/import surface (claude session export producing a credential-free archive) is the right shape. Would also be useful as the transport layer for the handoff pattern in orchestration setups where a session on one machine finishes a phase and needs to hand context to a session on another machine to continue.
This is almost exactly the problem I built CtxHop for.
It transfers Claude Code sessions between machines while keeping credentials out of the sync payload, and uses your own R2/S3-compatible storage for transport.
After restoring on the target machine, you can continue with Claude Code’s native resume flow.
https://github.com/CCCCY-ci/ctxhop
Workaround that solves the "no chats after switching accounts" problem (not exactly session export/import, but the same underlying pain point)
This issue is about exporting/importing a session file safely (no leaked credentials), but I ran into the closely related problem — switching Claude accounts and losing access to chats started under the other one — and found a working solution I haven't seen documented anywhere, including in this issue or in the code-server discussions about Claude Code integration. Sharing in case it helps others who land here searching for the same thing.
The setup: two isolated
code-server(VS Code server) containers, each running the Claude Code extension logged into a different account (separateCLAUDE_CONFIG_DIR, separate.credentials.json— no credentials ever move or get exported). Both containers mount the same host directory as theirprojects/history folder (the one underCLAUDE_CONFIG_DIR/projects/<mangled-cwd>/). Both also need to run with the exact samecwd(down to the literal string) for their Claude sessions — the folder name underprojects/is a mangling of the absolute cwd, so any mismatch silently creates a separate, unshared history folder.With that in place:
.jsonl— samesessionId, no duplicate writers, no corruption) across both code-server instances, the claude.ai web app, and the mobile app, in real time, regardless of which account you're currently logged into in either container..jsonlfile into the shared localprojects/folder — not all messages get imported, but enough of the transcript to recover context. From that point it behaves like any other local session: resumable via--resume, visible in "Local", and (via/remote-controlinside that chat) it re-syncs back out to claude.ai/app under whichever account is currently active, keeping its original title.This obviously requires infra you control (a container host, not something claude.ai gives you directly), and it's a workaround around the product's account-boundary rather than a real "export session" feature — but it fully solves "I have chats trapped under an account I can't currently use" without ever touching/leaking credentials, which seems to be the core concern in this issue too. Happy to share the full docker-compose if useful to anyone.