---
name: agnoclast-log
description: Close out a work session into Agnoclast — summarize what happened, confirm it reached the org, and surface anything teammates should know. Run at or near the end of any working session.
---

> **Agnoclast-managed skill.** This file is installed and kept up to date by Agnoclast. Local edits are
> restored on the next session (a backup of your version is saved alongside). Don't rely on changes here.

## Model: session-primary, daily-derived

The **session is the primary atomic unit** — one session = one durable Agnoclast record (via
`log_session`, keyed by `sessionId`), which is also the per-record privacy unit (`set_record_privacy`
is per record). Any "what happened today / this week" view is a **derived rollup** over those session
records, never a separately-authored primary. This mirrors records(atomic) → digests(derived); the
personal `/log` skill follows the same shape against the local brain.

## When to use

At the end of a Claude Code session, or after finishing a meaningful phase of work. Agnoclast keeps a
background auto-capture as a fallback, but this skill is the *authoritative* close-out: it composes a
clean, structured summary and persists THAT as the session's durable record (superseding the
auto-capture's raw-transcript re-derivation).

## Inputs

No arguments. Read the conversation context.

## Steps

1. **Claim what arrived while you were working** — the timeline moves during a session and the
   session-start block does not.

   Run `pending_records` (and read the `[staged: <id>]` rows in your startup context). Records that
   landed AFTER this session began are invisible to it otherwise: the arrivals block renders once, at
   startup, and nothing re-renders it. A session that sent an email, opened a PR, or talked to someone
   this session has almost certainly generated a record it never saw.

   For anything that belongs to work you actually did: `claim_record` then `route_record` onto the
   pages you know it belongs to — or `place_staged_record` for a `[staged: …]` row, where the pages you
   pick also decide which brain it lands in (ADR-0038), which makes it a disclosure decision and not
   just filing. `park: true` is a complete answer for anything with no real home.

   ⚠ **DO THIS BEFORE SUMMARIZING.** A record you claim here is part of what happened this session, so
   it belongs in the summary you write next — and claiming after you have already written the summary
   means the two disagree.

   ⚠ **Only what you have first-hand context on.** You are the one session that knows why that email
   was sent; you are not in a position to place a stranger's mail from a title. Recognizing your own
   work is nearly free, and guessing at someone else's is the failure `park` exists for.

2. **Summarize the session** — what was worked on, what was decided, what changed. Be concrete: name
   the projects, files, and people involved.
3. **Surface org-relevant signal** — blockers, decisions, handoffs, and anyone you coordinated with.
   These are the things a teammate or manager would want to know without reading the whole transcript.
4. **Persist it as the durable record** — call the `log_session` MCP tool with your curated `summary`
   (plus `project`, and the Claude Code `sessionId` if you know it). This writes YOUR summary as the
   session's authoritative Agnoclast record (`capture_source='skill'`). The background auto-capture is a
   fallback and will not overwrite it; passing the same `sessionId` the auto-capture uses dedupes them
   onto one record. This — not the raw-transcript re-derivation — is the canonical record going forward.

   ⚠ **If you belong to more than one brain, pass `brain`.** ADR-0022 deleted the write pointer, so a
   session-class source routes only by an explicit brain or a sole membership — omit it and the log is
   **STAGED, not recorded**, and staged session logs are not drainable by `/api/staged/promote`. Pick the
   brain the work was actually in (`my_brains` shows what each holds). This silently swallowed 86 close-outs
   before it was caught on 2026-08-09.
5. **Confirm + flag privacy** — **read the result text, do not assume it succeeded.** `log_session` now
   answers `NOT LOGGED — STAGED…` or `NOT LOGGED — the server skipped…` when no record was written; only a
   message carrying a record id means it landed. (It previously printed "Logged … updated existing" for a
   staged write, because `inserted` is merely falsy when nothing is recorded — an agent reported a session
   as saved when it was not.) If it errors, tell the user to run `npx -y @theronap/cortex-mcp doctor`.

   If any record from this session should be confidential, prefer passing `privacy: "confidential"` on the
   `log_session` call itself so it is tiered **at write time** rather than landing org-visible and being
   corrected after. Otherwise note it so the user can mark it (`set_record_privacy`). Default is org-visible
   under access rules.
6. **Sweep the wiki (author what you now understand)** — the HARD backstop for live authoring
   ([[cortex-wiki-authoring-spec]] D2). For each node whose understanding meaningfully advanced this
   session (the project(s) worked on, people you coordinated with, and yourself when your own focus
   shifted): call `authoring_context` for its kind, then `author` to write the page from your compiled
   understanding — what it IS, where it stands, dated decisions, open threads, key people — with inline
   `[[links]]` to other nodes (canonical names from the namespace; red-links for wanted-but-absent
   nodes). This is a synthesis, not a transcript dump. Skip nodes you didn't actually advance. If you
   already authored a node mid-session and nothing changed since, `author` will report "no change" —
   that's fine.
7. **Sweep pending documentation** — run `npx -y @theronap/cortex-mcp docs-scan --json`; if any
   docs are pending, follow the `agnoclast-author-docs` skill (author each into its page, then
   `docs-scan --mark`). Specs/plans written to disk this session must not die on disk — a spec IS
   a page. If no roots are registered or nothing is pending, skip silently.
8. **Reconcile the sweep (don't trust it).** Step 6 relies on your in-the-moment judgment of "what
   advanced"; this step closes the loop so nothing is silently missed. Before printing the Output:
   a. **Enumerate what you touched** — from the transcript, list the concrete entities this session
      advanced: the project(s), notable files/artifacts, and the people you coordinated with. Derive
      this checklist from what actually *happened*, not from what you remember authoring — the whole
      point is to catch the node you forgot.
   b. **Assert one outcome per entity** — every item gets exactly `authored [[Page]]` **or**
      `skipped — <reason>` (e.g. "no material change", "not a node", "already current"). Nothing may be
      left unaccounted for. If an entity that genuinely advanced has neither, `author` it now (Step 6).
   Carry the tally into the Output.

   > **A read-back verification sub-step lived here and was REMOVED 2026-07-31. Do not re-add it
   > without new evidence.** It asked you to `read_page` every page you had just authored, to confirm
   > the write landed. Measured over 397 local transcripts — 18 sessions that wrote a page,
   > 2026-07-29→31 — **18 `author` calls were rejected and all 18 were retried to success: zero
   > silently lost.** An end-of-session pass would have caught nothing, because the rejection reason
   > arrives *in the tool result at the moment of the call*. Session end is the weakest place to
   > verify a write; the result you already have in hand is the strongest.
   >
   > **What replaces it — at the moment of each write, not at the end:** a rejected `author` comes back
   > as an ORDINARY tool result with **no error flag** — `Could not author "<page>": Agnoclast API 409:
   > <reason>` — and `No change to "<page>"` is a **200 OK that wrote nothing**. Neither is an error at
   > the protocol level, so nothing will interrupt you. **Read the result text of every write; never
   > skim it.** That inline read is where this step's value actually was.

## Output

After calling `log_session`, show a short structured summary:

```markdown
## Session summary

**Worked on:** brief description
**Decisions:** decision 1; decision 2
**Open / blocked:** anything unresolved or waiting on someone
**Coordinated with:** people involved
**Logged:** ✅ persisted as the session's record (authoritative)  (or ⚠ log_session errored — run doctor)
**Wiki authored:** [[Node A]], [[Node B]] — pages updated (or "— nothing advanced this session")
**Reconciled:** N touched → M authored, K skipped (reason each)
```

## Safety rules

- This skill summarizes and persists the session's record (via `log_session`). It never sends external
  messages, never deletes anything, and never changes access on a record without the user explicitly asking.
- Raw session text stays on this machine — only the curated summary-grade record reaches the org, scoped
  by access rules.
