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

> **Cortex-managed skill.** This file is installed and kept up to date by Cortex. 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 Cortex 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. Cortex 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. **Summarize the session** — what was worked on, what was decided, what changed. Be concrete: name
   the projects, files, and people involved.
2. **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.
3. **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 Cortex 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.
4. **Confirm + flag privacy** — `log_session` returns a confirmation; if it errors, tell the user to
   run `npx -y @theronap/cortex-mcp doctor`. If any record from this session should be confidential,
   note it so the user can mark it (`set_record_privacy`). Default is org-visible under access rules.
5. **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.
6. **Sweep pending documentation** — run `npx -y @theronap/cortex-mcp docs-scan --json`; if any
   docs are pending, follow the `cortex-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.
7. **Reconcile & verify (prove the sweep — don't trust it).** Step 5 relies on your in-the-moment
   judgment of "what advanced"; this step closes the loop so nothing is silently missed and no stale
   write slips through. 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 5).
   c. **Verify the writes landed and are right** — for each page you claim you authored, `read_page` it
      (or check `page_history`) and confirm both: (i) **the change applied** — an `author` that returned
      "no change" when you *intended* an update means it did NOT land (stale `base_version`, wrong
      brain/namespace, or nothing actually differed) — re-check rather than assume; and (ii) **the page
      reflects THIS session's first-hand findings**, not a prior you copied forward. This is the
      read-after-write half of the read-before-write rule — the guard against laundering stale priors
      into the wiki. Fix a page you can edit; `set_page_validity` on one you can't. (Cross-brain note:
      `read_page` can resolve a page in another brain that `author` won't write — if a "verify" read
      looks right but your write reported no-op, run `my_brains` / check `authoring_context` before
      trusting the read.)
   Carry the tally into the Output. If any intended write did not land, say so — never report a clean
   sweep you didn't confirm.

## 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); writes verified ✅ (or ⚠ <what didn't land>)
```

## 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.
