Sessions, Checkpoints & Rewind
Resume, fork, branch, and time-travel
- Resume, continue, fork, branch, rename, and export sessions using the exact CLI flags and slash commands
- Use the /resume picker and its filters to find any past session, including background and SDK runs
- Open the rewind menu and choose correctly between Restore (reverts state) and Summarize (compresses context, no file change)
- Explain what checkpoints track and miss, and why they complement rather than replace git
- Reason about why sessions tie to directories not branches, and keep ~/.claude/projects/ from ballooning
A Claude Code session is a saved conversation tied to a project directory; checkpoints are an automatic, in-session undo for Claude's file edits. This lesson shows how to resume, fork, branch, rename, and export sessions, and how the rewind menu's restore-versus-summarize options let you time-travel through both code and conversation.
- 1The mental model: sessions vs. checkpoints
- 2Resuming: continue, resume, and the picker
- 3The /resume picker and its filters
- 4Branching and forking: try another approach
- 5The rewind menu: restore vs. summarize
- 6What checkpoints miss, and why directories matter
- 7Session storage, lifecycle, and cleanup
The mental model: sessions vs. checkpoints
Two recovery systems run side by side in Claude Code, and mixing them up causes most of the confusion in this area. Hold them apart from the start.
A session is a saved conversation tied to a project directory. Claude Code streams it to a local transcript file as you work, so you can exit, come back, and pick up exactly where you left off — or branch off to try a different approach. Sessions are the coarse unit: whole conversations you resume, fork, name, and export.
A checkpoint is a fine-grained snapshot taken inside a session, automatically, before Claude edits files. It is your in-session undo button. Every prompt you send creates one, so you can rewind to any earlier point and restore the code, the conversation, or both.
SESSION (one conversation, tied to a directory)
├─ checkpoint @ prompt 1 ← every user prompt snapshots Claude's edits
├─ checkpoint @ prompt 2
├─ checkpoint @ prompt 3 ← Esc Esc / /rewind to jump back here
└─ ...The key distinction: you resume a session (across time, across restarts) but you rewind within one using checkpoints. Sessions live in ~/.claude/projects/; checkpoints live attached to a session and clean up with it.
Key insight
One is a conversation, one is an undo stack
Session = the whole transcript you can leave and return to. Checkpoint = an automatic snapshot of Claude's file edits, taken before each change, that you rewind to. Resume operates on sessions; rewind operates on checkpoints.
Resuming: continue, resume, and the picker
Because every session is saved continuously, you can return to one after exiting or even after running /clear. There are three entry points from the command line plus one from inside a session.
| Command | What it does |
|---|---|
claude -c / claude --continue | Resume the most recent session in the current directory |
claude -r / claude --resume | Open the interactive session picker (no argument) |
claude --resume <id-or-name> | Resume a specific session directly by ID or name |
claude --from-pr <number> | Resume the session linked to that pull request |
/resume [session] | Switch to another conversation from inside an active session (alias /continue) |
You can also continue non-interactively — useful in scripts: claude -c -p "<query>" continues the previous session and prints the answer.
Name resolution is smart but exact. With claude --resume <name>, an exact match resumes directly; an ambiguous name opens the picker with that name pre-filled as a search term. With /resume <name>, an exact match resumes directly, but an ambiguous name reports an error — run /resume with no argument to open the picker instead.
Tip
Name sessions you'll want back
Set a name at startup with claude -n auth-refactor, mid-session with /rename auth-refactor, or from the picker by highlighting a row and pressing Ctrl+R. Accepting a plan in plan mode also auto-names the session from the plan content (unless you already set one). Named sessions are findable in the picker and resumable by name across the repo and its worktrees.
The /resume picker and its filters
Run /resume inside a session, or claude --resume with no arguments, to open the interactive picker. By default it shows interactive sessions from the current worktree, plus sessions started elsewhere that added the current directory with /add-dir. Each row shows the session name (or its summary / first prompt), time since last activity, message count, and git branch.
These keys drive it:
| Shortcut | Action |
|---|---|
↑ / ↓ | Navigate between sessions |
→ / ← | Expand or collapse grouped (forked) sessions |
Enter | Resume the highlighted session |
Space | Preview the session content |
Ctrl+R | Rename the highlighted session |
/ or any printable char | Enter search mode and filter (paste a PR/MR URL to find the session that created it) |
Ctrl+B | Filter to sessions from the current git branch (toggle) |
Ctrl+W | Widen to all worktrees of this repo (toggle) |
Ctrl+A | Widen to every project on this machine (toggle) |
Esc | Exit the picker or search mode |
Forked sessions created with /branch, /rewind, or --fork-session are grouped under their root session — press → to expand the group. Since v2.1.144, background sessions are marked in the picker so you can tell detached agents apart from interactive ones.
Note
Headless and SDK sessions are resumable but hidden
Sessions created with claude -p or the Agent SDK do not appear in the picker. They still exist on disk — resume one by passing its ID: claude --resume <session-id>. Capture that ID from the run's output if you'll want it back.
Branching and forking: try another approach
Sometimes you want to explore a different path without abandoning the one you're on. Branching copies the conversation so far and switches you into the copy, leaving the original untouched.
From inside a session, run /branch with an optional name (alias /fork):
/branch try-streaming-approachFrom the command line, combine --continue or --resume with --fork-session — this assigns a new session ID instead of reusing the original:
claude --continue --fork-session
claude --resume abc123 --fork-sessionThe original is unchanged and stays in the picker. The /branch confirmation prints two session IDs — the new branch you're now in and the original — so you can jump back with /resume <id>, the picker, or /resume <original-name>.
Two gotchas worth internalizing: permissions you approved with "allow for this session" do not carry over to a new branch. And if you resume the same session in two terminals without forking, messages from both interleave into one transcript — fork if you want isolation.
Export and share with /export [filename] (copies the conversation to clipboard, or writes a readable plain-text file if you pass a name) and /copy [N] (copies the Nth-latest response; offers a picker for individual code blocks, with w to write to a file).
Watch out
Branch is not the same as Summarize
Branching forks into a new session and preserves the original session intact. Summarize (in the rewind menu) stays in the same session and just compresses context. If you want to try a divergent approach without losing your current path, fork — don't summarize.
The rewind menu: restore vs. summarize
Checkpoints are created automatically — every user prompt snapshots the state of your code before Claude's edits, and checkpoints persist across sessions so you can reach them in resumed conversations.
To time-travel, run /rewind (aliases /checkpoint, /undo) or press Esc twice when the prompt input is empty. If the input has text, double-Esc clears it instead (the cleared text is saved to input history — press Up to recall it after).
The menu lists each prompt you sent. Select a point, then choose an action. The crucial split is restore (reverts state) vs. summarize (compresses context, changes no files):
| Action | Effect |
|---|---|
| Restore code and conversation | Revert both code and conversation to that point |
| Restore conversation | Rewind the conversation, keep current code |
| Restore code | Revert file changes, keep the conversation |
| Summarize from here | Replace the selected message and everything after it with a summary (keeps earlier context in full) |
| Summarize up to here | Replace messages before the selected message with a summary (keeps the selected message onward intact) |
| Never mind | Return without making changes |
Restore options undo state. Summarize options compress part of the conversation into an AI-generated summary without touching files on disk — like a targeted /compact where you pick which side of the message to shrink. In both summarize cases the original messages stay in the transcript, so Claude can still reference details, and you can type optional instructions to steer the summary.
Example
Two everyday moves
Recover from a bad edit: Claude refactored three files and broke the build → /rewind → Restore code (keep the conversation so Claude remembers what it tried) → re-prompt with a correction.
Free up context after a long debug: the session is bloated with a verbose investigation → /rewind, select the prompt where debugging started → Summarize from here → keep your initial instructions in full, collapse the noisy tail.
What checkpoints miss, and why directories matter
Checkpoints are powerful but have hard edges. Know them before you rely on them.
They track Claude's file-edit tools ONLY. If Claude runs a shell command that changes files — rm file.txt, mv old.txt new.txt, cp source.txt dest.txt, or a git reset — those changes cannot be undone through rewind. Only direct edits via Claude's file-editing tools are snapshotted.
They don't see external changes. Manual edits you make outside Claude Code, or edits from another concurrent session, normally aren't captured unless they happen to touch the same files this session edited.
They are separate from git and not a replacement for it. Think of checkpoints as local undo and git as permanent history. Keep committing for real version control, branches, and collaboration.
Cleanup. Checkpoints are cleaned up along with their session after 30 days by default (configurable via cleanupPeriodDays).
Now the directory point. Sessions tie to a project directory, not a git branch. A session is keyed by your working directory path, and the transcript is just a conversation — it does not snapshot your whole working tree. So if you switch git branches while a session is open (or before resuming one), the files on disk change underneath Claude. The same session can see entirely different code depending on the branch you're standing on. This is why git worktrees are the clean way to run parallel sessions on different branches: each worktree is its own directory, so each gets its own session scope with no branch-switching surprises.
Watch out
Bash file changes are NOT checkpointed
Rewind can't recover from rm, mv, cp, or git reset run in the shell — only from Claude's file-editing tools. For anything destructive at the shell level, your safety net is git (commit before risky work), not the checkpoint stack.
Session storage, lifecycle, and cleanup
Transcripts are stored as JSONL at ~/.claude/projects/<project>/<session-id>.jsonl, where <project> is derived from your working directory path — one line per message, tool use, or metadata entry. (Point CLAUDE_CONFIG_DIR elsewhere to relocate the whole store.)
Because sessions never intentionally expire on their own and accumulate as you work, ~/.claude/projects/ can balloon to gigabytes over time — long debugging runs and pasted screenshots (stored at full resolution in the JSONL) are the worst offenders. Two cleanup mechanisms keep it in check:
- Automatic time-based cleanup. Local transcript files (and their checkpoints) are removed after 30 days by default. Change the window with the
cleanupPeriodDayssetting. - Explicit purge.
claude project purge [path]deletes local Claude state on demand; use--dry-runto preview,-yto skip the prompt, or--allto clean everywhere.
If you want to avoid writing transcripts at all, set CLAUDE_CODE_SKIP_PROMPT_HISTORY, or in non-interactive mode pass --no-session-persistence.
Tip
Tune the cleanup window, don't disable it
If you genuinely need long-lived sessions, raise cleanupPeriodDays rather than turning persistence off. If ~/.claude/projects/ is bloated, run claude project purge --dry-run first to see what would go, then purge — and start fresh sessions for image-heavy work to avoid token drain and occasional 400 errors on resume.
Try it: Branch, break, and rewind
Practice the full session-and-checkpoint loop in a throwaway directory.
- Start named: in an empty dir, run
claude -n rewind-lab "create three small files a.txt, b.txt, c.txt with one line each". Let it make the edits. - Branch: run
/branch try-rewrite. Note the two session IDs printed. Ask Claude to rewrite all three files. You are now in the branch; the originalrewind-labis untouched. - Rewind a restore: run
/rewind, pick the prompt before the rewrite, and choose Restore code. Confirm the files revert but the conversation remembers the rewrite attempt. - Rewind a summarize: run
/rewindagain, pick an early prompt, and choose Summarize up to here. Confirm no files change and/contextshows reduced usage. - Prove the bash gap: ask Claude to run
rm a.txtin the shell, then/rewindand Restore — confirma.txtdoes not come back. (Recover it withgit checkoutif you initialized git, or recreate it.) - Hop sessions: exit, run
claude --resume rewind-labto return to the original branch, then/resumeand useCtrl+W/Ctrl+Ato see how the picker widens. - Clean up: run
claude project purge --dry-runin that directory to preview what would be deleted.
Deliverable: a short note describing one case where Restore was the right tool and one where Summarize was, plus what happened to a.txt after the bash rm — and why.
Key takeaways
- 1Sessions are whole conversations tied to a project directory; checkpoints are automatic per-prompt undo snapshots inside one session.
- 2Resume with `claude -c`/`--continue` (most recent) or `claude -r`/`--resume <id-or-name>`; `--fork-session` (or `/branch`, alias `/fork`) copies a session into a new one, leaving the original intact.
- 3The rewind menu (`/rewind` or Esc Esc on empty input) splits into Restore (reverts code and/or conversation) and Summarize (compresses context, no file change).
- 4Checkpoints track Claude's file-edit tools only — not bash `rm`/`mv`/`git reset` — are separate from git, and are cleaned up with their session after 30 days.
- 5Sessions key to directories, not branches: switching git branches changes the files Claude sees; use worktrees for clean parallel sessions.
- 6`claude -p`/SDK sessions don't show in the `/resume` picker but resume by ID; manage disk with `cleanupPeriodDays` and `claude project purge`.
Quiz
Lock in what you learned
Check your understanding
0 / 4 answered
1.Claude, while working in a session, runs `rm config.old.yaml` in the shell and then edits `config.yaml` with its file-editing tool. You open `/rewind` and Restore code to before both actions. What happens?
2.You want to discard a long, noisy debugging tangent to free up context, but you must keep your original setup instructions in full detail and you do NOT want any files changed. Which rewind action fits?
3.Why does the Claude Code documentation say sessions tie to directories, not branches — and what's the practical consequence?
4.You ran a task with `claude -p "..."` yesterday and now want to continue that exact conversation interactively. You open `/resume` but the session isn't listed. What's correct?
Go deeper
Hand-picked sources to keep learning
Continue, resume, from-pr, the picker, naming, branching, and where transcripts are stored.
How checkpoints work, the full rewind menu, restore vs. summarize, and limitations.
Esc, Esc Esc (rewind), Ctrl+B/W/A picker filters, and other in-session controls.
Exact syntax for -c/--continue, -r/--resume, --fork-session, -n/--name, and project purge.
Why directory-scoped sessions plus worktrees beat branch-switching for parallel work.
Source, issues, and changelog for session/checkpoint behavior across versions.