session-tree
Capture the chat as a tree a later agent can scan. Primary output is in this chat under the exact marker SESSION_TREE so it is greppable in the transcript.
Never invent. Never include secrets. Prefer ~40 lines over 200. Absolute dates, never "today". file:line over prose. Leaves in the user's language; English headers as in the template (grep).
When
| Trigger | Action |
|---|---|
| User asks for a session-tree / handoff / summary of this chat | Write immediately |
close-ticket just finished |
Write the tree in chat (do not wait) |
| Chat is getting heavy (long back-and-forth, large tool output, topic about to switch) | Offer and wait for yes |
| User says they will open a new agent / stop for the day | Write in chat and write the file (below) |
If run again in the same chat: replace — one tree, the latest, not three fragments.
Chat template
SESSION_TREE
## Goal
- <what this chat was for>
## Decided
- <decision> — <one sentence why>
## Parked
- <rejected or postponed, concrete>
## State
- Ticket: <id or none>
- Branch: <name or none>
- Done: <completed work, file:line>
- Stopping point: <exact>
- Files: `path` — modified; tested / untested
## Open
- <unresolved questions>
## Do not relitigate
- <decisions a new agent must not reopen>
State may be "n/a" for a planning-only chat. Still fill Goal / Decided / Parked / Open / Do not relitigate.
Gather coding state from the session plus git status -sb when this is a repo with changes.
Two passes on the tree itself: (1) does this match the chat? (2) what would a new agent miss? Fix before sending.
File (new agent / end of day / explicit handoff)
Chat always. File in addition when the user asked for a handoff, said they will start a new agent, or is stopping for the day.
Path: $(git rev-parse --show-toplevel)/handoffs/ — repo root, never cwd. Create the folder if needed.
If handoffs/ is missing from {git-root}/.gitignore, add it. Handoffs are personal continuity; team truth lives in the ticket, the PR, or the repo.
Filename: YYYY-MM-DD-handoff-N.md — today's date, N from 1, increment if taken.
Write the same SESSION_TREE body (plus an ISO date: at the top). Reply with the saved path.
A brand-new agent: read the newest file in handoffs/ if present; otherwise grep transcripts for SESSION_TREE.