Session Handoff
Sessions end. Time, context, attention, the user's day — all are finite. The default
end is "we'll pick it up next time," but that usually means "we'll figure out what we
were doing next time" — which costs the user another 5 minutes of re-orientation
every session, and costs you the context you built.
This Skill makes session end a first-class operation with an explicit output: a
handoff file that the next session can read first, before any other action, and be
productive in 30 seconds instead of 5 minutes.
When to use
Activate when any of these is true:
- The user says "done for today" / "let's stop here" / "see you tomorrow" / "we'll
continue later".
- The context is about to be compacted or has grown large; you anticipate losing
context before the next user message.
- A long task is in progress and a "natural pause" is approaching (end of work day,
end of a logical milestone, user switch context).
- A sub-task is in flight (long-running build, background command) that will outlive
this session.
When NOT to use
- The session just started. There is no in-progress work to hand off.
- The work is fully complete and verified (
completion-audit passed). No
in-progress state to hand off.
- The user explicitly said "throw it all away, start fresh next time." Respect that.
Process
Confirm the handoff is wanted (if you can — skip this step if the user is
clearly stepping away). One line: "Writing a handoff file so next session can
pick this up — okay?"
Choose a single, predictable path. Default (illustrative; actual
on-disk path is host-internal): <host-handoff-root>/<ISO-date>-<short-id>.md.
The mcode 0.2.4 public surface does not document a handoff file path. The
Skills below use <host-handoff-root> as a conceptual placeholder; the host
determines the actual root. Different from world-state and goal files
(those describe current state; handoff is the transition).
Write the handoff file in this exact shape:
# Handoff — <short task name>
**Written**: <ISO timestamp>
**Session ended because**: <one-line reason — user said stop / time up / context about to compact>
**Handed off to**: <next session, whoever reads this first>
## Goal (verbatim from the user)
<quote the user's original ask>
## Current state (point-in-time snapshot)
- <state file path> — last updated <ISO>
- <world-state file path> — last updated <ISO>
- <goal file path> — last updated <ISO>
- <family file path, if any> — last updated <ISO>
## What was done (this session)
- [x] <step + result + key file path>
- [x] <step>
- [ ] <step — not done in this session, see "In progress">
## In progress (when we stopped)
- **What**: <the sub-task that was running when we stopped>
- **Where we were**: <the exact step / line / commit>
- **Next concrete step**: <one verb-first sentence — "Run X and report Y">
- **Blocker (if any)**: <one sentence>
## Open questions for next session
- <question that, if answered, would unblock the next step>
- <another question>
## Critical paths (read these first next session)
- <file the next session absolutely must read>
- <another file>
- <tool / state to check>
## Things that might be wrong on resume
- <state that may have changed since this handoff>
- <file that may have been edited by another process>
- <assumption that may no longer hold>
Update the state files (world-state, goal, family) to reference the handoff
file by path. The next session's world-state-tracking read should mention "see
handoff file X" so the next-session agent knows to read it first.
Tell the user, in one line, where the handoff is: "Handoff written to
<host-handoff-root>/2026-08-24-xxx.md (path illustrative; actual
on-disk root is host-internal) — read this first next session."
If a sub-task is in flight (background command, async build, etc.):
- Record its task_id, command, expected completion signal in the handoff.
- Do not assume the sub-task will complete; the next session may need to check.
Output contract
The user sees, in this order:
- One-line confirmation of the handoff path.
- The handoff file's contents (or a link to it).
- (If sub-task in flight) the task_id and how to check its status.
- (If open questions) the questions, so the user can answer them before the next session.
Example
# Handoff — Auth refactor (OIDC alongside SAML)
**Written**: 2026-08-23T23:55:00Z
**Session ended because**: user said "we'll continue tomorrow"
**Handed off to**: next session — read this first
## Goal (verbatim from the user)
> "Refactor the auth subsystem to support OIDC without breaking the existing SAML path."
## Current state (point-in-time snapshot)
- `<host-goal-root>/2026-08-23-auth-oidc.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z
- `<host-state-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z
- `<host-family-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z
## What was done (this session)
- [x] Mapped current auth flow in `src/auth/`
- [x] Drafted `OidcProvider` trait + one impl for `provider = "okta"`
- [x] Confirmed 12/12 existing SAML tests still pass
- [ ] Add OIDC test for happy path with mock IdP
- [ ] Update `docs/auth.md` with new config flag
## In progress (when we stopped)
- **What**: writing the OIDC happy-path test
- **Where we were**: about to add the test fixture (decided to use `oauth2-mock-server`)
- **Next concrete step**: Create `tests/auth/oidc_test.rs` with a mock server fixture
and one login round-trip assertion
- **Blocker**: none
## Open questions for next session
- Should the OIDC module own token storage, or reuse the existing session store?
- Does IT have a preferred OIDC library (defaulting to `openidconnect`)?
## Critical paths (read these first next session)
- `/repo/src/auth/idp.rs` — current IdP interface
- `/repo/src/auth/oidc/mod.rs` — drafted OIDC implementation
- `<host-goal-root>/2026-08-23-auth-oidc.md` *(path illustrative; actual on-disk root is host-internal)* — current goal
- `<host-state-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — current world state
## Things that might be wrong on resume
- `docs/auth.md` was last updated 3 days ago by another contributor; verify it still
describes SAML only before adding OIDC docs.
- The test fixture choice (`oauth2-mock-server`) is a recent decision; confirm with
the user before committing to it.
Common pitfalls
- Do not write the handoff after every tool call. It is a session-end operation, not
a checkpoint.
- Do not skip the verbatim goal. The next session does not have the user's voice
in context; the verbatim quote is the only way to recover the user's exact ask.
- Do not write vague "next steps." "Continue the work" is not a step.
"Create test file X with assertion Y" is.
- Do not assume the sub-task will complete. A background build can be killed
between sessions; the next session must check.
- Do not put sensitive data in the handoff. The file is on disk. Treat it like
any other workspace file.
- Do not make the handoff the only place state lives. The handoff points to
state files; the state files are the source of truth, the handoff is the index.
Verification checklist
1---2name: session-handoff3description: At session end, write a structured handoff file so next session can pick up in 30 seconds. USE WHEN: user says "今天先到这" / "done for today" / "see you tomorrow" / "we'll continue later" / "下次再继续" / "end session" / "收尾", context about to compact, long task in progress, natural pause approaching (end of work day, end of milestone), sub-task in flight that outlives this session. TRIGGER PHRASES: "今天先到这", "done for today", "see you tomorrow", "we'll continue later", "下次再继续", "先到这", "end session", "session 结束", "收尾", "写到 handoff file", "wrap up", "session handoff", "session 接力". SKIP WHEN: session just started (no in-progress work to hand off), work is fully complete and verified (completion-audit passed), user said "throw it all away, start fresh next time" / "全部扔掉".4license: Apache-2.05---67# Session Handoff89Sessions end. Time, context, attention, the user's day — all are finite. The default10end is "we'll pick it up next time," but that usually means "we'll figure out what we11were doing next time" — which costs the user another 5 minutes of re-orientation12every session, and costs you the context you built.1314This Skill makes session end a **first-class operation** with an explicit output: a15handoff file that the next session can `read` first, before any other action, and be16productive in 30 seconds instead of 5 minutes.1718## When to use1920Activate when **any** of these is true:2122- The user says "done for today" / "let's stop here" / "see you tomorrow" / "we'll23 continue later".24- The context is about to be compacted or has grown large; you anticipate losing25 context before the next user message.26- A long task is in progress and a "natural pause" is approaching (end of work day,27 end of a logical milestone, user switch context).28- A sub-task is in flight (long-running build, background command) that will outlive29 this session.3031## When NOT to use3233- The session just started. There is no in-progress work to hand off.34- The work is fully complete and verified (`completion-audit` passed). No35 in-progress state to hand off.36- The user explicitly said "throw it all away, start fresh next time." Respect that.3738## Process39401. **Confirm the handoff is wanted** (if you can — skip this step if the user is41 clearly stepping away). One line: "Writing a handoff file so next session can42 pick this up — okay?"432. **Choose a single, predictable path.** **Default (illustrative; actual44 on-disk path is host-internal):** `<host-handoff-root>/<ISO-date>-<short-id>.md`.45 The mcode 0.2.4 public surface does not document a handoff file path. The46 Skills below use `<host-handoff-root>` as a conceptual placeholder; the host47 determines the actual root. Different from world-state and goal files48 (those describe current state; handoff is the **transition**).493. **Write the handoff file** in this exact shape:5051 ```markdown52 # Handoff — <short task name>5354 **Written**: <ISO timestamp>55 **Session ended because**: <one-line reason — user said stop / time up / context about to compact>56 **Handed off to**: <next session, whoever reads this first>5758 ## Goal (verbatim from the user)5960 <quote the user's original ask>6162 ## Current state (point-in-time snapshot)6364 - <state file path> — last updated <ISO>65 - <world-state file path> — last updated <ISO>66 - <goal file path> — last updated <ISO>67 - <family file path, if any> — last updated <ISO>6869 ## What was done (this session)7071 - [x] <step + result + key file path>72 - [x] <step>73 - [ ] <step — not done in this session, see "In progress">7475 ## In progress (when we stopped)7677 - **What**: <the sub-task that was running when we stopped>78 - **Where we were**: <the exact step / line / commit>79 - **Next concrete step**: <one verb-first sentence — "Run X and report Y">80 - **Blocker (if any)**: <one sentence>8182 ## Open questions for next session8384 - <question that, if answered, would unblock the next step>85 - <another question>8687 ## Critical paths (read these first next session)8889 - <file the next session absolutely must read>90 - <another file>91 - <tool / state to check>9293 ## Things that might be wrong on resume9495 - <state that may have changed since this handoff>96 - <file that may have been edited by another process>97 - <assumption that may no longer hold>98 ```991004. **Update the state files** (world-state, goal, family) to reference the handoff101 file by path. The next session's `world-state-tracking` read should mention "see102 handoff file X" so the next-session agent knows to read it first.1031045. **Tell the user, in one line**, where the handoff is: "Handoff written to105 `<host-handoff-root>/2026-08-24-xxx.md` *(path illustrative; actual106 on-disk root is host-internal)* — read this first next session."1071086. **If a sub-task is in flight** (background command, async build, etc.):109 - Record its task_id, command, expected completion signal in the handoff.110 - Do not assume the sub-task will complete; the next session may need to check.111112## Output contract113114The user sees, in this order:115116- One-line confirmation of the handoff path.117- The handoff file's contents (or a link to it).118- (If sub-task in flight) the task_id and how to check its status.119- (If open questions) the questions, so the user can answer them before the next session.120121## Example122123```markdown124# Handoff — Auth refactor (OIDC alongside SAML)125126**Written**: 2026-08-23T23:55:00Z127**Session ended because**: user said "we'll continue tomorrow"128**Handed off to**: next session — read this first129130## Goal (verbatim from the user)131132> "Refactor the auth subsystem to support OIDC without breaking the existing SAML path."133134## Current state (point-in-time snapshot)135136- `<host-goal-root>/2026-08-23-auth-oidc.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z137- `<host-state-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z138- `<host-family-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — last updated 2026-08-23T23:55:00Z139140## What was done (this session)141142- [x] Mapped current auth flow in `src/auth/`143- [x] Drafted `OidcProvider` trait + one impl for `provider = "okta"`144- [x] Confirmed 12/12 existing SAML tests still pass145- [ ] Add OIDC test for happy path with mock IdP146- [ ] Update `docs/auth.md` with new config flag147148## In progress (when we stopped)149150- **What**: writing the OIDC happy-path test151- **Where we were**: about to add the test fixture (decided to use `oauth2-mock-server`)152- **Next concrete step**: Create `tests/auth/oidc_test.rs` with a mock server fixture153 and one login round-trip assertion154- **Blocker**: none155156## Open questions for next session157158- Should the OIDC module own token storage, or reuse the existing session store?159- Does IT have a preferred OIDC library (defaulting to `openidconnect`)?160161## Critical paths (read these first next session)162163- `/repo/src/auth/idp.rs` — current IdP interface164- `/repo/src/auth/oidc/mod.rs` — drafted OIDC implementation165- `<host-goal-root>/2026-08-23-auth-oidc.md` *(path illustrative; actual on-disk root is host-internal)* — current goal166- `<host-state-root>/auth-refactor.md` *(path illustrative; actual on-disk root is host-internal)* — current world state167168## Things that might be wrong on resume169170- `docs/auth.md` was last updated 3 days ago by another contributor; verify it still171 describes SAML only before adding OIDC docs.172- The test fixture choice (`oauth2-mock-server`) is a recent decision; confirm with173 the user before committing to it.174```175176## Common pitfalls177178- **Do not write the handoff after every tool call.** It is a session-end operation, not179 a checkpoint.180- **Do not skip the verbatim goal.** The next session does not have the user's voice181 in context; the verbatim quote is the only way to recover the user's exact ask.182- **Do not write vague "next steps."** "Continue the work" is not a step.183 "Create test file X with assertion Y" is.184- **Do not assume the sub-task will complete.** A background build can be killed185 between sessions; the next session must check.186- **Do not put sensitive data in the handoff.** The file is on disk. Treat it like187 any other workspace file.188- **Do not make the handoff the only place state lives.** The handoff **points to**189 state files; the state files are the source of truth, the handoff is the index.190191## Verification checklist192193- [ ] Is the handoff at a single, predictable path (`<host-handoff-root>/...` *(path illustrative; actual on-disk root is host-internal)*)?194- [ ] Is the goal section copied verbatim from the user?195- [ ] Are the "done" items ✅ with file paths, and the "in progress" items ⬜ with196 exact "where we were" pointers?197- [ ] Is the "Next concrete step" one verb-first sentence?198- [ ] Are the critical paths listed (what the next session must read first)?199- [ ] Are the "might be wrong" risks named (so the next session verifies them)?200- [ ] If a sub-task is in flight, is its task_id and status-check method recorded?201- [ ] Did you tell the user where the handoff file is?202- [ ] Did you update the world-state file to reference the handoff path?