Resume a session
Sessions are saved continuously to local transcript files as you work, so you can return to one after exiting or running/clear. Use these entry points:
Sessions created with
claude -p or the Agent SDK do not appear in the session picker, but you can still resume one by passing its session ID to claude --resume <session-id>. Run this from the directory the session was started in: session ID lookup is scoped to the current project directory and its git worktrees, so a session created elsewhere reports No conversation found with session ID: <session-id>.
What a resumed session restores
A resumed session restores the conversation along with the state saved in it:- Conversation history: the full history, including tool calls and results.
- Model: the session continues on the model it was using. The model isn’t restored when it has been retired or isn’t allowed by
availableModels, when a--modelflag orANTHROPIC_MODEL-family environment variable picks one at launch, or on providers that use provider-specific deployment IDs, such as Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry; see model configuration for the resolution order. - Permission mode: the mode the session was in.
planandbypassPermissionsare never restored; bypassing permissions must be enabled again at launch, with one of its launch flags orpermissions.defaultMode: "bypassPermissions"in settings.autois restored only when your account still meets the auto mode requirements. Pass--permission-modeto override the restored mode. - Active goal: a goal that was still active when the session ended carries over; its turn count, timer, and token-spend baseline reset.
- Scheduled tasks: tasks that haven’t expired are restored. Background Bash and monitor tasks aren’t.
--mcp-config, --settings, --plugin-dir, --fallback-model, or directories added with --add-dir, pass them again when you resume; directories added mid-session with /add-dir aren’t restored either, though the session picker still uses them to locate the session. The standard settings files, such as settings.json and settings.local.json, are re-read at launch, so configuration that lives in them doesn’t need to be passed again.
Where the session picker looks
Sessions are stored per project directory. By default the session picker shows interactive sessions from the current worktree, plus sessions started elsewhere that added the current directory with/add-dir. Use Ctrl+W to widen to all worktrees of the repository or Ctrl+A to widen to every project on this machine.
Sessions whose first prompt was a /loop command don’t appear in the picker; running /loop later in a conversation doesn’t hide the session. Before v2.1.211, a /loop run early in a conversation hid the session from the picker permanently.
From v2.1.169, moving a session with /cd relocates it to the new directory’s project storage, so it appears in that directory’s picker afterward. As of v2.1.196, a moved session stays out of the old directory’s picker even after a crash or forced exit. On earlier versions, it could also reappear in the old directory’s list after an exit that wasn’t clean when the old path contained special characters such as underscores.
Selecting a session from another worktree of the same repository resumes it in place. Selecting a session from an unrelated project copies a cd and resume command to your clipboard instead.
Resuming by name resolves across the current repository and its worktrees. Both forms look for an exact match and resume it directly even if it lives in a different worktree:
Name your sessions
Give sessions descriptive names so they’re findable in the session picker and resumable by name. This matters most when you’re working on several tasks in parallel.
Once a session is named, return to it with
claude --resume <name> or /resume <name>. See Resume a session for how name resolution behaves across worktrees.
Interactive sessions you never name still get a default display name when they start. Requires Claude Code v2.1.196 or later. The default combines the working directory’s name with a two-character suffix, for example my-app-3f, and identifies the session in listings of running sessions, such as agent view and claude agents --json output.
The default isn’t a resume handle: claude --resume <name>, /resume <name>, and the session picker match only names you set. Naming the session replaces the default.
If you don’t name a session, Claude Code generates a session title for it: a short summary of your first prompt, written by a background request to the small/fast model, normally a Haiku-class model. Naming the session with --name or /rename replaces the generated title. You see the generated title in the session picker and in the statusline session_name field when no name is set; like the default display name, it isn’t a resume handle.
Use the session picker
Run/resume inside a session, or claude --resume with no arguments, to open the interactive session picker. Use these keyboard shortcuts to navigate, search, and widen the list:
Each row shows the session name if you set one, otherwise the AI-generated session title, conversation summary, or first prompt, along with time since last activity, git branch, and file size. Widen to all projects with
Ctrl+A to also see each session’s project path.
Sessions created with /branch or --fork-session get their own session IDs and appear as separate rows. When the picker finds more than one entry for the same session, it groups them under a single row. Press → to expand a group.
Branch a session
Branching creates a copy of the conversation so far and switches you into it, leaving the original intact. Use it to try a different approach without losing the path you were on. From inside a session, run/branch with an optional name:
Branched conversation instead of looking past the compaction summary to the original first prompt.
From the command line, combine --continue or --resume with --fork-session:
/branch confirmation prints two session IDs: the new branch you are now in and the original. To return to the original, pass its ID to /resume, use the session picker, or run /resume <original-name>. Permissions you approved with “allow for this session” do not carry over to the new branch. If you resume the same session in two terminals without forking, messages from both interleave into one transcript.
For checkpoint-based rewind within a single session, see Checkpointing.
Manage context within a session
These commands control what’s in the context window without leaving the session:/clear: start fresh with an empty context. Claude Code saves the previous conversation; resume it with/resume, or, in the same Claude Code process, from the rewind menu’s previous-session entry. You keep a name you set with--nameor/renamein the new conversation, but not an AI-generated session title/compact [instructions]: replace history with a summary, optionally focused on what you specify/context: show what is currently consuming context
Export and locate session data
Run/export to open a menu that lets you copy the current conversation to your clipboard or save it as a plain-text file, with messages and tool outputs rendered as readable text. Pass a filename to skip the menu and write directly to that file.
Access conversations from scripts
/export produces a rendered transcript for a person to read. The interfaces below produce structured data for a script to parse: a JSON result from a run, the path to a session’s transcript file, or a live stream of events. Pick by what triggers the script:
- Run Claude once and capture the result: invoke
claude -pwith--output-format jsonorstream-jsonto capture the result, session ID, usage, and cost of a non-interactive run as structured JSON. - Ask an existing session a question: pass a session ID to
claude -p --resumeto send a follow-up prompt, such as a summary request, and capture the structured response. - React to session events: read the
transcript_pathfield that hooks and status line commands receive as input. ASessionEndhook can archive the transcript when a session ends. - Embed Claude in a TypeScript or Python app: use the Agent SDK to receive each message programmatically.
jq:
Where transcripts are stored
By default, transcripts are stored as JSONL at~/.claude/projects/<project>/<session-id>.jsonl, where <project> is your working directory path with non-alphanumeric characters replaced by -. Each line is a JSON object for a message, tool use, or metadata entry. The entry format is internal to Claude Code and changes between versions, so scripts that parse these files directly can break on any release. To build on session data, use /export or the script interfaces instead.
The location, retention, and write behavior are configurable:
See also
These pages cover related session and parallelism mechanics:- Worktrees: run isolated parallel sessions on separate branches
- Checkpointing: rewind code and conversation to an earlier point
- Context window: what fills context and what survives compaction
- Non-interactive mode: session behavior under
claude -p