Ctx handover

From ActiveMemory/ctx · View interactive version

Ctx handover is an AI agent skill from the GitHub repository ActiveMemory/ctx. Per-session handover artifact writer. Wraps `ctx handover write` with `--summary` and `--next` (both required, both validated non-placeholder by the CLI). Always invoked as the final step of `/ctx-wrap-up`; not the user-facing trigger. When `.context/kb/` exists, also folds postdated closeouts into

How to use this skill

Skill file

Write a Handover

Capture the session's narrative thread so the next session (a

fresh agent, a different operator, a cold restart the next

morning) can resume without re-deriving context probabilistically

from canonical files plus journal.

This skill is the sole authoritative recall artifact writer

(per KB-RULES.md §Four inviolable rules: *"the handover is

the sole authoritative recall artifact"*). SESSION_LOG.md

entries, closeouts, and journal entries are mid-flight surfaces;

the handover is what /ctx-remember reads on session start.

Authoritative background reading:

.context/ingest/KB-RULES.md §Four inviolable rules;

specs/kb-editorial-pipeline.md §Interface.

When to Use

/ctx-wrap-up owns the user-facing trigger for session-end

("let's wrap up", "save state", "leave a handover", "before I

go", "stepping away") and delegates to this skill as its final

step. Do not advertise this skill as a direct user trigger.

run ends with this skill.

consuming closeouts (use --no-fold). This is the one case

where direct invocation is appropriate.

When NOT to Use

but check with the user. A no-op session still benefits from

a "nothing changed; next-step is X" handover when the next

session has zero context.

and nothing has changed since.

/ctx-decision-add, etc.); those write to canonical files,

not to a handover artifact.

Authority Boundary (vs Other Skills)

.context/handovers/<TS>-<slug>.md; folds postdated

closeouts from .context/ingest/closeouts/ into the

handover's ## Folded closeouts section; archives folded

closeouts to .context/archive/closeouts/. Single writer of

this artifact.

trigger. Drives the broader capture ceremony (learnings,

decisions, conventions, tasks) and always delegates to

/ctx-handover as its final step.

closeouts whose generated-at postdates the handover; the

read-side counterpart to this skill's write surface.

/ctx-learning-add, /ctx-convention-add): write to the

five canonical files. This skill never modifies those files;

the handover narrative references them, it does not author

them.

Usage Examples

/ctx-handover "kb editorial pipeline phase KB skills drafted"
/ctx-handover "rev2 spec landed; tomorrow start the writer package"
/ctx-handover "research session on cursor hooks"
/ctx-handover --no-fold "mid-session checkpoint before lunch"

Input Contract

The skill wraps ctx handover write, which enforces required

flags via MarkFlagRequired and rejects placeholder bodies via

the Phase SK validation pattern. Empty TBD, see chat,

whitespace-only values are rejected by the CLI, not just by the

skill text.

| Flag | Type | Default | Description |

|------|------|---------|-------------|

| --summary | string | (required) | Past tense; what happened this session. |

| --next | string | (required) | Future tense; what the next agent should do FIRST. Specific, not vague. |

| --highlights | string | "" | Notable artifacts produced this session. |

| --open-questions | string | "" | Things that remain undecided. |

| --no-fold | bool | false | Skip closeout consumption (mid-session checkpoint). |

| --commit | string | (resolved) | Override resolved git HEAD for Provenance line (CI replay). |

Positional argument: handover title (becomes filename slug).

Pre-Write Gates

Two distinct refusals, each leaves zero residue:

and stop.

.context/kb/ is not required for handover; the artifact

exists for code-dev sessions as well. KB-state folding is

conditional on the directory's existence (see §Process).

Process

  1. Verify pre-write gates. Refuse cleanly if any gate

fails. Zero residue on refusal.

  1. Gather signal silently (mirror /ctx-wrap-up Phase 1

when invoked standalone):

```bash

git status --short

git diff --stat

git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline -5

```

Scan the conversation history for:

spec entries).

  1. Draft --summary and --next. Both are required, both

are validated non-placeholder by the CLI:

was done, not what was attempted. Concrete: *"drafted six

Phase KB skill files; reconciled rev2 spec changes;

deferred CLI wiring to next session", not "made

progress on KB stuff"*.

specific first action the next agent should take.

Concrete: *"start internal/cli/handover/cmd/write/cmd.go

using Phase SK validation pattern", not "continue

work" or "look at the kb"*.

Surface the drafts to the user for confirmation before

running the CLI. The user is the final authority on what

the handover says.

  1. Run ctx handover write with the confirmed values:

```bash

ctx handover write "<title>" \

--summary "<one-paragraph past tense>" \

--next "<one-paragraph future tense>" \

[--highlights "<bullet list>"] \

[--open-questions "<bullet list>"] \

[--no-fold] \

[--commit <sha>]

```

The CLI:

CTX_TASK_COMMIT and GITHUB_SHA for CI replay).

closeout window.

generated-at postdates the cursor).

handover's ## Folded closeouts section. Malformed

closeouts (missing generated-at, malformed frontmatter)

are skipped with a warning.

.context/archive/closeouts/. Archived closeouts are

immutable.

When --no-fold is set, the fold + archive steps are

skipped; closeouts stay in place. Use for mid-session

checkpoints where the user wants the handover artifact but

intends to keep ingesting before the next session boundary.

  1. Report the result. Surface:

handover"*).

the user can fix or delete; site-review's job to flag,

but the warning here is opportunistic).

that triggered rejection).

Closeout Fold Mechanics

The fold mechanism is the integration point between the

editorial pipeline (/ctx-kb-* closeouts) and session continuity

(handover artifacts). Mechanically:

the generated-at of the newest handover (or zero time if

none exists).

returns every closeout whose generated-at postdates the

cursor.

## Folded closeouts in the new handover, in generated-at

order. The frontmatter is preserved verbatim so the audit

trail survives the fold.

.context/archive/closeouts/. Archived closeouts are

immutable; subsequent passes never re-fold them.

A handover with no postdated closeouts to fold writes a

## Folded closeouts section with the body "none"; never

omit the section, so the audit trail is explicit.

Edge Cases

| Case | Expected behavior |

|------|-------------------|

| .context/ missing | Refuse; suggest ctx init. No residue. |

| .context/handovers/ missing | Refuse; suggest ctx init --upgrade. No residue. |

| Empty --summary or --next | The CLI rejects with the placeholder-rejection message; surface verbatim. |

| Placeholder values (TBD, see chat, whitespace-only) for --summary or --next | The CLI rejects; surface verbatim and ask the user to redraft. |

| No postdated closeouts to fold | Write the handover with ## Folded closeouts body "none". Never omit the section. |

| Postdated closeout has malformed frontmatter | The CLI skips the file with a warning naming it. Report the warning to the user so they can fix or delete. |

| --no-fold set | Skip the fold + archive steps; the handover stands alone; closeouts stay in .context/ingest/closeouts/ for the next invocation. |

| Mid-session re-invocation | Each invocation writes a new handover file. The newest one is what /ctx-remember reads next session. Multiple per session are fine. |

| Session aborted before wrap-up | Closeouts stay in place; next session's /ctx-remember reads canonical files + the last handover + any postdated unfolded closeouts. Editorial work survives. |

| User runs /ctx-wrap-up without .context/kb/ present | /ctx-wrap-up still drives /ctx-handover as its final step; kb-presence affects what gets folded, not whether the handover is written. |

| gitmeta.ResolveHead returns an error (no git, detached HEAD with no fallback) | The CLI surfaces the typed MissingGitError; relay verbatim. Phase RG owns the recovery path; this skill does not invent one. |

| CTX_TASK_COMMIT or GITHUB_SHA set | Honoured for the Provenance line per gitmeta.ResolveHead's precedence rules; no special handling here. |

Anti-Patterns

chat"`. The CLI rejects these; do not work around the

rejection by inventing prose that technically passes the

placeholder check but is still vague.

pass"*. The fold is the integration point; closeouts that

outlive their relevant handover are recall noise. Use

--no-fold explicitly when the user wants the checkpoint

behavior; do not infer it.

Hand-edits drift from the schema the read side expects.

immutable per KB-RULES.md §Closeout shape.

session did not actually produce. Light compression for

clarity is allowed; new facts are not.

Output Contract

For pre-write refusals, return only the specified refusal text

and stop.

For successful handover writes, end with this structured

summary:

postdated the prior handover"*).

the CLI.

operator sees what the next agent will read first.

Quality Checklist

Before reporting completion, verify:

returned with zero residue).

requested).

.context/archive/closeouts/.

user.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.