Task Statement 1.7·Domain 1 — 27% of exam
Session State and Resumption
Manage session state, resumption, and forking
Official Exam Guide Objectives
The objectives below are quoted from Anthropic's Claude Certified Architect – Foundations exam guide, v1.1. Read the exam guide summary for the full blueprint.
Task 1.7: Manage session state, resumption, and forking.
Knowledge of
- Named session resumption using
--resume <session-name>to continue a specific prior conversation - fork_session for creating independent branches from a shared analysis baseline to explore divergent approaches
- The importance of informing the agent about changes to previously analyzed files when resuming sessions after code modifications
- Why starting a new session with a structured summary is more reliable than resuming with stale tool results
Skills in
- Using --resume with session names to continue named investigation sessions across work sessions
- Using fork_session to create parallel exploration branches (e.g., comparing two testing strategies or refactoring approaches from a shared codebase analysis)
- Choosing between session resumption (when prior context is mostly valid) and starting fresh with injected summaries (when prior tool results are stale)
- Informing a resumed session about specific file changes for targeted re-analysis rather than requiring full re-exploration
What You Need to Know
How an agent picks work back up after a gap is a design decision, not a detail. Anything that runs across several sittings — chasing a bug through a large system, working through a codebase, research spread over days — leaves behind an accumulation: files that were read, conclusions that were drawn, chains of reasoning that led to them. This task statement is about what to do with that accumulation, and there are exactly three answers: carry it forward, split it, or set it aside and rebuild.
One idea drives every choice between them: a resumed session carries its old tool results forward as if they were still true. A session that read auth.ts on Monday still holds Monday's auth.ts on Wednesday. Nothing in the session invalidates that read, and the model will reason from it with full confidence. So the question to ask before continuing any piece of work is whether what the session already knows is still true.
Three Session Management Options
Three mechanisms exist across the Agent SDK and Claude Code. They are not interchangeable — each answers a different question about the accumulated state — and the exam presents scenarios that make exactly one of them correct.
Option 1: --resume <session-name>
Resume reopens a named session where it was left, with the full conversation restored — every tool result, every analysis, every chain of reasoning still present.
When to use: What the session already knows is still true, or mostly true, and continuing costs less than rebuilding the understanding. If a few files have changed since, resume and tell the agent exactly which ones, so that it re-reads only those (see Targeted Re-Analysis below).
When NOT to use: The session's tool results are stale as a body: much of the code has changed, a rebase or branch switch has moved the ground, or so much time has passed that you cannot list what is different. The history then describes a codebase that no longer exists, which produces the stale context problem below.
Option 2: fork_session
Fork takes an existing session as a starting point and splits off an independent line from it. Past the branch point the two sides are unaware of each other: neither observes the other's results and neither is affected by the other's work.
When to use: The expensive groundwork is already done and you want to try more than one direction from it. Having analysed a codebase, fork to weigh two refactoring strategies against each other — both inherit the same understanding and diverge from there.
When NOT to use: You only want to carry on. Fork exists to compare alternatives, so using it for straightforward continuation creates a branch nobody needed. Resume is the continuation tool.
Option 3: Fresh start with summary injection
Open a new session carrying nothing, then seed it with a written summary of what the previous one established. No tool results come across — only the account you chose to write.
When to use: The old tool results have gone stale, because files changed substantially, an API moved, or dependencies shifted. Also where a long session has silted up with results that no longer matter and the context would be better rebuilt than continued.
When NOT to use: The prior context is still accurate and you want the detail in it. Rebuilding by hand what resume restores for free is wasted effort, and a summary can only lose detail the session still holds.
Three triggers, three choices — pick on intent, step 1: The prior context is still accurate
The Stale Context Problem
This is the idea the whole task statement turns on. It arises when a session is reopened after the underlying files have moved on, leaving the agent to reason from cached reads that describe code as it used to be.
How it manifests: A developer works with Claude Code on a codebase, changes 3 files, and resumes without mentioning it. The advice that comes back contradicts itself — fixes are recommended for problems already solved, and code is discussed that no longer exists in the file.
Why it happens: Resuming restores everything, and everything includes each file's contents as they were when the tool read them. A file modified since is still represented in history by its old text, and the model reasons across both that record and anything read fresh, with nothing marking which is current.
The session cannot detect it. An agent has no way to notice that a file changed between sessions. It reasons from whatever sits in its context. Knowing what changed has to come from outside the session: from you, or from tooling that compares what the session read with what is on disk now.
Two fixes, and the amount of staleness decides between them.
- Most of the context is still valid and you can list what changed (3 files of 50). Stay with the resumed session and inform it: name each changed file, say that its earlier reads of those files are out of date, and have it re-read only those. The exam guide lists this as a skill: "Informing a resumed session about specific file changes for targeted re-analysis rather than requiring full re-exploration".
- The prior tool results are stale as a body (a large refactor, a rebase, a long gap, changes you cannot enumerate). Begin a new session and inject a structured summary of what was established, naming the files that have changed so those can be re-read deliberately. The exam guide's wording is that "starting a new session with a structured summary is more reliable than resuming with stale tool results".
Why the fresh session is the more reliable of the two: Re-reading inside a resumed session adds the current contents. It does not remove the old ones, so both versions remain in the history. An explicit statement of what changed tells the model which version to trust, and that works while the list is short and complete. As the stale share grows the list gets harder to complete, and any file left off it is still answered from its old contents — particularly on side questions where nobody thought to re-read anything. A fresh session holds no old reads at all, so nothing stale comes across and the knowledge does.
Resume or Start Fresh: The Decision the Exam Grades
The exam guide states the skill as "Choosing between session resumption (when prior context is mostly valid) and starting fresh with injected summaries (when prior tool results are stale)". Each side has a cost and a risk:
| Resume, stating what changed | Fresh session with a structured summary | |
|---|---|---|
| Prior tool results | Carried forward word for word, including any that are now out of date | Not present |
| Cost | Low: nothing is re-explored | A summary to write, and some files to re-read |
| Risk | The model reasons from outdated file contents or query results that nobody flagged | The model lacks a detail the summary left out |
| Use when | Context is mostly valid and you can list what changed | Heavy code churn, a long gap, a different branch, a rebase or merge, or a prior session that had become confused |
| Exam guide's position | Right "when prior context is mostly valid" | "more reliable than resuming with stale tool results" |
The guide states a preference, not a tie. When an item sets "resume the old session" against "start a new session with a structured summary" and the stem says the files changed substantially, a long time passed, or a rebase or merge happened, the fresh start is the answer.
Neither the guide nor the documentation gives a numeric threshold, so treat the following as a rule of thumb for study rather than a documented fact:
| Situation | Continuation |
|---|---|
| Nothing the session read has changed | Resume |
| A minority of the files changed (roughly a third or fewer), within about a week, and you can name them | Resume and declare the changes |
| Most of what the session read has changed, or weeks have passed | Fresh session with a structured summary |
One file of three changed two days ago is a resume-and-declare case. All three changed three weeks ago is a fresh start.
Targeted Re-Analysis vs Full Re-Exploration
Changed files do not justify re-examining everything. Re-reading 50 files because 3 of them moved spends the session's budget re-establishing facts that never stopped being true.
The correct approach is targeted re-analysis: name the files that changed and let the agent re-examine only those. In the exam guide this is something you do to a resumed session whose context is otherwise sound. Resume it, then state the delta (the set of differences since the session last ran):
Since our last session these files changed, and what you read from them earlier is out of date:
- src/auth/session.ts (the token lifetime now comes from config.ts, not the constructor)
- src/auth/config.ts (new file)
- tests/session.test.ts (three test cases renamed)
Re-read those three files before continuing. Everything else you analysed is unchanged.
Then carry on with the plan we agreed: extract the refresh path into its own module.Two properties make this the modelled answer to "how do you resume after code changes":
- The re-read is scoped. Naming the files stops the agent either trusting old contents or re-exploring everything.
- The delta is stated as fact, not left to be discovered. The agent does not have to work out what moved, which it could not do reliably from old reads.
The weak version of the same message is "the code has changed, please re-check anything relevant". It is neither targeted nor trustworthy, because "relevant" is exactly what the agent cannot determine from stale context. A complete delta also follows the change outwards: if an edited file altered an interface that unchanged files call, name those callers too.
When the session is too stale to resume, the same targeting carries into the fresh one:
- Start a fresh session.
- Seed it with a written summary that states both halves: what the earlier work established, and which files have moved since — auth.ts, database.ts and api-routes.ts.
- Only those three get re-read and re-examined.
- The findings from that re-read are merged with the summary covering everything untouched.
It is quicker than starting over and safer than resuming a stale session, because the only material in context is either freshly read or deliberately written.
Writing the Summary a Fresh Session Starts From
A fresh session has none of the earlier conversation, so the summary is the whole handover. A structure that works:
Continue the investigation described below. Everything here was established in an
earlier session. That session's tool results are not loaded, so re-read any file
before you modify it.
## Established findings
- auth.ts: SQL injection in the login query (critical). Fixed since the analysis.
- database.ts: connection pool not released on the error path (medium). Still open.
- api-routes.ts: no rate limiting on public endpoints (high). Fixed since the analysis.
- utils.ts: no issues found.
## Changed since the analysis
- auth.ts, database.ts, api-routes.ts
## Open questions
- Does the retry wrapper in database.ts mask the pool leak?
## Next step
Re-read the three changed files and confirm the fixes, then pick up the pool leak.
The analysis of every other file still stands.What makes a summary do its job:
- It carries conclusions, not raw output. File names, the issues found with their severities, and the recommendations. Pasting the old session's tool output into the new prompt brings the stale file contents straight back into the session that was meant to be free of them.
- It carries both halves. A summary with no list of changed files leaves the agent unable to tell which conclusions to revisit, so it either trusts all of them or re-reads everything. A list of changed files with no findings throws away the earlier analysis, and the new session re-explores from nothing.
- It says what is unresolved and what to do next. Open questions and the next step are what turn a record of the past into a continuation.
The risk on this side is omission: a detail the summary leaves out is gone. That is the price paid for carrying nothing stale.
Why Fork Beats the Alternatives for a Comparison
The case the exam guide uses is a session that has built an expensive shared analysis — a dependency map, a coverage report, architecture notes — followed by a wish to compare two mutually exclusive strategies, such as two testing strategies or two refactoring approaches.
| Approach | Cost of the baseline analysis | Isolation between the strategies | Verdict |
|---|---|---|---|
| Two fresh sessions | Paid twice | Total | Wasteful, and the two sessions may analyse the code differently, so a difference in outcome cannot be put down to the strategies |
| One session, both strategies in turn | Paid once | None: the first strategy's reasoning is in context when the second is worked out | Wrong: the comparison is biased |
| Fork once per strategy from the baseline | Paid once | Total | Correct |
Forking gives both branches an identical starting analysis, so the differences between them reflect the strategies and nothing else. The baseline session is left unchanged and can be forked again or resumed.
The second row fails for the same reason a session is a poor reviewer of its own output (task 4.6): earlier reasoning in the same context biases what follows.
When to Use Each Option: Decision Matrix
| Scenario | Best Option | Reasoning |
|---|---|---|
| Continuing work from yesterday, no files changed | --resume | Nothing has gone stale, so the full history is an asset |
| Comparing two refactoring approaches | fork_session | Two directions wanted from one shared understanding |
| Resuming after modifying 3 of 50 files | --resume, naming the 3 files | The context is mostly valid; targeted re-analysis covers what moved |
| Returning after a large refactor, a rebase or a branch switch | Fresh start + summary | Most of the cached reads describe code that no longer exists |
| Long session with cluttered history | Fresh start + summary | A curated summary is worth more than accumulated noise |
| Exploring a testing strategy vs a documentation strategy | fork_session | Independent lines that should not observe each other |
| Resuming after dependency updates | Fresh start + summary | Indirect changes make it unclear which cached reads survive |
| Returning to a specific investigation from several sessions ago | --resume <session-name> | The name picks out one session among many |
Practical Example: The Contradictory Advice Bug
Two days of work across a codebase of 50 files. The first day covers the authentication module and turns up three problems. That evening all three are fixed, which means edits land in auth.ts, session.ts and middleware.ts.
Resuming on Day 2 without saying so produces recommendations to fix three issues that no longer exist, because the tool results describing the unfixed code were restored along with everything else. Asked directly about auth.ts, the answers alternate — sometimes describing the old version held in history, sometimes the current version just read — with no signal distinguishing the two.
The fix here: tell the resumed session what changed. Forty-seven of the fifty files are exactly as the session read them, so the context is mostly valid and the change is easy to list: "Since yesterday, auth.ts, session.ts and middleware.ts were edited to fix the three authentication issues you found. Your earlier reads of those three files are out of date. Re-read them, verify the fixes and check for anything the changes introduced. Everything else you analysed is unchanged." The agent now has a signal for which version is current, and it re-reads three files instead of fifty.
The fix if more had moved: start again with a summary. Suppose instead Day 2 comes a month later. The branch has been rebased, dependencies have been upgraded, and nobody can list everything that is different. Most of what the session read can no longer be trusted, and a list of changes would be too long to get complete. Start a fresh session with a summary: "Prior analysis identified three authentication issues in auth.ts, session.ts, and middleware.ts. All three have been fixed. Please re-analyse these three files to verify the fixes and check for any new issues introduced by the changes. The branch has been rebased since that analysis, so re-read any other file before relying on what is said about it here."
Nothing outdated exists in the new session to be reasoned from. The agent reads the files as they now stand, confirms the fixes, and gives advice that stays consistent because there is only one version of the truth in context.
Two versions in context — the answer keeps flipping, step 1: Day 1 finds 3 issues; Day 2 fixes all three
Beyond One Conversation: Crash Recovery Needs a Manifest
Resume and fork both assume one conversation whose session file still exists. A long multi-agent run that crashes part-way leaves several agents' partial work outside any single conversation, and resuming the coordinator restores only the coordinator's own history. The exam guide covers this under task 5.4 as "Structured state persistence for crash recovery: each agent exports state to a known location, and the coordinator loads a manifest on resume".
A manifest is a small state file the coordinator can read to see where the run stood:
{
"run_id": "billing-test-audit-01",
"goal": "Add comprehensive tests to the billing package",
"phases": {
"structure_map": { "status": "complete", "output": "state/structure.json" },
"risk_ranking": { "status": "complete", "output": "state/risk.json" },
"test_writing": {
"status": "in_progress",
"completed": ["billing/invoice.py", "billing/proration.py"],
"pending": ["billing/dunning.py", "billing/tax.py"],
"last_error": { "type": "timeout", "module": "billing/tax.py" }
}
}
}On restart the coordinator loads the manifest, skips the phases marked complete, re-delegates only the pending work (the two modules still to do), and injects the outputs already collected into the new agents' prompts. Items that combine session management (1.7), context passing to subagents (1.3) and crash recovery (5.4) test exactly this seam.
Deep Dive
Where sessions actually live, and how resume finds them
A session is defined precisely: "the conversation history the SDK accumulates while your agent works. It contains your prompt, every tool call the agent made, every tool result, and every response. The SDK writes it to disk automatically so you can return to it later." Transcripts are stored as JSONL under a path keyed on the working directory: "Claude Code stores sessions under ~/.claude/projects/<encoded-cwd>/*.jsonl", and to find the directory you "replace every non-alphanumeric character in the absolute working directory with -: /Users/me/proj becomes -Users-me-proj."
How far Claude Code searches depends on what you hand it:
| You pass | Where it looks |
|---|---|
--continue | "the most recent session in the current directory" only |
--resume <session-id> | First "The current project directory and its git worktrees", then "Every other project on this machine" |
--resume <name> | "Resuming by name resolves across the current repository and its worktrees"; a name matching several sessions opens the picker with the name pre-filled |
--resume with no argument | The session picker, which starts with the current worktree and widens with Ctrl+W (all worktrees) or Ctrl+A (every project on the machine) |
So a specific session can be resumed by ID from any directory: "You can run claude --resume <session-id> from any directory". This is newer behaviour: "Before v2.1.223, the lookup was scoped to the current project directory and its git worktrees; SDK versions that bundle an older CLI still behave this way." --continue remains tied to the directory you run it from, which is why it is the wrong tool for reaching a particular older session.
Two limits remain. The search is "Same machine only: the session file still needs to exist on the current machine", and transcripts are subject to retention, 30 days by default and adjustable with cleanupPeriodDays.
Sourcescode.claude.com › sessionscode.claude.com › sessionsfetched 2026-11-19
What a resumed session restores, and what it does not
Resume restores more than just messages. The documented list is the conversation history ("the messages, tool calls, and results"), the model ("the session continues on the model it was using", apart from documented exceptions), the agent the session was started as, the permission mode, an active goal, and session-scoped scheduled tasks that have not expired. A tool call that was still running when the previous process ended "doesn't get rerun when you resume".
Permission mode is the part with conditions. Resuming from a terminal by --continue, by session ID or by an unambiguous name, "Claude Code restores the permission mode the session was in, except in the cases in the table." The two cases worth knowing:
| Session ended in | Resumed from a terminal, it starts in |
|---|---|
bypassPermissions | "The permission mode a new session would start in." Bypassing permissions again has to be enabled at launch |
plan | "Plan mode. With --fork-session, the permission mode a new session would start in" |
Other routes behave differently: a session chosen from the picker, or resumed with claude -p, starts in the mode a new session or a new claude -p run would start in, apart from the plan-mode exception. Launch flags are not restored either, so --mcp-config, --plugin-dir, --add-dir, --settings and --fallback-model have to be passed again.
All of this is one more reason a resumed session's behaviour is not always identical to where you left it, beyond stale tool results.
Sourcecode.claude.com › sessionsfetched 2026-11-19
Continue vs resume — the practical difference for automation
The two "keep working" options track state differently. The SDK sessions guide puts it plainly: "Continue finds the most recent session in the current directory. You don't track anything. ... Resume takes a specific session ID. You track the ID." The headless docs give the CLI form: "Use --continue to continue the most recent conversation, or --resume with a session ID to continue a specific conversation." For a single interactive workflow, --continue is the low-friction choice. For scripted or multi-conversation automation, the docs recommend explicitly capturing the ID: "If you're running multiple conversations, capture the session ID to resume a specific one", typically via --output-format json and reading the session_id field from the result. The resuming command does not have to run from the original directory: "You can run the two commands from different directories: Claude Code finds the session by its ID in any project on this machine."
--continue also has blind spots. Interactive claude --continue "Skips sessions created with claude -p or the Agent SDK, and sessions whose first prompt was /loop", although "claude -p --continue includes -p, SDK, and /loop sessions". Those sessions are also left out of the session picker, and "You can still resume one by passing its session ID to claude --resume <session-id>."
Sourcescode.claude.com › headlesscode.claude.com › sessionscode.claude.com › cli-referencefetched 2026-11-19
The SDK options behind continue, resume and fork
The exam guide's fork_session is the Python name of an Agent SDK option. "Continue, resume, and fork are option fields you set on query()":
| Intent | Python (ClaudeAgentOptions) | TypeScript (Options) | Command line |
|---|---|---|---|
| Continue the most recent session | continue_conversation=True | continue: true | --continue |
| Resume a specific session | resume=session_id | resume: sessionId | --resume |
| Fork instead of continuing | resume=session_id, fork_session=True | resume: sessionId, forkSession: true | --resume <id> --fork-session, --continue --fork-session, or /branch in a session |
The session ID comes from "the session_id field on the result message", which is "present on every result regardless of success or error".
Forking twice from one baseline, once per strategy, looks like this:
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
BASELINE = "..." # session ID captured from the analysis session
async def explore(strategy: str) -> str | None:
"""Run one strategy in its own fork and return the fork's session ID."""
fork_id = None
async for message in query(
prompt=strategy,
options=ClaudeAgentOptions(resume=BASELINE, fork_session=True),
):
if isinstance(message, ResultMessage):
fork_id = message.session_id # the fork's ID, never BASELINE
return fork_id
async def main():
fork_a, fork_b = await asyncio.gather(
explore("Plan the migration using integration tests first."),
explore("Plan the migration using unit tests with fakes."),
)
print(fork_a, fork_b)
asyncio.run(main())The invariant: each fork starts from a copy of the baseline's history and writes to its own session ID, so the baseline is never written to and neither branch can see the other. Resuming without fork_session would instead reuse the original ID and extend its history.
Both SDKs also expose session management functions: list_sessions() and get_session_messages() to enumerate sessions and read a past transcript, and get_session_info(), rename_session() and tag_session() to look up, title and tag one session (listSessions(), getSessionMessages(), getSessionInfo(), renameSession() and tagSession() in TypeScript). There is also a standalone fork_session() function (forkSession() in TypeScript) that "Copies a session's transcript into a new session" without running a query.
Sourcescode.claude.com › sessionscode.claude.com › pythonfetched 2026-11-19
Fork semantics, precisely
Forking is not a variant of resume — it is resume plus a divergence point. The SDK sessions guide: "Forking creates a new session that starts with a copy of the original's history but diverges from that point. The fork gets its own session ID; the original's ID and history stay unchanged. You end up with two independent sessions you can resume separately." The Claude Code sessions doc says the same thing about /branch: "Branching creates a copy of the conversation so far and switches you into it, leaving the original intact." Practically, "Sessions created with /branch or --fork-session get their own session IDs and appear as separate rows" in the session picker — they are first-class, independently resumable sessions from the moment they're created, not temporary branches of the parent. The CLI reference describes the flag in one line: "When resuming, create a new session ID instead of reusing the original (use with --resume or --continue)".
A fork copies the conversation and nothing else. "Forking branches the conversation history, not the filesystem. If a forked agent edits files, those changes are real and visible to any session working in the same directory." Two forks that both edit the same working tree are therefore not isolated on disk, only in what each conversation knows. A fork made with the SDK's fork_session() function also "doesn't include the original session's file checkpoints, so you can't rewind it to a checkpoint captured before the fork."
Forking is also the documented answer to two processes sharing one session: "If you resume the same session in two terminals or two claude -p runs at the same time, both write to one transcript", and "To keep both conversations, add --fork-session to each claude command."
Sourcescode.claude.com › sessionscode.claude.com › sessionscode.claude.com › pythonfetched 2026-11-19
Three different things are called "fork"
Only the first row is the subject of this task statement. The other two share the word and behave differently.
| Mechanism | What the new context starts with |
|---|---|
fork_session (SDK), --fork-session (CLI), /branch | A copy of a saved session's history under a new session ID. The original is unchanged, and files on disk are not copied |
A conversation fork: /subtask, or a fork Claude starts through the Agent tool | "A fork is a subagent that inherits the entire conversation so far instead of starting fresh." Only its final result comes back to the parent |
A skill with context: fork (task 3.2) | An isolated subagent whose prompt is the skill content. It does not see the conversation: "Despite the name, a skill with context: fork doesn't run in a fork of the current conversation" |
The skill version is close to the opposite of a conversation fork: it keeps verbose work out of the conversation instead of copying the conversation into the work. An ordinary subagent inherits nothing either: "Each subagent starts with a fresh, isolated context window. It doesn't see your conversation history", with the conversation fork as the stated exception.
Sourcescode.claude.com › sessionscode.claude.com › sub-agentscode.claude.com › skillsfetched 2026-11-19
Sessions persist conversation, not files — checkpointing is the separate mechanism
A session captures conversation state only: "Sessions persist the conversation, not the filesystem. To snapshot and revert file changes the agent made, use file checkpointing." Checkpointing runs on a different cadence — "Every prompt you send that starts a turn creates a new checkpoint", and in the SDK "Each prompt that starts a turn is a checkpoint, and its user message's UUID is the restore point" — and Claude Code "keeps file snapshots for the 100 most recent checkpoints in a session".
Its coverage is defined by which tool first touched a file. The SDK "creates backups of files before modifying them through the Write, Edit, or NotebookEdit tools". Bash is the partial exception: "Once Claude has edited a file with its file editing tools in your conversation, /rewind undoes changes that Bash commands make to that file afterward. A file that only Bash commands changed isn't tracked and stays as it is." Subagents are the other gap: "Edits a subagent applies aren't tracked, except a skill with context: fork running in the foreground."
This matters for the stale-context problem. The rewind menu can "Restore code: revert file changes while keeping the conversation", and after that choice the conversation still holds every tool result describing the edits that were just undone — checkpointing reverts code, not what the model believes about the code. The SDK docs make the same point from the other side: "File rewinding restores files on disk to a previous state. It does not rewind the conversation itself."
Sourcescode.claude.com › sessionscode.claude.com › file-checkpointingcode.claude.com › checkpointingfetched 2026-11-19
Sessions track talk; checkpointing tracks files, step 1: A session is the conversation — prompts, calls, results
Capturing a session ID headlessly, for the resume-vs-fresh-summary decision
In scripted/CI usage, the documented pattern for tracking a session to resume later is to read its ID straight out of the JSON result: session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id'). This is the concrete mechanism behind choosing resume over fresh-start-with-summary in an automated pipeline — the script has to explicitly decide, per run, whether to pass that captured session_id to --resume (prior context still valid) or to start a new session with an injected summary (prior tool results are stale), exactly the decision rule from this lesson's "Three Session Management Options."
Sourcecode.claude.com › headlessfetched 2026-11-19
Where the documentation itself recommends a fresh start
The documentation does not discuss files changing underneath a resumed session; that reasoning is the exam guide's. It does recommend carrying results forward in place of a transcript in two neighbouring situations, and both support the same habit.
For resuming on another host, one of the three listed approaches is "Don't rely on session resume. Capture the results you need (analysis output, decisions, file diffs) as application state and pass them into a fresh session's prompt. This is often more robust than shipping transcript files around."
For a session that has gone wrong, the best-practices page advises against correcting it a third time: "/clear plus one new prompt that folds in what you learned works better almost every time." /clear starts an empty context while keeping the previous session resumable. The same page gives the pattern for the opposite case, work that is still valid and spans days: "/rename oauth-migration in the session names it, so that claude --resume oauth-migration from your shell picks it back up later, checkpoints included."
Sourcescode.claude.com › sessionscode.claude.com › best-practicesfetched 2026-11-19
Quick Reference
| Fact | Value |
|---|---|
| The one-line model | A resumed session carries its old tool results forward as if they were still true |
| Context mostly valid, a few named files changed | Resume and tell the agent which files changed (targeted re-analysis) |
| Prior tool results stale (heavy churn, rebase, long gap) | New session with an injected structured summary — the guide calls this "more reliable" |
| Two approaches to compare from one analysis | Fork once per approach; the baseline is paid for once and stays unchanged |
| Summary contents | Established findings, files changed since, open questions, next step — conclusions, not raw tool output |
| Session storage path | ~/.claude/projects/<encoded-cwd>/*.jsonl (cwd with non-alphanumerics replaced by -) |
--continue | Finds most recent session in current directory; no ID tracking needed; run interactively, it skips claude -p and Agent SDK sessions |
--resume <id|name> | Requires a specific session ID or name; you must track it |
| Session ID lookup scope | Current project directory and its git worktrees, then every other project on the machine (before v2.1.223: the first only) |
| Session name lookup scope | The current repository and its worktrees |
| What resume restores | Conversation history (messages, tool calls, results), model, agent, permission mode (with conditions), active goal, unexpired session-scoped scheduled tasks |
| Permission mode on a terminal resume | plan comes back as plan mode; bypassPermissions does not come back and must be enabled again at launch |
| Not restored on resume | Launch flags such as --mcp-config, --add-dir, --settings |
| Capturing a session ID in scripts | claude -p "..." --output-format json | jq -r '.session_id' |
| SDK option names | Python continue_conversation, resume, fork_session; TypeScript continue, resume, forkSession |
| Fork mechanics | New session gets its own ID; copies history up to the fork point; original's ID and history stay unchanged |
| What a fork does not copy | Files: a fork's edits are real and visible to every session in the directory |
| Forked session visibility | Appears as a separate row in the session picker, independently resumable |
| What sessions persist | Conversation only — not the filesystem |
| What reverts file changes | Checkpointing (separate mechanism), not sessions |
| Checkpoint cadence | One checkpoint per prompt that starts a turn; the 100 most recent are kept |
| Checkpointing blind spots | A file that only Bash commands changed; most subagent edits |
| Crash recovery across several agents | Each agent exports state; the coordinator loads a manifest on resume (task 5.4) |
Exam Traps
More wrong answers, and why each fails
| Tempting answer | Why it fails | Choose instead |
|---|---|---|
Use --continue to get back to a specific older investigation | It reopens the most recent conversation in the current directory, and run interactively it skips sessions created with claude -p or the Agent SDK | --resume with the session's name or ID |
| Fork so that a risky edit happens "on a copy" | A fork branches the conversation, not the working tree; its file edits are real and visible to every session in the directory | Checkpointing or version control for the files |
| Assume a subagent picks up the parent session's history | A subagent starts with a fresh context; only a conversation fork inherits the conversation | Put the findings it needs in its prompt |
| Add a shared memory store so branches or subagents can see each other's work | Forked branches cannot see each other and subagents do not share memory between invocations; for a comparison, a shared store would remove the isolation the fork exists to provide | Pass context explicitly in the prompt; keep compared branches separate |
How This Is Tested
Items on this task statement describe a gap in the work and ask how to continue. The deciding detail is nearly always how much changed during the gap, or whether one line of work or two is wanted.
| Stem signal | Answer | The wrong answer beside it |
|---|---|---|
| "You return after a few days; three files were refactored. How do you continue?" | Resume and name the changed files for targeted re-analysis | Resume and say nothing; or re-explore the whole codebase |
| The same return, but "most of the module was rewritten", "after a rebase", "weeks later", or "the earlier session had begun contradicting itself" | A new session with an injected structured summary | Resume and ask it to re-read things; fork the session |
| "Which is more reliable: resuming with stale tool results, or a new session with a structured summary?" | The new session with the summary | Resume, because it preserves more |
| "You want to compare two refactoring approaches (or testing strategies) from the same analysis" | Fork the baseline once per approach with fork_session | Both in one session; two fresh sessions |
| "How do you continue a named investigation across work sessions?" | --resume <session-name> | --continue, which reopens only the most recent conversation |
| "Yesterday's work, nothing has changed, carry straight on" | Resume | Fork (a branch nobody needed); a fresh summary (discards valid detail) |
| "A long multi-agent run crashed part-way; how does the coordinator pick up?" | Agents export state to a known location; the coordinator loads a manifest on resume | --resume alone; re-running every agent |
Practice Scenario
Your team has already spent a significant tool-call budget building a full picture of a complex billing dispute — every past invoice pulled with lookup_order, the account's history read with get_customer. Two support leads now want to try different resolution offers from that same picture, without either lead's attempt influencing the other's. Which approach should you take?
Practice Questions
Exam simulator
Question 1 of 13
Scenario · Developer Productivity with Claude
You run two long investigations in the same repository over several days: one into a memory leak, one into flaky tests. Each morning you reopen your work with claude --continue, and twice this week you found yourself in the flaky-test session while meaning to pick up the leak. Which approach should you take?
Sources
- Claude Code Documentation — Anthropic
- Claude Code in Action (Skilljar) — Anthropic
- Agent SDK overview — Anthropic
- Work with sessions (Agent SDK) — Anthropic
- Manage sessions (Claude Code) — Anthropic
- Run Claude Code programmatically — Anthropic
- Rewind file changes with checkpointing (Agent SDK) — Anthropic
- Checkpointing (Claude Code) — Anthropic
- CLI reference — Anthropic
- Agent SDK reference - Python — Anthropic
- Create custom subagents — Anthropic
- Extend Claude with skills — Anthropic
- Best practices for Claude Code — Anthropic