Persistent Memory
Capture, recall, consolidate, and forget memories scoped to a user-chosen
topic (e.g. parenting, work, relationship-anna) as plain markdown
files, so any future conversation can pick up where the last one left off.
This SKILL.md is a thin index. Operation pipelines, taxonomy,
privacy rules, integration patterns, and scaling guidance live in
rules/*.md and load on demand. Literal artefact templates live in
templates/*.md. Worked examples and citations live in references/*.md.
Read only what the current operation asks for.
Mode Detection
Parse $ARGUMENTS (first token) and detect the operation:
| Operation |
Default |
Trigger phrases |
write |
yes |
"remember", "save to memory", "add to memory", $0 == "write" |
read |
|
"recall", "load memory", "what do you remember about", $0 == "read" |
consolidate |
|
"consolidate memory", "compress memory", $0 == "consolidate" |
forget |
|
"forget that", "delete memory", "redact", $0 == "forget" |
list |
|
"list memory", "what scopes do I have", $0 == "list" |
State the detected operation and resolved scope in one line before
continuing. Example:
Operation: write
Scope: parenting
Storage tier: home (~/.agent-memory/parenting/)
If no scope is provided, ask once (single batched message) — never guess.
Required Reading by Operation
Load on demand — do not preload.
Storage Layout (one-line summary; full rules in rules/storage-layout.md)
Three tiers; the user picks per invocation, or accepts the default.
| Tier |
Path |
Committed? |
Default for |
home (default) |
~/.agent-memory/<scope>/ |
No |
Personal scopes (parenting, work) |
project-local |
<repo>/.agent/memory/<scope>/ |
No (gitignore) |
Per-project private notes |
project-shared |
<repo>/memory/<scope>/ |
Yes |
Team-shared project knowledge |
Per-scope directory layout (identical across tiers):
<storage-root>/<scope>/
├── INDEX.md # Curated, ≤ 200 lines; always loaded by `read`
├── entries/ # Individual memory entries; loaded on demand
│ └── <yyyy-mm-dd>-<slug>.md
├── archive/ # Consolidated / superseded entries (audit trail)
└── AUDIT.log # Append-only ledger of write / consolidate / forget
Core Workflow
Every operation is gated. Do not proceed to the next phase until the
prior phase's gate passes.
write (default)
read
consolidate
forget
list
Walk every storage tier the user has enabled, print every scope with
entry counts and last-updated timestamps. No writes.
Integration With Other Skills
This skill is model-invocable (disable-model-invocation: false)
so host workflows can call it programmatically. Two ways to invoke it:
- Explicit — the user types
/persistent-memory write parenting
or /persistent-memory read parenting.
- Runtime, from a host skill — the host skill's
SKILL.md
contains a one-line pointer block that calls
Skill("persistent-memory", "read <scope>") when the host runs.
The second form is the canonical integration. Runtime Skill() calls
require disable-model-invocation: false — without it the Skill tool
refuses the call at the harness layer (you'd see
Skill X cannot be used with Skill tool due to disable-model-invocation).
See
rules/integration-with-skills.md
for the full contract and the literal snippet at
templates/pointer-snippet.md.
| Pattern |
Token cost |
Magic |
Best for |
| Pointer |
INDEX only, on skill load |
None |
The default. Explicit, debuggable, no hook. |
| Hook |
INDEX every session |
High |
Always-on scopes (e.g. a personal assistant). |
For the parenting example: add one block to parenting/SKILL.md:
> **Persistent memory:** Before responding, run
> `Skill("persistent-memory", "read parenting")` to load accumulated
> context for this scope.
| Tier |
Backend |
Use when |
| 1 |
Plain markdown (this skill, default) |
≤ ~500 entries per scope, single user, no semantic search needed |
| 2 |
Markdown + SQLite FTS index (this skill, opt-in) |
Up to ~5k entries per scope, keyword search beats full-INDEX scan |
| 3 |
Markdown blobs + local vector DB (Chroma, Qdrant) |
Semantic recall ("what did we discuss about X") matters |
| 4 |
Managed memory layer (Mem0, Letta, Zep) |
Multi-user, multi-tenant, > 10k entries, graph relationships, hosted SLA |
Graduate one tier at a time. The skill ships a migration recipe in
rules/scaling-tiers.md for moving from
markdown to SQLite, and from SQLite to a vector DB, without losing
entries.
Core Principles
- Plain text, local-first. Memory is markdown the user can read,
edit, grep, and delete with standard tools. No proprietary format.
- Progressive disclosure. INDEX is small and always loaded; detail
entries load on demand. Modeled on Claude Code's MEMORY.md.
- Two-phase write. Extract candidates first, then resolve each
against existing entries with ADD / UPDATE / DELETE / NOOP. Modeled
on Mem0's extraction + update pipeline.
- Consent before persistence. Every write shows the user a diff
preview unless
--auto is passed; secrets and PII on the never-store
list are refused outright.
- Forgetting is a feature. A clear
forget operation is part of
the surface, not an afterthought. Required for privacy and for
pruning entrenched mistakes (see Reflexion entrenchment warning).
- One scope, one purpose. Resist mega-scopes ("life"). Split into
parenting, health, work etc. so the INDEX stays under 200 lines.
- Markdown until it hurts. Stay on Tier 1 until a concrete signal
(search latency, INDEX bloat, multi-user) forces a graduation.
- Writing to memory without showing the user the diff first.
- Storing secrets, credentials, or government IDs (refuse outright).
- Mega-scopes that swell the INDEX past 200 lines.
- Letting the model auto-write without scope confirmation.
- Re-recording the same fact instead of UPDATE-ing the existing entry.
- Deleting an entry without an AUDIT.log line.
- Skipping consolidation forever — the INDEX rots and recall degrades.
- Committing
~/.agent-memory/ to a public repo.
Definition of Done
A write run is done when:
A read run is done when:
A consolidate run is done when:
A forget run is done when:
1---2name: persistent-memory3description: Persists context across conversations as plain markdown so every future session can enrich a topic-scoped memory (e.g. `parenting`, `relationship-anna`, `work-history`, `project-acme`). Four operations: `write` (extract candidates, resolve as ADD / UPDATE / DELETE / NOOP per Mem0), `read` (load a ≤ 200-line INDEX; fetch detail entries on demand per Claude Code's MEMORY.md pattern), `consolidate` (sleep-style merge + prune), `forget` (delete or redact with audit). Three storage tiers: home (`~/.agent-memory/<scope>/`, default), project-local (gitignored), project-shared (committed). Strict never-store list (passwords, API keys, JWTs, credit cards, SSNs, private keys); mandatory consent preview before write. Documents scaling from markdown → SQLite FTS → vector DB → managed memory (LoreKit / Mem0 / Letta / Zep). Documents the LoreKit backend the self-improvement loops now run on (`autonomous-workflow`, `fix-bug`, `batch-linear-tickets`, `implement-suggestion`, `ci-auto-fix`, `e2e-pr-stabilizer`, `test-auto-fix`4license: MIT5---67# Persistent Memory89Capture, recall, consolidate, and forget memories scoped to a user-chosen10topic (e.g. `parenting`, `work`, `relationship-anna`) as plain markdown11files, so any future conversation can pick up where the last one left off.1213> **This `SKILL.md` is a thin index.** Operation pipelines, taxonomy,14> privacy rules, integration patterns, and scaling guidance live in15> `rules/*.md` and load on demand. Literal artefact templates live in16> `templates/*.md`. Worked examples and citations live in `references/*.md`.17> Read only what the current operation asks for.1819---2021## Mode Detection2223Parse `$ARGUMENTS` (first token) and detect the operation:2425| Operation | Default | Trigger phrases |26| ------------- | ------- | ------------------------------------------------------------------------ |27| `write` | **yes** | "remember", "save to memory", "add to memory", `$0 == "write"` |28| `read` | | "recall", "load memory", "what do you remember about", `$0 == "read"` |29| `consolidate` | | "consolidate memory", "compress memory", `$0 == "consolidate"` |30| `forget` | | "forget that", "delete memory", "redact", `$0 == "forget"` |31| `list` | | "list memory", "what scopes do I have", `$0 == "list"` |3233State the detected operation and resolved scope in one line before34continuing. Example:3536```text37Operation: write38Scope: parenting39Storage tier: home (~/.agent-memory/parenting/)40```4142If no scope is provided, ask once (single batched message) — never guess.4344---4546## Required Reading by Operation4748Load on demand — do not preload.4950| Operation | Files |51| ------------- | ---------------------------------------------------------------------------------------------- |52| `write` | [`rules/storage-layout.md`](./rules/storage-layout.md), [`rules/write-pipeline.md`](./rules/write-pipeline.md), [`rules/memory-taxonomy.md`](./rules/memory-taxonomy.md), [`rules/privacy-and-consent.md`](./rules/privacy-and-consent.md) |53| `read` | [`rules/storage-layout.md`](./rules/storage-layout.md), [`rules/read-pipeline.md`](./rules/read-pipeline.md) |54| `consolidate` | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md), [`rules/memory-taxonomy.md`](./rules/memory-taxonomy.md) |55| `forget` | [`rules/forget-pipeline.md`](./rules/forget-pipeline.md), [`rules/privacy-and-consent.md`](./rules/privacy-and-consent.md) |56| `list` | [`rules/storage-layout.md`](./rules/storage-layout.md) |57| integration | [`rules/integration-with-skills.md`](./rules/integration-with-skills.md) |58| scaling | [`rules/scaling-tiers.md`](./rules/scaling-tiers.md) |59| pre-flight | [`rules/quality-checklist.md`](./rules/quality-checklist.md), [`rules/anti-patterns.md`](./rules/anti-patterns.md) |6061---6263## Storage Layout (one-line summary; full rules in [`rules/storage-layout.md`](./rules/storage-layout.md))6465Three tiers; the user picks per invocation, or accepts the default.6667| Tier | Path | Committed? | Default for |68| ----------------- | --------------------------------- | ---------- | -------------------------------------- |69| `home` (default) | `~/.agent-memory/<scope>/` | No | Personal scopes (parenting, work) |70| `project-local` | `<repo>/.agent/memory/<scope>/` | No (gitignore) | Per-project private notes |71| `project-shared` | `<repo>/memory/<scope>/` | Yes | Team-shared project knowledge |7273Per-scope directory layout (identical across tiers):7475```text76<storage-root>/<scope>/77├── INDEX.md # Curated, ≤ 200 lines; always loaded by `read`78├── entries/ # Individual memory entries; loaded on demand79│ └── <yyyy-mm-dd>-<slug>.md80├── archive/ # Consolidated / superseded entries (audit trail)81└── AUDIT.log # Append-only ledger of write / consolidate / forget82```8384---8586## Core Workflow8788Every operation is gated. Do not proceed to the next phase until the89prior phase's gate passes.9091### `write` (default)9293| Phase | Name | Rule | Gate |94| ----- | --------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------- |95| 0 | Resolve scope + tier | [`rules/storage-layout.md`](./rules/storage-layout.md) | Scope name + storage tier confirmed; directory created |96| 1 | Privacy pre-flight | [`rules/privacy-and-consent.md`](./rules/privacy-and-consent.md) | No secrets / PII on the never-store list slip through |97| 2 | Extract candidates | [`rules/write-pipeline.md`](./rules/write-pipeline.md) | Candidate list produced with type, confidence, source per item |98| 3 | Compare to existing | [`rules/write-pipeline.md`](./rules/write-pipeline.md) | Each candidate tagged ADD / UPDATE / DELETE / NOOP |99| 4 | Consent preview | [`rules/privacy-and-consent.md`](./rules/privacy-and-consent.md) | User saw the diff and approved (unless `--auto` flag) |100| 5 | Write + audit | [`rules/write-pipeline.md`](./rules/write-pipeline.md) | INDEX updated, entry files written, AUDIT.log line appended |101102### `read`103104| Phase | Name | Rule | Gate |105| ----- | ---------------- | ---------------------------------------------------------- | ------------------------------------------------------------- |106| 0 | Resolve scope | [`rules/storage-layout.md`](./rules/storage-layout.md) | Scope directory exists; INDEX.md present (or report empty) |107| 1 | Load INDEX | [`rules/read-pipeline.md`](./rules/read-pipeline.md) | INDEX content surfaced to current conversation |108| 2 | On-demand fetch | [`rules/read-pipeline.md`](./rules/read-pipeline.md) | Detail entries fetched only when INDEX points to them |109110### `consolidate`111112| Phase | Name | Rule | Gate |113| ----- | ---------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------- |114| 0 | Snapshot | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md) | Pre-consolidation state captured (path + file count) |115| 1 | Group + merge | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md) | Semantically similar entries grouped; merge plan drafted |116| 2 | Prune stale | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md) | Entries past staleness cutoff flagged for archive |117| 3 | Preview + apply | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md) | User saw before / after summary and approved |118| 4 | Rewrite INDEX | [`rules/consolidate-pipeline.md`](./rules/consolidate-pipeline.md) | INDEX reflects new state; AUDIT.log appended |119120### `forget`121122| Phase | Name | Rule | Gate |123| ----- | ---------------- | ---------------------------------------------------------- | ------------------------------------------------------------- |124| 0 | Resolve target | [`rules/forget-pipeline.md`](./rules/forget-pipeline.md) | Memory id, slug, or query resolves to exactly one entry set |125| 1 | Show + confirm | [`rules/forget-pipeline.md`](./rules/forget-pipeline.md) | User saw the entries and explicitly confirmed |126| 2 | Delete or redact | [`rules/forget-pipeline.md`](./rules/forget-pipeline.md) | Entries removed (or redacted); INDEX + AUDIT.log updated |127128### `list`129130Walk every storage tier the user has enabled, print every scope with131entry counts and last-updated timestamps. No writes.132133---134135## Integration With Other Skills136137This skill is **model-invocable** (`disable-model-invocation: false`)138so host workflows can call it programmatically. Two ways to invoke it:1391401. **Explicit** — the user types `/persistent-memory write parenting`141 or `/persistent-memory read parenting`.1422. **Runtime, from a host skill** — the host skill's `SKILL.md`143 contains a one-line pointer block that calls144 `Skill("persistent-memory", "read <scope>")` when the host runs.145146The second form is the canonical integration. Runtime `Skill()` calls147require `disable-model-invocation: false` — without it the Skill tool148refuses the call at the harness layer (you'd see149`Skill X cannot be used with Skill tool due to disable-model-invocation`).150See151[`rules/integration-with-skills.md`](./rules/integration-with-skills.md)152for the full contract and the literal snippet at153[`templates/pointer-snippet.md`](./templates/pointer-snippet.md).154155| Pattern | Token cost | Magic | Best for |156| --------------- | ------------------------- | ----- | ---------------------------------------------- |157| **Pointer** | INDEX only, on skill load | None | The default. Explicit, debuggable, no hook. |158| **Hook** | INDEX every session | High | Always-on scopes (e.g. a personal assistant). |159160For the parenting example: add one block to `parenting/SKILL.md`:161162```markdown163> **Persistent memory:** Before responding, run164> `Skill("persistent-memory", "read parenting")` to load accumulated165> context for this scope.166```167168---169170## Scaling Tiers (full guidance in [`rules/scaling-tiers.md`](./rules/scaling-tiers.md))171172| Tier | Backend | Use when |173| ---- | ---------------------------------------------- | ------------------------------------------------------------------------ |174| 1 | Plain markdown (this skill, default) | ≤ ~500 entries per scope, single user, no semantic search needed |175| 2 | Markdown + SQLite FTS index (this skill, opt-in) | Up to ~5k entries per scope, keyword search beats full-INDEX scan |176| 3 | Markdown blobs + local vector DB (Chroma, Qdrant) | Semantic recall ("what did we discuss about X") matters |177| 4 | Managed memory layer (Mem0, Letta, Zep) | Multi-user, multi-tenant, > 10k entries, graph relationships, hosted SLA |178179Graduate one tier at a time. The skill ships a migration recipe in180[`rules/scaling-tiers.md`](./rules/scaling-tiers.md) for moving from181markdown to SQLite, and from SQLite to a vector DB, without losing182entries.183184---185186## Core Principles1871881. **Plain text, local-first.** Memory is markdown the user can read,189 edit, grep, and delete with standard tools. No proprietary format.1902. **Progressive disclosure.** INDEX is small and always loaded; detail191 entries load on demand. Modeled on Claude Code's MEMORY.md.1923. **Two-phase write.** Extract candidates first, then resolve each193 against existing entries with ADD / UPDATE / DELETE / NOOP. Modeled194 on Mem0's extraction + update pipeline.1954. **Consent before persistence.** Every write shows the user a diff196 preview unless `--auto` is passed; secrets and PII on the never-store197 list are refused outright.1985. **Forgetting is a feature.** A clear `forget` operation is part of199 the surface, not an afterthought. Required for privacy and for200 pruning entrenched mistakes (see Reflexion entrenchment warning).2016. **One scope, one purpose.** Resist mega-scopes ("life"). Split into202 `parenting`, `health`, `work` etc. so the INDEX stays under 200 lines.2037. **Markdown until it hurts.** Stay on Tier 1 until a concrete signal204 (search latency, INDEX bloat, multi-user) forces a graduation.205206---207208## Anti-patterns (one-liner — full list in [`rules/anti-patterns.md`](./rules/anti-patterns.md))209210- Writing to memory without showing the user the diff first.211- Storing secrets, credentials, or government IDs (refuse outright).212- Mega-scopes that swell the INDEX past 200 lines.213- Letting the model auto-write without scope confirmation.214- Re-recording the same fact instead of UPDATE-ing the existing entry.215- Deleting an entry without an AUDIT.log line.216- Skipping consolidation forever — the INDEX rots and recall degrades.217- Committing `~/.agent-memory/` to a public repo.218219---220221## Definition of Done222223A `write` run is done when:224225- [ ] Scope and storage tier explicitly resolved (no defaults assumed silently).226- [ ] Privacy pre-flight passed (no never-store items in candidates).227- [ ] Candidate list shown to the user with ADD / UPDATE / DELETE / NOOP tags.228- [ ] User approved (or `--auto` flag was explicit).229- [ ] Entry files written; INDEX updated; AUDIT.log line appended.230- [ ] One-line summary delivered: "Saved N memories to <scope> (<tier>)."231232A `read` run is done when:233234- [ ] Scope resolved; if no INDEX exists, user is told the scope is empty.235- [ ] INDEX content is now in the conversation context.236- [ ] Detail entries are fetched only when the INDEX references them.237238A `consolidate` run is done when:239240- [ ] Before / after summary shown (entry count delta, INDEX line delta).241- [ ] User explicitly approved.242- [ ] AUDIT.log line appended with operation, timestamp, and counts.243244A `forget` run is done when:245246- [ ] Target entries shown verbatim before deletion.247- [ ] User confirmed (typed "yes" or `--confirm` flag).248- [ ] Entries removed (or redacted); INDEX updated; AUDIT.log line appended.