Compact the current conversation into a structured handoff document for a fresh agent to continue without needing the full conversation history.
-
Scan before writing — run these in parallel before drafting anything:
- Check git status and branch:
git status --short && git branch --show-current - Check any open todos from the conversation (TodoRead if available, or summarize from context)
- Note the working directory
- Check git status and branch:
-
Write the handoff document — save to a temp file:
- Windows:
$f = "$env:TEMP\handoff-$(Get-Date -Format 'yyyyMMdd-HHmmss').md" - Unix/macOS:
f=$(mktemp /tmp/handoff-XXXXXX.md) - Read the (empty) file before writing to satisfy tool requirements
- Windows:
-
Output the file path at the end so the user can share it with the next session.
Use exactly these sections, in order:
# Handoff: <one-line summary of what was being worked on>
**Date:** YYYY-MM-DD
**Working dir:** <path>
**Git:** <branch> — <clean|N uncommitted changes>
## Accomplished
- <bullet per completed item>
## Current State
<2–4 sentences: what works now, what is broken, where the code sits>
## Open Tasks
<copy any open TodoWrite items; if none, list the next logical steps>
## Key Decisions
| Decision | Rationale |
|----------|-----------|
| <what was chosen> | <why — the constraint or tradeoff> |
## Dead Ends
- **<approach tried>** — abandoned because <reason>. Don't retry.
## Blockers / Open Questions
- <anything unresolved that the next session needs to decide or investigate>
## Artifacts
- `<path or URL>` — <one-line description>
## Suggested Skills
<list any /skill-name commands the next session should use, with a reason>
## First Action
<single most important next step — one sentence, imperative, actionable>- Do not duplicate content already in artifacts (diffs, plans, PRDs, commits). Reference by path or URL only.
- Dead Ends section is mandatory if any approach was explored and abandoned — this saves the next agent from repeating work.
- First Action must be specific: not "continue the work" — say exactly what file to open, what command to run, or what decision to make.
- Keep the whole document under ~400 lines. Dense > verbose.
- If the user passed
$ARGUMENTS, treat them as the focus of the next session. Tailor Open Tasks, First Action, and Suggested Skills toward that focus.
$ARGUMENTS