One of the most underused features in Claude Code is session management. Most developers just open a new session every time, which means re-explaining the codebase, restating context, and repeating setup work on every return.
Claude Code stores every session. With the right flags, you can resume exactly where you left off — whether your connection dropped, you switched machines, or you deliberately paused a complex refactor to handle something urgent.
This guide covers every session management feature available as of June 2026.
Why Session Context Matters
When you start a fresh Claude Code session and ask it to continue a task, you’re not resuming — you’re rebuilding. Claude has to re-read files, re-understand the codebase structure, and reconstruct the mental model of what was being attempted.
A resumed session carries:
- Full conversation history
- All file reads and diffs from the previous session
- The reasoning chain behind previous decisions
- Awareness of what has already been tried and failed
For long refactors, architecture discussions, or debugging sessions spanning hundreds of tool calls, this context has real value. Losing it means starting over.
Session Storage
Claude Code stores sessions at:
~/.claude/projects/<project-path>/<session-id>.jsonl
Each session is a JSONL file (newline-delimited JSON), with one event per line. Sessions are kept for 30 days by default. To change the retention period:
// ~/.claude/settings.json
{
"cleanupPeriodDays": 90
}
Set to 0 to keep sessions indefinitely (disk space permitting).
The Core Flags
--continue / -c: Resume the Latest Session
# Resume the most recent session in the current project
claude --continue
claude -c # shorthand
This is the fastest way to return to where you left off. No picker, no searching — it finds the most recent session for your current working directory and opens it.
Works with -p for headless use:
claude -c -p "Continue the database migration from where we left off"
--resume / -r: Interactive Session Picker
# Open the interactive session picker
claude --resume
claude -r # shorthand
# Resume a specific session by name or UUID
claude --resume auth-refactor
claude --resume 7f3a9c2b-...
The picker shows sessions grouped by recency, with timestamps and a preview of the last message in each session.
Picker keyboard shortcuts:
| Shortcut | Action |
|---|---|
Ctrl+A | Show all sessions across all projects on this machine |
Ctrl+W | Show sessions across all worktrees of the current repository |
Ctrl+B | Filter to sessions on the current git branch |
/ | Search mode — type to filter sessions |
Paste a GitHub PR URL directly into the picker to find sessions associated with that PR.
--from-pr: Resume a Session Linked to a PR
claude --from-pr 482
claude --from-pr https://github.com/org/repo/pull/482
When you started a Claude Code session while working on a PR and that session was associated with the PR, this flag finds it. Useful when returning to a PR review after a few days.
Naming Sessions
Anonymous sessions get auto-generated names. Named sessions are searchable and meaningful:
# Start a new named session
claude -n "payment-gateway-refactor"
claude --session-name "fix-race-condition-auth"
Rename a session mid-conversation:
/rename payment-v2-migration
The session name appears in the prompt bar when active, making it easier to know which context you’re in when multiple sessions are running.
Forking a Session
Sometimes you want to branch from a session without affecting the original — for example, trying an alternative approach to the same problem.
# Resume a session but fork it (creates a new session branching from the resumed one)
claude --continue --fork-session
claude --resume auth-refactor --fork-session
The original session is preserved exactly as-is. The fork starts from the same context but is treated as an independent session going forward. Changes in the fork don’t affect the original.
This is particularly useful for:
- Testing two different implementation approaches without losing either
- Exploring a risky change while keeping a clean recovery point
- Handing off a session to a teammate while keeping your own copy
The /resume Command (In-Session)
To switch sessions without exiting:
/resume
Opens the same interactive picker from within an active session. The current session is automatically saved.
Exporting a Session
To save the full session for documentation, handoff, or archival:
/export
Copies the session transcript to the clipboard. With a filename argument, writes to disk:
/export session-auth-refactor-2026-06-17.md
The export includes all conversation turns, tool calls, and file operations in a readable format.
Checkpointing: Rewind Without Losing Work
Separate from session resumption, Claude Code also checkpoints automatically at each user prompt. These checkpoints let you rewind within a session — not just resume across sessions.
To access checkpoints:
- Press
Esctwice when the input field is empty - Type
/rewind
The checkpoint picker shows every user turn in the current session. For each checkpoint, you have five actions:
| Action | What It Does |
|---|---|
| Restore code and conversation | Reverts both the conversation and all file changes to this point |
| Restore conversation | Reverts only the conversation; keeps file changes as-is |
| Restore code | Reverts only the file changes; keeps the conversation as-is |
| Summarize from here | Compresses all messages after this point into a summary (/compact variant) |
| Summarize up to here | Compresses all messages before this point into a summary |
Important limitation: Checkpointing tracks files modified through Claude Code’s file editing tools. Files changed by Bash commands (e.g., sed, mv, git checkout) are not tracked and won’t be reverted.
This is different from --fork-session. Forking creates a separate session from a resumed point. Checkpointing rewinds within the current session.
Practical Patterns
Pattern 1: Daily Continuation
Start each day by continuing yesterday’s session on the feature you’re working on:
# Start with context from yesterday
claude -c
# Or be explicit about which task
claude --resume feature-user-auth
This is faster than explaining “I’m working on the user authentication flow, the JWT implementation is in src/auth/, and we were in the middle of implementing refresh token rotation…”
Pattern 2: Safe Exploration with Fork
Before making a risky structural change:
# Save the current state and branch from it
claude --continue --fork-session -n "try-new-db-schema"
If the experiment goes badly, the original session is intact. Return to it with --resume.
Pattern 3: Parallel Work on Multiple Features
# Session for feature A
claude -n "feature-analytics-v2" --bg "Implement the analytics dashboard, start with the data model"
# Session for feature B in a different terminal
claude -n "feature-notifications" --bg "Build the notification system, email + push"
# Check all running sessions
claude agents
# Attach to whichever finishes first
claude attach feature-analytics-v2
Pattern 4: Handoff Documentation
Before handing off a complex session to a teammate or archiving it:
/export handoff-feature-payments-2026-06-17.md
The export gives a complete record of decisions made, approaches tried, and the current state of the work.
Headless Session Resumption
For automation, session context can be passed through --session-id:
# Get the session ID of the last session
LAST_SESSION=$(claude -p "" --output-format json 2>/dev/null | jq -r '.session_id' | head -1)
# Resume that session in a later job
claude -p "Continue the task" --session-id "$LAST_SESSION" --output-format json
Or capture the session ID when starting:
SESSION_DATA=$(claude -p "Start analyzing the API for rate limit issues" --output-format json)
SESSION_ID=$(echo "$SESSION_DATA" | jq -r '.session_id')
# Save for later
echo "$SESSION_ID" > .claude-session-id
# Resume in next CI step
claude -p "Report findings and suggest fixes" \
--session-id "$(cat .claude-session-id)" \
--output-format json
Troubleshooting
--continue opens a fresh session instead of resuming
The most common cause: the previous session is in a different working directory. Session lookup is project-path based. If you opened Claude Code from ~/projects/myapp/src last time and you’re now in ~/projects/myapp, they’re treated as different projects.
Solution: always run Claude Code from a consistent root directory for a given project, or use --resume with an explicit session name.
Session picker shows no recent sessions
Sessions older than cleanupPeriodDays (default 30 days) are deleted. If the project path changed (rename, move), sessions won’t appear for the new path.
Checkpoint rewind didn’t restore a file
Files modified by Bash commands aren’t checkpointed. If Claude ran git checkout -- src/auth.ts or used sed -i to modify a file, that change is outside the checkpoint scope. Only edits made through Claude Code’s built-in file tools are tracked.
Summary
| Goal | Command |
|---|---|
| Continue most recent session | claude --continue or claude -c |
| Pick a session interactively | claude --resume or claude -r |
| Resume by name | claude --resume session-name |
| Resume from a PR | claude --from-pr 482 |
| Start a named session | claude -n "name" |
| Fork a session before risky work | claude --continue --fork-session |
| Switch sessions mid-conversation | /resume |
| Export session transcript | /export |
| Rewind within a session | /rewind or double Esc |
| List all running sessions | claude agents |
The session system in Claude Code is sophisticated enough to support multi-day workflows, parallel tracks, safe experimentation, and handoffs. Most developers are leaving significant productivity on the table by starting fresh every time.
Related
- Claude Code GitHub Actions: Complete CI/CD Integration Guide
- Claude Code Multi-Agent Orchestration Patterns
- Claude Code Headless PR Review with CI
- Claude Code Checkpoints & /rewind: Complete Guide 2026 — restore code, conversation, or both to any prior session state