Learn · Agentic architecture & orchestration · CCAR-F task 1.7
Sessions: resume and fork
Resume when history is valuable, fork to try another approach, start fresh with a summary when the context is stale.
Key ideas
- Every Claude Code and Agent SDK run has a session ID.
- claude --continue resumes the latest session; claude --resume <id-or-name> a specific one; the SDK uses the resume option.
- After resuming, tell the agent which files changed so it re-analyses only those.
- --fork-session (SDK fork_session) branches from a session's history without changing the original.
- If earlier tool results are stale, a fresh session with a structured summary beats resuming.
- For long tasks, persist state outside the conversation: progress files, task lists, git commits.
Worked example: Resume, fork and fresh start
Capture the session ID on day 1, resume it on day 2 with a note about what changed, and fork it to explore an alternative without touching the original.
Exam traps
- Resuming a session whose tool results are stale after big code changes, instead of starting fresh with a summary.
- Resuming without telling the agent which files changed.
- Using --resume alone to try an alternative approach; it changes the original. Fork instead.
- Keeping all long-task state only in the conversation, with no progress file or commits.
Official docs
Practise CCAR-F questions · Next lesson: Designing tool interfaces