Managing Claude Code sessions: resume, name, branch and export
TL;DR
Every Claude Code conversation is a session you can return to: --continue for the latest, --resume to pick, /rename to name, /branch to try another approach. Transcripts are kept 30 days by default; resuming a long session after a break costs more than you'd think.
Yesterday you were halfway through a refactor with Claude Code; today you open a new terminal and it's all blank. Or you want to try another approach without losing the current one. Claude Code saves every conversation as a session tied to the project directory, with tools to resume, name, branch and export them. Mastering them saves you from re-explaining context, which also saves tokens.
Resuming a session
| Command | What it does |
|---|---|
claude --continue | Reopens the most recent session in the current directory |
claude --resume | Opens the session picker |
claude --resume <name> | Resumes a named session directly |
claude --from-pr <number> | Filters to sessions linked to that pull request |
/resume | Switches to another session from inside the running one |
A resumed session restores the conversation history, the model, the permission mode (for most terminal resume routes) and even an active goal. But some launch flags such as --mcp-config, --settings and --add-dir must be passed again.
Name sessions so you can find them
claude -n auth-refactor # name at startup
/rename auth-refactor # rename mid-session
claude --resume auth-refactor
Unnamed sessions still get a title generated from the first prompt that works for resuming, but your own names are far easier to remember when running several tasks in parallel.
The session picker
Space: preview the content;Ctrl+R: rename.Ctrl+W: widen to all worktrees of the repo;Ctrl+A: every project on the machine;Ctrl+B: only the current git branch.- Paste a pull request URL into the search to find the session that created it.
Branch to try another approach
/branch try-streaming-approach # inside a session
claude --continue --fork-session # from the command line
Branching copies the conversation up to that point and switches you into the copy; the original stays intact. If you resume the same session in two terminals without forking, messages from both interleave into one transcript.
Where it's stored and for how long
- Transcripts are JSONL files at
~/.claude/projects/<project>/<session-id>.jsonl. - They're kept for 30 days by default; change it with
cleanupPeriodDays. /exportwrites a readable text transcript; the JSONL format is internal and changes between versions, so don't write scripts that parse it directly.
Risks and caveats
- Resuming a long session after a break is expensive: the cache has expired, so the first turn rereads everything; Claude Code may ask "Resume this conversation?" with an estimate of the usage it will take.
- Transcripts contain everything: code, command output, possibly secrets printed to the terminal. Protect your
~/.claudedirectory. -pand SDK sessions don't appear in the picker: resume them by session ID.
How to apply it
- Dev: Name sessions after tickets or branches; at the end of the day
/clearinstead of letting a session grow forever, and--resumetomorrow if needed. - Tech Lead: Use
/branchbefore big design decisions so there's a way back. - PM:
/exportan incident-investigation session as postmortem material.
Sources & references
- Manage sessions — Claude Code Docs