Claude Code Sessions: Resume by Name, Fork From a Baseline, or Start Fresh With a Summary Card
You investigate a refund bug on Monday and come back on Tuesday after a teammate edited the code. Resume the named session and say which files changed, fork it to compare two fixes, or start fresh from a summary card when the old tool results are stale.
What you will learn
- Name a Claude Code session with -n and bring it back with --resume or --continue
- Tell a resumed session exactly which files changed, so only those are read again
- Branch two approaches from one analysis with --fork-session or the SDK's resume and fork_session
- Decide when a summary card and a fresh session beat resuming with stale tool results
Before you start
- Running Claude Code in a terminal
- What a tool result is in an agent conversation
On Monday you spend an hour in Claude Code working out why refunds fail in your support agent's code. Claude reads refund.py, then orders.py, and you note a finding: the refund check runs before the order lookup. Overnight, a teammate edits the code. On Tuesday you ask the same question again.
What Claude remembers is how the files looked yesterday. So you have three choices: carry on with the same conversation, make a copy of it, or begin again with a short brief. Claude Code has a command for each, and picking the right one is mostly about one question: are the old tool results still true?
A case file, a photocopy, a one-page brief
Think of a detective with a case file. Resume is opening the same file and carrying on. Fork is a photocopy: you test one theory on each copy, and the original stays clean. And when the notes are out of date, you hand a new detective a one-page brief, facts only.
Name it, then resume by name
The lecture's project is a cheat sheet, commands.md, and a summary template. Here are the three CLI lines from it, in the order you use them:
claude -n refund-bug
# day 1: investigate, then close the terminal
claude --resume refund-bug
# day 2: the same conversation, found by its name
claude --continue
# or: the most recent conversation in this folder
-n refund-bug(or--name) names the session when you start it.--resume refund-bug(or-r) brings back exactly that conversation the next day.--continue(or-c) needs no name. It takes the latest conversation in this folder.
A name pays off when you run more than one investigation in the same folder. With --continue you get whichever one was last, which may not be the one you meant.
There's one catch. When you resume, everything comes back, and that includes the old tool results. The file contents Claude read on Monday are still sitting in the conversation, and Claude has no way to know they're out of date.
Tell it exactly what changed
Your resumed session remembers three files: refund.py, orders.py and policy.json. Overnight, refund.py and policy.json were edited. orders.py is the same.
Claude can't see the edits on its own, so you tell it. The project's PROMPT.md has the message:
I resumed the refund-bug session. refund.py and policy.json changed since you read them. Re-read only those two files and update your findings.
This is targeted re-analysis. Two files get a second look, and the work from Monday on orders.py is kept. If you say nothing, the session keeps trusting yesterday's results. If you ask it to re-explore everything, you throw away the part of Monday's work that is still true.
Fork: two branches from one baseline
Now say the analysis is finished and you can see two ways to fix the code. Branch A tries a guard function. Branch B moves the rules into a table. Both should start with everything the analysis learned, and neither should spoil the other.
That shared analysis is your baseline, and a fork gives each idea its own copy of it. You compare the results (in the lecture, A is short and easy to read, B is easier to extend), keep the better one, and the original refund-bug session stays exactly as it was.
There are two ways to fork. In the terminal, add --fork-session to a resume:
claude --resume refund-bug --fork-session
In the Agent SDK (Python), the same three moves are options on ClaudeAgentOptions:
ClaudeAgentOptions(resume=session_id) # resume a session
ClaudeAgentOptions(continue_conversation=True) # the most recent one
ClaudeAgentOptions(resume=session_id, fork_session=True) # branch from a shared baseline
Each branch starts from the same baseline, neither one spoils the other, and after the fork the original refund-bug session stays unchanged.
When old results are stale, summarise and restart
Sometimes resuming is the wrong move. Look at an old session where most of the tool results are out of date: an old read of refund.py, an old read of policy.json, a long search output. Telling it "these changed" would mean correcting most of the conversation.
So you write a summary card and start a new session with it. This is the project's summary_card.md:
# Summary card for a fresh session
Findings so far
- The refund check runs before the order lookup.
Files that changed since I read them
- refund.py, policy.json
Still open
- Does the refund window live in policy.json?
Next step
- Read the two changed files again, then propose the fix.
Four headings: findings, files that changed, what is still open, and the next step. The new session reads the files again today, so every tool result in it is fresh. A clean summary is more reliable than a pile of out-of-date tool results, because there's nothing old left to trust by mistake.
The card works for the same reason a subagent brief does: the new session inherits nothing, so whatever it needs must be written down (see passing context to subagents). For why a long session degrades in the first place, and how a fresh start compares with compaction, see long-running sessions: compact, prune, isolate or start fresh.
Which one fits the situation
| Situation | Choose | Why |
|---|---|---|
| Context is mostly still true | Resume | Keep the work, tell it what changed |
| Compare two approaches | Fork | Each branch starts from the same baseline |
| Tool results are stale | Fresh + summary | No old results to trust by mistake |
Common mistakes
- Resuming and saying nothing. The session doesn't notice edits on disk. It answers from Monday's file contents.
- Expecting a fork to refresh the files. A fork copies the conversation, old tool results included. It branches; it doesn't re-read.
- Re-exploring the whole codebase after two files changed. Name the changed files and keep the rest of the work.
- Relying on
--continuewith several investigations in one folder. It takes the most recent one. Name sessions with-nand resume by name.
How this shows up in a question
A typical scenario: a developer resumes a named session the next morning, and two of the files it analysed were edited overnight. The answer that keeps the valid work is to resume and name the changed files. Watch for distractors that hope the session notices, that claim a fork refreshes tool results, or that throw everything away and start over.
Quick recap
| Goal | Claude Code CLI | Agent SDK (Python) |
|---|---|---|
| Name a session | claude -n refund-bug | |
| Resume a named session | claude --resume refund-bug | resume=session_id |
| Continue the most recent one | claude --continue | continue_conversation=True |
| Branch from a baseline | --resume refund-bug --fork-session | resume=session_id, fork_session=True |
| Results are stale | Write a summary card, start a new session with it | |
The cheat sheet and the summary card for this lesson are in the community, free to join.
Try it yourself
Open a project of your own and start claude -n my-bug. Ask a question, quit, and bring it back with claude --resume my-bug. Then resume it again with --fork-session, try a change in the fork, and check that the original conversation didn't change.
Related course on Udemy
Claude Certified Architect - Foundations (CCAR-F) Exam Prep
Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)Related posts
CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
