Back to Article List

Claude Code sessions: Resume, save and export conversations

Claude Code sessions: Resume, save and export conversations

Forty minutes into a refactor on a remote box, my SSH connection dropped and took the Claude Code session down with it. Recovery was one command after reconnecting: claude --continue, and the whole conversation plus the half-finished task came straight back. That save works because sessions are plain files on disk with a set of commands wrapped around them, and once you know the layout you can resume, branch, export and audit conversations however you like. Everything below was tested on the 2.1 CLI on Ubuntu 24.04.

Where Claude Code stores sessions

Every session is a JSONL transcript at a predictable path:

~/.claude/projects/<project-dir-slug>/<session-id>.jsonl

The slug is derived from the project directory (slashes become dashes), and each line of the file is one JSON event: a user message, an assistant reply, a tool call with its result. Plain text means greppable, which has already earned its keep for me when I needed to find which past session ran a particular schema change:

grep -l "ALTER TABLE" ~/.claude/projects/-home-user-api/*.jsonl

Transcripts don't live forever. Retention is controlled by cleanupPeriodDays and defaults to 30 days, after which old sessions get cleaned up. If yours double as an audit trail, raise it (the FAQ below covers how). The lifecycle details sit in the official sessions documentation.

claude --continue vs claude --resume

claude --continue (short form -c) reopens the most recent session for the current directory without showing a picker. It's the right tool nine times out of ten and the one to reach for after a crash or a dropped connection. claude --resume (-r) opens an interactive picker of past sessions instead and also accepts a session id or name directly:

claude --continue
claude --resume
claude --resume auth-refactor

Both are scoped to the directory you run them in, so cd into the project first; a resume attempt from the wrong folder finds nothing and that absence confuses people more than any error message would. Names come from the --name flag at launch or /rename later, and named sessions make the picker worth opening.

The third option, --fork-session, resumes a copy rather than appending to the original. I use it to try a second approach against the same conversation history without polluting the transcript I may want to return to. All three flags are listed in the CLI reference.

Switch sessions without restarting

Inside a running session the same machinery is reachable as slash commands. /resume opens the picker, /clear ends the current session and starts a fresh one (the old transcript stays on disk), /branch splits a new session off the current conversation and /rename sets the name the picker will show. I run /clear liberally because long conversations bloat the context window, and /rename right before stopping for the day, since "auth-refactor" reads a lot better than a UUID the next morning.

What a resumed session restores

Resume brings back the conversation history, the model selection and the agent you were running, and it keeps the permission mode with two exceptions: plan and bypassPermissions are never restored, a deliberate safety choice I dug into in the piece on Claude Code plan mode. Command-line flags don't survive either: anything you passed with --mcp-config or --add-dir (and --settings) has to be passed again.

claude --resume auth-refactor --mcp-config ./mcp.json --add-dir ../shared-lib

Forgetting this produces a classic confusion: the resumed session answers questions from history perfectly, then stumbles the moment it reaches for an MCP tool that's no longer attached. The clean fix is moving servers out of flags entirely; project-scoped servers live in a checked-in .mcp.json and load on every start, which the Claude Code MCP configuration guide covers scope by scope.

Export a Claude Code conversation

For a human-readable copy, /export does it in-session:

/export session-notes.txt

That writes a plain-text transcript to the file you name, good enough for pasting into a PR description or handing a teammate the context of a decision. For anything structured, script it instead. Headless mode plus resume turns any old session into something you can query:

claude -p --resume <session-id> --output-format json "summarize the decisions made in this session and list every file we changed"

That resumes the session non-interactively, runs one prompt against the full history and emits JSON you can pipe through jq. I keep a small script that walks the week's sessions this way and produces a Friday digest of what the agent changed and why. And since the JSONL files are the raw source, nothing stops you from parsing them directly for tool calls or timestamps, no export step needed.

Check token usage in a session

Three commands answer the "how much have I used" family of questions. /usage (also reachable as /cost) shows the current session's token consumption. /context is the one I open more, because it visualizes what's occupying the context window right now, from memory files and MCP tool definitions to the conversation itself, so you can see exactly what to prune when the window fills up. /status rounds things out with account state: login method, organization and where you stand against your plan's limits. What those limits mean plan by plan is a separate topic, covered in Claude Code cost and usage limits.

Keep remote sessions alive with tmux

Back to the dropped SSH story. --continue made recovery painless, but I'd rather not need it, so on servers every session now starts inside tmux; a dead connection then leaves Claude working instead of killing it, and tmux attach after reconnecting skips even the resume step. The full server workflow is in the guide to running Claude Code on a VPS. That setup has quietly become my default for long agent tasks, and it's cheap to reproduce: LumaDock's Claude Code VPS hosting is a one-click template, the box comes up instantly with the CLI preinstalled and unmetered bandwidth means an agent pulling dependencies all night adds nothing to the bill. The session keeps working after the laptop lid closes.

One habit worth stealing before you go: /rename anything unfinished when you step away. Ten seconds of naming beats scrolling a picker full of auto-generated titles at nine the next morning.

Your idea deserves better hosting

24/7 support 30-day money-back guarantee Cancel anytime
Ciclo di fatturazione

VPS.S1

56.86 kr Save  17 %
47.37 kr Mensile
  • 2 vCPU AMD EPYC
  • 2 GB RAMMEMORIA
  • 30 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi

VPS.S3

141.74 kr Save  33 %
94.47 kr Mensile
  • 4 vCPU AMD EPYC
  • 6 GB RAMMEMORIA
  • 70 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi

EPYC VPS.P1

85.01 kr Save  22 %
66.10 kr Mensile
  • 2 vCPU AMD EPYC
  • 4 GB RAMMEMORIA
  • 40 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

EPYC VPS.P2

160.66 kr Save  24 %
122.83 kr Mensile
  • 2 vCPU AMD EPYC
  • 8 GB RAMMEMORIA
  • 80 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

EPYC VPS.P4

283.58 kr Save  23 %
217.39 kr Mensile
  • 4 vCPU AMD EPYC
  • 16 GB RAMMEMORIA
  • 160 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

EPYC VPS.P5

378.14 kr Save  25 %
283.58 kr Mensile
  • 8 vCPU AMD EPYC
  • 16 GB RAMMEMORIA
  • 180 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

EPYC VPS.P6

567.26 kr Save  25 %
425.42 kr Mensile
  • 8 vCPU AMD EPYC
  • 32 GB RAMMEMORIA
  • 200 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

EPYC VPS.P7

661.82 kr Save  29 %
472.70 kr Mensile
  • 16 vCPU AMD EPYC
  • 32 GB RAMMEMORIA
  • 240 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

Genoa VPS.G2

237.20 kr Save  20 %
189.74 kr Mensile
  • 2 vCPUAMD EPYC Genoa 4ª generazione 9xx4 a 3,25 GHz o equivalente, su architettura Zen 4. AMD EPYC G4
  • 4 GB DDR5MEMORIA
  • 50 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

Genoa VPS.G4

427.04 kr Save  22 %
332.12 kr Mensile
  • 4 vCPUProcessore AMD EPYC con core vCPU dedicati, su hardware server enterprise. AMD EPYC G4
  • 8 GB DDR5MEMORIA
  • 100 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

Genoa VPS.G6

854.18 kr Save  22 %
664.34 kr Mensile
  • 8 vCPUProcessore AMD EPYC con core vCPU dedicati, su hardware server enterprise. AMD EPYC G4
  • 16 GB DDR5MEMORIA
  • 200 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

Genoa VPS.G7

1518.61 kr Save  22 %
1186.39 kr Mensile
  • 8 vCPUProcessore AMD EPYC con core vCPU dedicati, su hardware server enterprise. AMD EPYC G4
  • 32 GB DDR5MEMORIA
  • 250 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi. inclusi
  • Backup automatico gratuitoInclude uno slot di backup che puoi impostare su esecuzione giornaliera, settimanale o mensile.

AMD Ryzen VPS.R1

161.27 kr Save  18 %
132.79 kr Mensile
  • 1 CPU dedicato AMD Ryzen 9 7950X a 4,5 GHz o equivalente, su architettura Zen 4. vCPU
  • 4 GB DDR5MEMORIA
  • 50 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6 inclusi Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi.
  • Backup automatico incluso

AMD Ryzen VPS.R2

284.66 kr Save  17 %
237.20 kr Mensile
  • 2 CPU dedicate AMD Ryzen 9 7950X a 4,5 GHz o equivalente, su architettura Zen 4. vCPU
  • 8 GB DDR5MEMORIA
  • 100 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6 inclusi Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi.
  • Backup automatico incluso

AMD Ryzen VPS.R4

1044.02 kr Save  18 %
854.18 kr Mensile
  • 8 CPU dedicate AMD Ryzen 9 7950X a 4,5 GHz o equivalente, su architettura Zen 4. vCPU
  • 32 GB DDR5MEMORIA
  • 400 GB NVMeDISCO
  • Banda illimitata
  • IPv4 & IPv6 inclusi Il supporto IPv6 al momento non è disponibile in Francia, Finlandia o nei Paesi Bassi.
  • Backup automatico incluso

Frequent questions

How do I keep sessions longer than 30 days?

Set cleanupPeriodDays in ~/.claude/settings.json, for example {"cleanupPeriodDays": 120}. Keep in mind that transcripts contain everything Claude read and ran, command output included, so longer retention on a shared machine is a privacy decision as much as a convenience.