Last reviewed: 2026-07-20
Direct answer
To resume an interrupted coding agent session, rebuild the working picture before asking the agent to continue: confirm the repository branch and worktree, reload project instructions, inspect the current diff, restate the last completed step, and write a short continuation brief that separates facts from assumptions. The goal is not to recreate every token from the previous conversation. The goal is to give the next run enough verified context to continue without overwriting useful work or losing review evidence.
Use this smoke-test workflow before you let the agent edit again:
- Setup assumptions: you are in the intended repository, the interrupted work was saved to disk or a branch, and the agent is allowed to read repository instructions and run read-only inspection commands.
- Happy-path request plan: ask the agent to inspect the current branch, list changed files, summarize the visible diff, identify the active instruction files, and propose the next edit without changing files yet.
- Error-path check: if the branch is wrong, the diff is empty when changes were expected, instructions are missing, or unrelated files appear in the diff, stop and create a recovery note before continuing.
- Minimum assertions: branch name matches the task, changed files match the expected scope, no credential files are included, the continuation brief names the next action, and the pull request or handoff path is clear.
- Pass/fail logging fields: record
session_id,repository,branch,worktree_path,changed_files_count,instruction_files_seen,next_action,review_link,result, andfollow_up_owner. - What not to assert: do not claim model memory, account state, CI status, production readiness, pricing, rate limits, or external service behavior unless you checked those sources directly.
For related repository setup patterns, see Pack Repository Context So Coding Agents Understand Your Codebase and Memory Hygiene for Long-Running Coding Agents .
Who this is for
This guide is for engineers who use coding agents across terminal, IDE, or hosted development surfaces and need a repeatable recovery path after a browser tab closes, a terminal dies, a context window is compacted, or a long run is paused. It also helps reviewers who receive partially completed agent changes and need enough evidence to decide whether the work can continue.
The workflow fits best when the agent can inspect a local or remote repository, read project instructions, summarize changed files, and work through a pull request or branch review. It also helps when the agent surface changes mid-task. Claude Code documentation describes coding work across terminal, IDE, desktop, and browser surfaces, so the recovery note should make the current surface explicit instead of assuming the next session has the same view as the previous one.
This is not a shortcut around review. It is a controlled restart pattern. If the work was interrupted while changing permissions, credentials, deployment settings, billing-sensitive routing, or production behavior, stop at inspection and bring the right operator back into the loop. A recovered session should make the work easier to review, not broader or harder to explain.
Key takeaways
- Treat the filesystem and Git state as the recovery source, not the interrupted chat transcript.
- Reload persistent project instructions before asking for edits, because instruction files and memory mechanisms can affect how a new run interprets the task.
- Use a Git worktree or dedicated branch when recovery work must be isolated from other active changes.
- Preserve reviewability by making the agent summarize diffs, assumptions, and next actions before it resumes implementation.
- Hand off through a pull request when the work needs collaborative review, because pull requests are designed to propose, compare, review, and merge branch changes.
- Keep examples secret-free. If a credential must appear in a template, use
<API_KEY_PLACEHOLDER>and keep real values out of the note.
A good recovery run has a narrow shape. First, it observes. Then it summarizes. Then it asks for confirmation or performs one bounded continuation step. If the next agent cannot explain why a file changed, it should not keep editing that file. That discipline matters more than the specific agent product because interruptions usually damage context before they damage code.
Sources checked
- Official source evidence 1 - accessed 2026-07-20; purpose: verify source-backed claims for this guide.
- Claude Code memory documentation - accessed 2026-07-20; purpose: verify project memory and instruction-file context for agent workflows.
- Git worktree documentation - accessed 2026-07-20; purpose: verify parallel worktree isolation commands and constraints.
- GitHub pull requests documentation - accessed 2026-07-20; purpose: verify pull request review and collaboration boundaries.
Contract details to verify
| Area | What to verify | Source URL | Accessed | Safe candidate wording |
|---|---|---|---|---|
| Agent surface | Whether the assistant can inspect code, edit files, run commands, and work across the expected surface. | https://docs.anthropic.com/en/docs/claude-code | 2026-07-20 | “Use the agent surface only after the repository state and next action are restated.” |
| Persistent instructions | Which project instruction files or remembered notes are loaded for the new session. | https://code.claude.com/docs/en/memory | 2026-07-20 | “Reload project instructions and restate task facts before continuing.” |
| Work isolation | Whether a separate working tree or branch is appropriate for recovery work. | https://git-scm.com/docs/git-worktree | 2026-07-20 | “Use a dedicated branch or worktree when recovery must stay isolated.” |
| Review handoff | Whether the branch should move through a pull request before merge. | https://docs.github.com/en/pull-requests | 2026-07-20 | “Use a pull request when collaborators need to compare and review the resumed changes.” |
Failure modes
- Evidence gap: the agent cannot inspect the failing log, source page, pull request, or local command output. The safe action is to stop and record the missing evidence instead of guessing.
- Scope drift: the agent edits files that are not connected to the observed failure. Keep the repair tied to the failing signal and leave unrelated cleanup for a separate task.
- Environment mismatch: the local check uses different versions, credentials, feature flags, or runtime settings than the hosted path. Record the mismatch before treating the result as proof.
- Unreviewed fallback: the agent changes models, endpoints, permissions, or retry behavior to make a run pass without preserving the review boundary. Treat access and provider failures as operational blockers, not topic failures.
- Weak handoff: the final note says the issue is fixed but omits the command, result, changed files, and remaining uncertainty. That makes the next operator repeat the investigation.
- Instruction drift: the new session reads a different instruction file set than the interrupted session. Ask it to list the instruction files it used, then compare that list against the recovery note.
- Worktree confusion: the agent resumes in the main checkout while the interrupted work lives in a linked worktree, or the reverse. Confirm both
branchandworktree_pathbefore edits.
Start with a short recovery note:
session_id: interrupted-session-placeholder
repository: org/repo-placeholder
branch: feature/resume-placeholder
worktree_path: /path/to/worktree-placeholder
changed_files_count: 0
instruction_files_seen: [AGENTS.md, CLAUDE.md]
last_confirmed_step: inspected current diff
next_action: propose continuation plan before edits
review_link: https://example.invalid/pull/request-placeholder
result: pass-or-fail-placeholder
follow_up_owner: engineer-placeholder
Then ask the agent to continue from verified state:
We are resuming an interrupted coding task. First inspect the current branch, current worktree, changed files, and project instructions. Summarize what is already changed and what you believe the next step is. Do not edit files until the summary is complete.
If that summary disagrees with the recovery note, fix the note or stop the run. If it agrees, give the agent one bounded next step and require it to keep its change evidence visible in the final handoff.
Reader next step
Before resuming your next interrupted agent run, create a one-page continuation brief and make the first resumed prompt read-only. Include the branch, worktree path, changed files, instruction files, last confirmed step, next proposed action, and review destination. Then ask the agent to summarize the repository state before editing. If the summary matches your brief, continue with one bounded task. If it does not match, stop and correct the working state first.
If the interruption happened during pull request preparation, pair this workflow with How to Hand Off Coding Agent Pull Requests for Review . If the interruption happened while multiple sessions were active, pair it with Use Git Worktrees to Keep Parallel Coding Agents Isolated .
Use Write Change Scope Notes Before an Agent Pull Request as the next comparison point. Keep Agent Memory Review Before Long-Running Tasks nearby for setup and permission checks.
FAQ
Do I need the original conversation to resume safely?
Not always. The safer baseline is the repository state: branch, worktree, changed files, instructions, and review evidence. The original conversation can help, but it should not override what is actually in the repository.
Should the agent start editing immediately after an interruption?
No. Ask for an inspection summary first. A short read-only pass catches wrong branches, missing instructions, stale assumptions, and unrelated files before the resumed run changes anything.
When should I use a Git worktree?
Use a worktree when you need a separate working tree attached to the same repository, especially when another task or agent might also be active. Confirm cleanup expectations before merging or removing it.
What belongs in the handoff?
Include the branch, changed files, instruction files used, tests or checks attempted, known gaps, next action, and review link. Keep credentials, full prompts, and private outputs out of the handoff.
Can this workflow prove the code is production-ready?
No. It only proves the resumed session has enough local context to continue safely. Production readiness depends on the project checks, review requirements, deployment process, and external evidence that apply to the repository.