# Memory Capture Rules

Memory lives in Claude Code's native auto-memory directory,
`~/.claude/projects/<project>/memory/` (a worktree shares its main
project's). **The native writer is the writer.** When you learn something
worth keeping, write it there yourself, at the moment you learn it — the
way the platform's own memory instruction says to: one fact per file with
frontmatter, and an index line in `MEMORY.md` ONLY if it is a standing
fact. There is no capture command, no scripted write path, no
after-the-fact extractor and no validator. Full contract, one page:
`cabinet/memory-contract.md`.

## The three layers

1. **Front of mind — `MEMORY.md`.** Loaded at every session start. Holds
   **standing facts only**: preferences, identity, hard constraints, what
   is currently true. One line per fact, pointing at its file. Small on
   purpose.
2. **Recalled on cue — everything else.** Lessons, decisions, past
   solutions, session records. Written as a topic file in the memory dir
   with **no index line**, and reached by `/recall <question>` when a
   session needs it. `/recall` searches every memory file (indexed or
   not), the per-session records, the archived drafts and the retained
   transcripts, and answers as one cited paragraph. (In a project where
   the watchtower runtime is not installed, grep the memory dir and the
   session records directly — the discipline is the same, only the verb
   is missing.)
3. **Live now** — threads and the last session, in the session-start
   injection. Not memory's job.

## When to write

Capture at the moment of learning, without asking whether to save it:

- **A standing fact** — a preference the operator stated, a correction
  they made, an identity fact, a hard constraint that will hold next
  month → write the file AND add its index line to `MEMORY.md`.
- **A lesson, a decision with its reasoning, a discovered gotcha, how a
  problem was solved** → write the file; NO index line. `/recall` will
  find it.
- **A standing fact that stopped being true** → the session that notices
  edits it: rewrite the line and the file, or delete both.

Update an existing memory rather than write a duplicate — search first
(`/recall` or a grep of the memory dir). That instruction is the dedup.

## Never

- Never write a **region pointer** (`- region \`lesson_*.md\` → …`).
  The convention is retired; the platform cannot read it.
- Never run a trimming, decay or consolidation pass of your own, and never
  build a cap. The platform enforces its own index cap and reminds the
  session when `MEMORY.md` is over it; its background consolidation
  ("auto-dream", `/dream` by hand) merges, re-dates and re-indexes the
  folder — leave it on.
- Never put a lesson or a dated observation on the index "so it gets
  seen". A line on the index is a claim that the fact is standing.

## Before re-deriving anything

**`/recall` before you re-derive a solution, re-argue a decision, or
re-discover a constraint.** The lament behind this model is real: you do
not know what you needed to remember until later. The answer is to ask
the record at the moment of need, not to guess that nothing was written.
The `/memory` skill browses the same index and corpus.

A cue line may appear before a prompt ("The project record may already answer
this: …"), naming one file by title and path. It is a pointer the session
judges — read the named file if it is relevant, ignore it if not — and it
never replaces `/recall` for a real question.

## What NOT to capture

- Code patterns visible by reading current files
- Git history (use `git log`)
- Anything already in CLAUDE.md, a rule, or a briefing file
- Ephemeral debugging details
- Information that changes frequently (use state files instead)

## In-session immediacy is not a memory problem

If guidance must apply *in this turn* ("always use pnpm"), it belongs in
`.claude/rules/`, not memory. Rules load eagerly; the index loads at
start; everything else is recalled on cue.

## Why this shape

Measured (Simplification Project 1, 2026-09): files with a direct index
line were read ~20x more per file than files reachable only through a
region pointer; sessions opened ~1% of the pointer-reachable corpus in a
month and never grepped it; the post-hoc extractor filed drafts into a
queue whose only consumer was the 30-day expiry. What survived is what
was read: hand-written, in-session, directly indexed standing facts —
plus a retriever for everything else. Plan and evidence:
`.claude/plans/simplification-1-memory-retrieval.md`.
