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
Строк Оплати

VPS.S1

$5.99 Save  17 %
$4.99 Щомісячно
  • 2 vCPU AMD EPYC
  • 2 GB RAMПАМʼЯТЬ
  • 30 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено

VPS.S3

$14.99 Save  33 %
$9.99 Щомісячно
  • 4 vCPU AMD EPYC
  • 6 GB RAMПАМʼЯТЬ
  • 70 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено

EPYC VPS.P1

$8.99 Save  22 %
$6.99 Щомісячно
  • 2 vCPU AMD EPYC
  • 4 GB RAMПАМʼЯТЬ
  • 40 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

EPYC VPS.P2

$16.99 Save  24 %
$12.99 Щомісячно
  • 2 vCPU AMD EPYC
  • 8 GB RAMПАМʼЯТЬ
  • 80 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

EPYC VPS.P4

$29.99 Save  23 %
$22.99 Щомісячно
  • 4 vCPU AMD EPYC
  • 16 GB RAMПАМʼЯТЬ
  • 160 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

EPYC VPS.P5

$39.99 Save  25 %
$29.99 Щомісячно
  • 8 vCPU AMD EPYC
  • 16 GB RAMПАМʼЯТЬ
  • 180 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

EPYC VPS.P6

$59.99 Save  25 %
$44.99 Щомісячно
  • 8 vCPU AMD EPYC
  • 32 GB RAMПАМʼЯТЬ
  • 200 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

EPYC VPS.P7

$69.99 Save  29 %
$49.99 Щомісячно
  • 16 vCPU AMD EPYC
  • 32 GB RAMПАМʼЯТЬ
  • 240 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

Genoa VPS.G2

$24.99 Save  20 %
$19.99 Щомісячно
  • 2 vCPUAMD EPYC Genoa 4-го покоління 9xx4 з 3,25 GHz або подібний, на архітектурі Zen 4. AMD EPYC G4
  • 4 GB DDR5ПАМʼЯТЬ
  • 50 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

Genoa VPS.G4

$44.99 Save  22 %
$34.99 Щомісячно
  • 4 vCPUПроцесор AMD EPYC з виділеними ядрами vCPU, на серверному обладнанні корпоративного класу. AMD EPYC G4
  • 8 GB DDR5ПАМʼЯТЬ
  • 100 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

Genoa VPS.G6

$89.99 Save  22 %
$69.99 Щомісячно
  • 8 vCPUПроцесор AMD EPYC з виділеними ядрами vCPU, на серверному обладнанні корпоративного класу. AMD EPYC G4
  • 16 GB DDR5ПАМʼЯТЬ
  • 200 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

Genoa VPS.G7

$159.99 Save  22 %
$124.99 Щомісячно
  • 8 vCPUПроцесор AMD EPYC з виділеними ядрами vCPU, на серверному обладнанні корпоративного класу. AMD EPYC G4
  • 32 GB DDR5ПАМʼЯТЬ
  • 250 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах. включено
  • Безкоштовний авто бекапМістить один слот резервного копіювання, який можна налаштувати на щоденний, щотижневий або щомісячний запуск.

AMD Ryzen VPS.R1

$16.99 Save  18 %
$13.99 Щомісячно
  • 1 виділений CPU AMD Ryzen 9 7950X з 4,5 GHz або подібний, на архітектурі Zen 4. vCPU
  • 4 GB DDR5ПАМ'ЯТЬ
  • 50 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6 включено Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах.
  • Авто бекап включено

AMD Ryzen VPS.R2

$29.99 Save  17 %
$24.99 Щомісячно
  • 2 виділених CPU AMD Ryzen 9 7950X з 4,5 GHz або подібний, на архітектурі Zen 4. vCPU
  • 8 GB DDR5ПАМ'ЯТЬ
  • 100 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6 включено Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах.
  • Авто бекап включено

AMD Ryzen VPS.R4

$109.99 Save  18 %
$89.99 Щомісячно
  • 8 виділених CPU AMD Ryzen 9 7950X з 4,5 GHz або подібний, на архітектурі Zen 4. vCPU
  • 32 GB DDR5ПАМ'ЯТЬ
  • 400 GB NVMeСХОВИЩЕ
  • Безлімітний трафік
  • IPv4 & IPv6 включено Підтримка IPv6 наразі недоступна у Франції, Фінляндії чи Нідерландах.
  • Авто бекап включено

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.