#21: Naming and Resuming Sessions 📼
Today we'll look at how Claude Code sessions work: naming them, getting back to them, and branching off to try something different.
A session is a saved conversation tied to a project directory. Claude Code saves it continuously as we work, so closing the terminal (or running /clear) doesn't lose anything. Let's dive in.
Picking Up Where We Left Off
There are a few ways back in:
claude --continue # most recent session in this directory
claude --resume # open the session picker
claude --resume auth-fix # jump straight to a named session
claude --from-pr 128 # sessions linked to a pull requestInside a running session, /resume switches to a different conversation without quitting.
A resumed session brings back the conversation, the model it was using, and usually its permission mode. Flags like --mcp-config, --settings, and --add-dir aren't restored, so we pass those again if the session needed them.
Naming Sessions
Unnamed sessions get a generated title from our first prompt, but a real name is much easier to find again:
claude -n hal-auth-refactor/rename hal-auth-refactorThe name also shows up on the prompt bar. Once it's named, claude --resume hal-auth-refactor takes us right back. This matters most when we've got a few tasks going in parallel.
The Session Picker
claude --resume with no name opens a picker. A few keys worth knowing:
Space preview a session
Ctrl+R rename the highlighted session
Ctrl+B only sessions from the current git branch
Ctrl+W widen to every worktree of this repo
Ctrl+A widen to every project on this machineTyping almost anything else searches. We can even paste a pull request URL to find the session that created it. Neat!
Branching A Session
Sometimes we want to try a different approach without losing the path we're on. /branch copies the conversation so far and switches us into the copy:
/branch try-streaming-approachThe original stays untouched in the picker. From the shell, the same thing is --fork-session:
claude --continue --fork-sessionGetting Data Out
/export copies the conversation to our clipboard or saves it as a readable text file. For scripts, it's better to ask a session directly:
claude -p --resume <session-id> --output-format json \
"summarize what we changed" | jq -r '.result'Under the hood, transcripts live as JSONL in ~/.claude/projects/<project>/<session-id>.jsonl. The format is internal and changes between versions, so scripts that parse those files directly can break on any release.
Watch Out
Resuming the same session in two terminals without forking makes the messages from both interleave into one transcript. Branch first if we want two lines of work.
Sessions started with claude -p or the Agent SDK don't show up in the picker or in --continue. We can still resume them by passing the session ID to --resume.
More info about sessions can be found at the Claude Code docs.