Handoff
Create one concise handoff document that lets a fresh agent resume without reconstructing the session. Save it in the temporary directory provided by the host operating system, never in the current workspace.
Non-negotiable rules
- Produce the handoff instead of merely describing what it would contain.
- Use only host capabilities that are available. If no filesystem-writing capability exists, return the complete handoff in the response and state that it could not be saved.
- Do not modify project files, commits, tickets, specifications, ADRs, or other external state while preparing the handoff.
- Treat user arguments or accompanying text as the intended focus of the next session. Prioritize the state and next actions relevant to that focus while retaining blockers and constraints that could invalidate the work.
- Never include secrets, credentials, access tokens, passwords, private keys, session cookies, personal data, or unnecessary sensitive values. Replace them with descriptive redactions such as [REDACTED API token].
- Do not copy large content already preserved in a durable artifact. Link or cite its exact path, URL, issue identifier, commit, or command instead.
- Distinguish verified facts from assumptions and proposed next steps. Never present an unverified belief as completed work.
Gather the minimum reliable state
Use the conversation first. Perform focused read-only inspection only when needed to make the handoff accurate, such as checking repository status, current branch and commit, touched files, test results, or existing artifact locations. Do not launch broad research or continue implementation.
Capture:
- The user's goal and, when supplied, the next-session focus.
- Work completed and the evidence that confirms it.
- Current repository or external-system state needed to resume safely.
- Decisions and constraints that must be preserved.
- Remaining work in dependency order, with the next concrete action first.
- Blockers, failures, uncertainties, and unsuccessful approaches worth avoiding.
- Existing artifacts by exact path, URL, issue, commit, or command.
- Relevant validation commands and whether each last passed, failed, or was not run.
- Skills that the next agent should explicitly invoke.
When repository state matters and tools permit, inspect it read-only. Record uncommitted changes as user-owned unless the conversation proves otherwise. Do not imply that a commit, push, publication, deployment, or external update occurred without evidence.
Write the document
Choose the host's temporary directory through the environment or platform facility; do not assume /tmp on every operating system. Use a collision-resistant filename beginning with handoff- and ending in .md. Avoid overwriting an existing file.
Use this structure, omitting only sections that truly do not apply:
# Handoff: <short task name>
## Next-session focus
<The user's supplied focus, or the most immediate continuation objective.>
## Goal
<The outcome the user ultimately wants.>
## Completed
- <Verified result and evidence/reference.>
## Current state
- <Branch, commit, working-tree state, external state, or other resume context.>
## Decisions and constraints
- <Binding decision or user instruction.>
## Remaining work
1. <First concrete action.>
2. <Later action in dependency order.>
## Blockers and uncertainties
- <What is blocked or unverified, and why.>
## Artifacts and references
- `<path or command>` — <why it matters>
- <URL, issue, or commit> — <why it matters>
## Validation
- `<command or check>` — passed | failed | not run — <relevant detail>
## Suggested skills
- `<skill-name>` — <why the next agent should invoke it>
## Resume prompt
<A compact instruction the next agent can act on immediately.>
Keep the document dense and operational. Prefer exact nouns, paths, versions, identifiers, and outcomes over a narrative transcript. Include commands only when they are safe, relevant, and already known; never embed credentials.
Suggested skills
Name only skills known to be available or explicitly used in the session. Use their exact names. Explain the task each skill should support. If no relevant skill is known, write None identified rather than inventing one.
Verify and report
After writing, read the saved document back and verify:
- it exists outside the workspace in the temporary directory;
- it contains no obvious secret values or needless personal data;
- references resolve as precisely as the available context permits;
- completion claims have evidence;
- remaining work begins with an executable next action;
- the suggested-skills section is present;
- the next-session focus reflects any user-supplied argument.
Return the exact saved path and a one-sentence summary. Do not paste the entire document unless the user asks for it or saving was impossible.