CertSafari
    Anthropic Claude Certified Architect – Foundations (CCAR-F)· Lessons

    Domain 1 · Lesson 7/30

    Session resumption, forking, and fresh starts

    Manage session state, resumption, and forking

    19 min read
    3.86% of exam
    5 sources
    Published 20 Oct 2026
    Docs as of 14 Oct 2026

    What you will be able to do

    • Choose between continue, resume by name or ID, and fork for a given workflow
    • Name a Claude Code session and resume it directly by that name with --resume
    • Resume a specific SDK session by its captured session ID, including after a max-turns or budget limit
    • Fork a session to compare two approaches from one shared analysis baseline, and predict what the fork does not inherit
    • Decide when to resume with a note about changed files and when to start a fresh session seeded with a structured summary

    Key concept

    Session as a replayable transcript — A session is the saved conversation, including every tool call and its result. Resuming it gives the agent back exactly what it saw before. That is useful while those results are still true and misleading once the files behind them have changed.

    1.Continue, resume, fork: three ways back into a conversation

    Claude Code and the Agent SDK save each conversation as a session. An investigation that took two hours to build up (files read, hypotheses ruled out, a root cause half-found) can therefore be picked up later instead of rebuilt. The design decision is which way back in to use. Each option answers a different question: which conversation do I want, and do I want to change it or copy it?

    Continue is the no-bookkeeping option. It takes the most recent session in the current directory, so you track nothing. That works only while your app runs one conversation at a time. Resume takes a specific session ID (or, in the CLI, a session name), so you have to keep track of which one you want. Fork starts from an existing session's history but writes a new session, and the original stays as it was.

    Matching the workflow to the session mechanism
    What you are buildingWhat to use
    One-shot task: single prompt, no follow-upNothing extra; one query() call
    Multi-turn chat in one processClaudeSDKClient (Python) or continue: true (TypeScript)
    Pick up after a process restartcontinue_conversation=True / continue: true (most recent session in the directory)
    Return to a specific past session that may not be the most recentCapture the session ID and pass it to resume
    Try an alternative approach without losing the originalFork the session
    Stateless task, nothing written to diskpersistSession: false (TypeScript only)

    The first row matters more than it looks. A pipeline where every prompt is self-contained needs no session handling. Each query() call stands alone, and adding resume logic would only create state that nothing reads. Session handling is worth adding only when a later turn needs what an earlier turn learned.

    A resumed session keeps more than the conversation. In Claude Code it continues on the same model and, when it was started with --agent, as the same agent with that agent's tool restrictions. If a tool was still running when the earlier process died, it does not run again. Claude sees the call marked as cut off and is told to check whether it took effect before trying again.

    Checkpoint 1 of 7· Match them up

    Match each way back into a conversation to what it does

    Tap a term, then the definition that fits it.

    Sources12

    2.Naming a session and resuming it by name with --resume

    A name turns a session into something you can go straight back to. You can set one at startup with claude -n auth-refactor, during the session with /rename auth-refactor, or by highlighting a session in the picker and pressing Ctrl+R. The next day, claude --resume auth-refactor loads that conversation directly, with no picker. You can also pass the next turn on the same command line: claude -r "auth-refactor" "Finish this PR".

    Each resume form has its own behaviour. --continue follows recency, not identity, so it is correct only when the session you want is guaranteed to be the latest one. --resume with no argument opens the picker, which works but makes you search by hand. --resume <name> with an exact match resumes directly. If the name matches more than one session, it opens the picker with the name pre-filled as a search term. Pasting a summary into a brand-new session loses the full history of what was read and concluded, and that history is what makes resuming worthwhile.

    How a name argument resolves
    CommandExact matchAmbiguous name
    claude --resume <name>Resumes directlyOpens the session picker with the name pre-filled as a search term
    /resume <name>Resumes directlyReports an error; run /resume with no argument to open the picker

    Not every label that shows up in a listing is a resume handle. An unnamed interactive session gets a default display name such as my-app-3f, but passing that name to --resume finds nothing. A generated title, which is a short summary of your first prompt, does work as a handle, and so does a name you set yourself. Sessions also live on the local disk, so a resume works only on the machine where the session file exists. A CI worker on a fresh ephemeral host will not find a session created on another build machine unless the transcript file is copied across.

    Checkpoint 2 of 7· Check yourself

    A developer named a session 'auth-refactor' on their laptop. A CI job on a fresh ephemeral build host then runs claude -r "auth-refactor" "Finish this PR". Nothing else was set up on the host. What happens?

    Checkpoint 3 of 7· Exam question

    An architect ran a two-hour investigation into a flaky payment-retry bug yesterday afternoon and named the session 'payment-retry-bug' before stopping for the day. This morning, a teammate wants the architect to pick the investigation back up with full context of everything already read and concluded, without hunting through the interactive session picker. Which approach satisfies this most directly?

    Sources231

    3.Resuming a specific session by ID in the Agent SDK

    In the SDK, a session ID does the job a name does in the CLI. Every result message carries a session_id. Capture it when a run finishes and pass it back as resume later. The headless CLI follows the same pattern: run with --output-format json, pull out session_id, and pass it to --resume.

    Capturing a session ID from a headless run and resuming that exact sessionbash
    session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id')
    claude -p "Continue that review" --resume "$session_id"

    Resume by ID is required, not just convenient, once more than one conversation shares a directory. Take a backend serving many users, each with a long-running investigation against the same repository. continue_conversation=True would reattach to whichever session in that directory was touched last, which is usually someone else's. Forking would create a new branch every turn and leave the user's actual thread behind. The service should store each user's session ID and pass it to resume when that user returns, whether a minute or hours later.

    Resuming an earlier analysis session to act on its suggestionspython
        async for message in query(
            prompt="Now implement the refactoring you suggested",
            options=ClaudeAgentOptions(
                resume=session_id,
                allowed_tools=["Read", "Edit", "Write", "Glob", "Grep"],
            ),
        ):

    Three situations call for resume by ID:

    • Following up on finished analysis. The agent has already read the code, and you want it to act on what it found without reading the files again.
    • Recovering from a limit. A run that stopped with error_max_turns or error_max_budget_usd can be resumed in the same session with a higher limit, so the work already done is kept. In a single-shot query() call the SDK raises after yielding that error result, so catch the exception first and keep the ID.
    • Restarting a process. Save the ID before shutdown and pass it to resume afterwards to restore the conversation.

    Checkpoint 4 of 7· Fill the gap

    Your backend serves many users, and each one has a long-running investigation against the same repository directory. When a user comes back, the service loads the session ID it stored for that user and runs the code below. Which option fills the blank so the user gets back their own conversation?

        async for message in query(
            prompt="Now implement the refactoring you suggested",
            options=ClaudeAgentOptions(
                 ? =session_id,
                allowed_tools=["Read", "Edit", "Write", "Glob", "Grep"],
            ),
        ):

    Checkpoint 5 of 7· Exam question

    An application serves many concurrent users, each with their own long-running investigation conversation against the same repository directory. A backend service needs to resume a specific user's conversation on demand, potentially hours after the user's last message, while other users' sessions remain active in the same directory. Which session option should the service use?

    Sources1

    4.Forking a session to compare divergent approaches

    Forking lets two approaches start from the same analysis without either one changing the other. Say a session has mapped an auth module and proposed JWT, and you also want to see how OAuth2 would look. Resuming and asking about OAuth2 would add that exploration to the JWT thread. A fork copies the history into a new session, and the original stays exactly as it was. The same applies when comparing two testing strategies or two refactoring plans: do the expensive codebase analysis once, then branch from it.

    Forking: resume the baseline with fork_session=True and capture the new branch's own IDpython
            async for message in query(
                prompt="Instead of JWT, outline how OAuth2 would work for the auth module",
                options=ClaudeAgentOptions(
                    resume=session_id,
                    fork_session=True,
                    max_turns=5,
                ),
            ):
                if isinstance(message, ResultMessage):
                    forked_id = message.session_id  # The fork's ID, distinct from session_id

    The fork gets its own session ID, separate from the original. Store both, because later turns on each branch resume by their own ID. Resuming the original ID afterwards carries on the JWT thread as if the fork never happened. The TypeScript option is forkSession: true, and in the CLI you add --fork-session to a resume to work on a copy of the conversation.

    The Python SDK also offers fork_session() as a standalone function that works on the transcript file. It writes the fork and returns its ID but does not run the agent, so nothing happens until you pass that ID to resume. Its up_to_message_id parameter copies the transcript only up to and including a chosen message. That lets you branch from the point where the analysis was complete, before the session started committing to one approach.

    Creating a fork on disk, then continuing it via resumepython
    from claude_agent_sdk import fork_session, list_sessions
    
    sessions = list_sessions(directory="/path/to/project", limit=1)
    if sessions:
        forked = fork_session(sessions[0].session_id, title="Try the OAuth approach")
        print(forked.session_id)  # pass as ClaudeAgentOptions(resume=...) to continue the fork

    A fork copies the conversation, not the permission state. 'Allow for this session' grants stay with the session that issued them. They carry over to an in-process /branch, which runs in the same process, but a --fork-session fork starts as a new process and you approve again there. This has nothing to do with the working directory or with how many turns have passed, and choosing --resume over --continue does not change it. Forking also resets plan mode: a session that ended in plan mode, resumed with --fork-session, starts in the permission mode a new session would use.

    Checkpoint 6 of 7· Check yourself

    After an expensive codebase analysis that ended with a JWT proposal, an engineer wants to try OAuth2 on a separate branch. They call forked = fork_session(session_id, title="Try the OAuth approach") in Python, and no agent output appears. What explains this, and what is the next step?

    Sources1245

    5.Resume with a change note, or start fresh with a structured summary

    Resuming brings back every tool result exactly as it was recorded. If you edited retry.py after the session read it, the resumed agent still has the old contents in context and will reason from them unless told otherwise. Resuming is only as good as those recorded results are still accurate.

    When most of the earlier context still holds, resume and say exactly what changed. For example: "Since we stopped, src/payments/retry.py and tests/test_retry.py were modified; re-read those two and update your conclusions." The agent re-checks only the named files and keeps the rest of its analysis. Without that note it either trusts outdated reads or, if told only that "things changed", has to explore the whole codebase again, which wastes the reason for resuming.

    When the code has changed enough that most recorded tool results are wrong, start a new session instead. Before the old session ends, save what is worth keeping as application state: analysis output, decisions made, file diffs. Then write that into the new session's first prompt as a structured summary. The new agent starts from accurate conclusions with no outdated file contents to mislead it. This approach also avoids the same-machine limit on resuming, because a summary can go anywhere a prompt can.

    Choosing between resuming and a fresh start
    SituationBetter choiceWhy
    Analysis is still accurate; you want the agent to act on itResumeThe agent builds on its analysis without re-reading files
    A few known files changed since the session read themResume and name the changed filesTargeted re-reads; the rest of the context stays valid
    Broad changes make most recorded tool results staleNew session seeded with a structured summaryConclusions carry forward; outdated file contents do not
    The work must continue on another hostNew session seeded with captured resultsResume needs the session file on the current machine

    Claude Code also has a middle option when you resume a large session. Choosing Resume from summary runs /compact straight away, so later requests carry a summary instead of the full history, while Resume full session as-is loads the conversation unchanged. The summary is generated rather than written by you, so it does not guarantee the facts you care most about are kept. How to protect that information is covered in preserving critical information across long interactions.

    Checkpoint 7 of 7· Match them up

    Teammates changed the code overnight while your investigation was paused. Pair each situation with the better way to pick the work back up.

    Tap a term, then the definition that fits it.

    Sources21

    Practise it for real

    Name a Claude Code session, resume it by name, and fork it into a separate branch

    1. 1.Start a session with claude -n auth-refactor and ask Claude to analyze one module of a project.

      Why: A name you set is a resume handle, unlike the default display name.

      You should see: The session runs under the name auth-refactor.

    2. 2.Exit, then run claude -r "auth-refactor" "Summarize what you found".

      Why: An exact name match resumes directly, and the second argument becomes the next turn.

      You should see: Claude answers from the earlier analysis without reading the module again.

    3. 3.Edit one file the session read, exit, resume by name, and tell Claude which file changed.

      Why: The resumed history still holds the old tool result for that file.

      You should see: Claude re-reads only the file you named.

    4. 4.Run claude --resume auth-refactor --fork-session and try a different approach.

      Why: The fork copies the conversation into a new session and leaves the original as it was.

      You should see: Commands you allowed for the session earlier ask for approval again in the fork, and auth-refactor still resumes on the original thread.

    Sources

    (5)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Continue finds the most recent session in the current directory.”
      ↩︎ Continue, resume, fork: three ways back into a conversation
      “Resume takes a specific session ID. You track the ID.”
      ↩︎ Continue, resume, fork: three ways back into a conversation
      “Nothing extra. One query() call handles it.”
      ↩︎ Continue, resume, fork: three ways back into a conversation
      “Same machine only: the session file still needs to exist on the current machine.”
      ↩︎ Naming a session and resuming it by name with --resume
      “Required when you have multiple sessions (for example, one per user in a multi-user app)”
      ↩︎ Resuming a specific session by ID in the Agent SDK
      “Recover from a limit. The first run ended with error_max_turns or error_max_budget_usd”
      ↩︎ Resuming a specific session by ID in the Agent SDK
      “now you want it to act on that analysis without re-reading files.”
      ↩︎ Resuming a specific session by ID in the Agent SDK
      “Original session is untouched; resuming it continues the JWT thread”
      ↩︎ Forking a session to compare divergent approaches
      “Capture the results you need (analysis output, decisions, file diffs) as application state”
      ↩︎ Resume with a change note, or start fresh with a structured summary
      “This is often more robust than shipping transcript files around.”
      ↩︎ Resume with a change note, or start fresh with a structured summary
      “Required when you have multiple sessions (for example, one per user in a multi-user app)”
      ↩︎ Exam trap 2
      “This is often more robust than shipping transcript files around.”
      ↩︎ Exam trap 5
      “Continue finds the most recent session in the current directory. You don’t track anything. Works well when your app runs one conversation at a time.”
      ↩︎ Checkpoint
      “Capture the results you need (analysis output, decisions, file diffs) as application state and pass them into a fresh session’s prompt.”
      ↩︎ Checkpoint
    2. 2.
      “Model: the session continues on the model it was using”
      ↩︎ Continue, resume, fork: three ways back into a conversation
      “is told to check whether it took effect before running it again”
      ↩︎ Continue, resume, fork: three ways back into a conversation
      “/rename auth-refactor. The name also appears on the prompt bar”
      ↩︎ Naming a session and resuming it by name with --resume
      “The default isn’t a resume handle.”
      ↩︎ Naming a session and resuming it by name with --resume
      “Add --fork-session to resume a copy of the conversation instead.”
      ↩︎ Forking a session to compare divergent approaches
      “If you fork into a separate process with --fork-session, the new process starts without them and you re-approve there”
      ↩︎ Forking a session to compare divergent approaches
      “Conversation history: the full history, including tool calls and results.”
      ↩︎ Resume with a change note, or start fresh with a structured summary
      “Resume from summary: runs /compact immediately. Later requests carry the summary instead of the full history.”
      ↩︎ Resume with a change note, or start fresh with a structured summary
      “Conversation history: the full history, including tool calls and results.”
      ↩︎ Key concept
      “Resumes the named session directly”
      ↩︎ Exam trap 1
      “If you fork into a separate process with --fork-session, the new process starts without them and you re-approve there”
      ↩︎ Exam trap 3
      “Reopens the most recent session in the current directory”
      ↩︎ Prediction
    3. 4.
      “Copy the transcript up to and including the message with this UUID”
      ↩︎ Forking a session to compare divergent approaches
    4. 5.
      “fork_session() writes the new file and returns its ID. It doesn't run the agent”
      ↩︎ Forking a session to compare divergent approaches
      “fork_session() writes the new file and returns its ID. It doesn't run the agent”
      ↩︎ Exam trap 4
      “It doesn't run the agent, so the fork sits on disk until you resume it with query().”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 15 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.