Give your AI agents a shared memory that survives every session
Your agents forget everything when a session ends, re-derive settled facts, and contradict decisions nobody wrote down. Here's how to give them a durable, file-based shared brain, one place agents read at session start and write back at session end, so knowledge compounds instead of resetting.
- System
- shared agent memory
- Origin
- Abstracted from the shared brain of a production agent fleet.
Try this recipe in your own project
Read the files below first. The download for the whole kit asks for your email.
SKILL.md3.3 KBreference/AGENTS.md1.7 KBreference/memory-file.example.md1.1 KBreference/MEMORY.index.example.md1.4 KB
Start in a test project with synthetic data. A skill file provides instructions; it does not grant permissions, start an autonomous process or establish compatibility with every agent host. Check this guide’s evidence and applicable file-specific licence.
The problem
Your AI agents forget everything the moment a session ends. Every new session you re-explain the project, the decisions already made, how you like things done. Run two agents in parallel and neither knows what the other learned. Worse: an agent confidently re-derives a fact you settled last week, or contradicts a decision nobody wrote down. The knowledge that should compound just evaporates, session after session, and you become the only long-term memory the system has.
What you get
A durable, file-based brain your agents read at the start of every session and write back to at the end, so knowledge accumulates instead of resetting:
- Agents start already knowing the project, the settled decisions, and your preferences, no re-briefing.
- One shared brain across all agents: what one learns, the others can read.
- Knowledge is typed and findable: durable facts, current status, settled decisions, and time-bound work live in separate, predictable places.
- It doesn't rot: a curation habit keeps it deduplicated, current, and small enough to actually load.
Use when / skip when
Use when you run agents repeatedly on the same project or product, especially more than one agent, and you're tired of being the only thing that remembers.
Skip when it's a one-off task, or the knowledge already lives somewhere the agent reads anyway (the code, the git history, a ticket). Don't store what the repo already records, store only what isn't derivable from it.
Ingredients
- A version-controlled repo the agents can read and write (git is ideal, the history is a free audit log). BYO. This is your repo, not a service.
- Agents that can read files at session start and write files at session end (a rules/context file that instructs them to is enough).
- A human or agent curator for the periodic cleanup pass. That's it, no database, no vector store, no framework.
The recipe
1. Make one repo the single source of truth. Durable knowledge, decisions, preferences, and current state all live here as plain markdown. Agents read from it at the start of a session and write back at the end. One brain, one place.
2. Separate knowledge by how it changes. Four kinds, four homes, mixing them is why memory rots:
- Durable knowledge / preferences: facts that stay true (who the user is, how they work, hard-won lessons). One fact per file.
- Current status: what exists, what's live, what's in flight. Overwritten, not appended: current state, not a changelog.
- Decisions: settled calls, with the why. Append-only; a decision is a record, not a status.
- Time-bound work: plans with a lifecycle (draft → active → done → archived). Dated, and archived when finished, never deleted.
3. One fact per file, plus an index. Each durable memory is its own small file
with frontmatter, a name (stable slug), a one-line description (used to judge
relevance on recall), and a type. A single index file lists one line per memory
so an agent can scan what exists before loading the bodies. One monolithic memory
file becomes unfindable and un-mergeable; small files + an index scale.
4. Write the read/write protocol into the agent's rules. In the file your agent
loads every session, state plainly: at session start, read the index + the
relevant files; at session end, write back what changed. The protocol is what
makes the brain live, without it you have a folder nobody opens. See
reference/AGENTS.md.
5. Prefer artifacts over chat. A result that matters gets written to a file in the brain, not left in a conversation that evaporates. If it's worth producing, it's worth a place to be found again. (Quick lookups stay in chat, don't file everything; file the things meant to compound.)
6. Link related memories. A lightweight [[other-memory-name]] link between
files lets the brain form a graph, an agent reading one fact discovers the
related ones. A link to a memory that doesn't exist yet is fine; it marks
something worth writing later.
7. Give it a curator (see Keeping it healthy). Memory rots without one.
Evidence
From an agent fleet running this as its shared brain in production:
- Keep memory separate from how agents run. The storage layer stayed unchanged while the way the agents ran was rebuilt around it several times. That separation is the most important decision here.
- One-fact-per-file + an index out-performed a single large memory file: agents find the relevant fact without loading everything, and two agents editing different facts don't collide.
- Curation is not optional: without a periodic consolidation pass, duplicates and stale facts accumulate until the brain actively misleads.
What might go wrong
- The brain rots. Bites within weeks: duplicate memories, facts that now contradict reality, an index that lags the files. Symptom: agents cite things that are no longer true. Prevention is a scheduled consolidation pass that merges duplicates, fixes stale facts, and prunes. A memory system with no curator degrades into a liability.
- Stale recall stated as fact. A memory is a point-in-time snapshot. One that names a file, flag, or function may describe a world that has since changed. Rule: treat recalled memory as a lead to verify, not ground truth, check it against the live code before acting on it.
- The monolith trap. One giant memory file feels simpler and then becomes unsearchable and un-mergeable. Small files + an index from day one.
- Storing the derivable. Memories that restate the code structure, the git history, or the ticket are noise that buries the signal. Store only what is not recoverable from the repo itself, the non-obvious.
- The folder nobody opens. If the read/write protocol isn't in the agent's standing instructions, the brain exists but never gets read or updated. The protocol is the recipe, not the folder.
Keeping it healthy
What keeps it alive:
- A curator (a human, or a dedicated agent role) runs a periodic consolidation pass: merge duplicates, reconcile stale facts against reality, prune what is no longer true, keep the index honest and the files small.
- The write-back-at-session-end habit: enforced by the agent's rules file, is what feeds the brain. If sessions only read and never write, knowledge stops compounding.
- Keep files small and current: a memory file that grows into a history document should be trimmed to current state; the git history holds the past.
The skill
The skill and its reference code, in full. This is what an agent follows to build the pattern in your codebase. Copy any file here, or get every guide as one kit from naturate.io/recipes.
SKILL.md3.3 KB
---
name: shared-agent-memory
description: Give AI agents a shared memory that survives every session — a version-controlled, file-based brain agents read at session start and write at session end, so knowledge compounds instead of resetting. Use when running agents repeatedly on the same project, especially more than one agent.
---
# Set up a shared brain for a user's agents
You are giving a developer's AI agents a durable, file-based shared memory in their
own repo. Implement it here, adapting to their setup. No database, no vector store —
plain markdown in version control plus a read/write protocol.
## Detect their setup
Which agent(s) they use (Claude Code, Cursor, etc.) and where each reads its
standing instructions (e.g. `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, a rules dir).
Whether they have a repo to hold the brain (use it) or need one. Whether they run
multiple agents (raises the value of one shared brain).
## Build this
1. **Pick the brain's home** — a version-controlled repo (or a `memory/` + docs
tree inside their existing one). Git so history is a free audit log.
2. **Create the four homes, separated by how knowledge changes:**
- durable knowledge / preferences (one fact per file)
- current status (overwritten, not appended)
- decisions (append-only, with the why)
- time-bound plans (dated, lifecycle draft→active→done→archived)
3. **Memory file schema** — each durable memory is a small file with frontmatter:
`name` (stable slug), `description` (one line, used to judge relevance on
recall), `type`. Body = the one fact, linking related memories with
`[[other-name]]`. See `reference/memory-file.example.md`.
4. **The index** — one file listing one line per memory (`- [title](file.md) —
hook`) so an agent scans what exists before loading bodies. See
`reference/MEMORY.index.example.md`.
5. **Write the read/write protocol into their agent's rules file** — the crucial
step. At session start: read the index + relevant files. At session end: write
back what changed. Adapt `reference/AGENTS.md` into their `CLAUDE.md` /
`.cursorrules` / rules dir. Without this the brain is a folder nobody opens.
6. **Add the "artifacts over chat" habit** — results that matter get filed, not
left in a conversation. And the "don't store the derivable" rule — nothing that
restates the code, git history, or a ticket.
7. **Set up the pulse** — a periodic curation pass (a scheduled task, or a
dedicated curator agent role) that merges duplicates, fixes stale facts against
reality, prunes, and keeps files small + the index honest.
## Guardrails to enforce
- The read AND write halves both go in the rules file — a read-only brain stops
compounding.
- One fact per file + an index. Never one monolithic memory file.
- Recalled memory is a lead to verify, not ground truth — instruct the agent to
check anything that names a file/flag/function against live code before asserting.
- Store only the non-obvious; skip anything derivable from the repo.
## Verify before done
Open a fresh session and confirm the agent reads the index unprompted, can answer
a project question from memory alone, and writes a new/updated memory at session
end. Confirm two memories don't duplicate the same fact.
## Read alongside
`RECIPE.md` (the why + receipts) and `reference/` (protocol + schema to adapt).
reference/AGENTS.md1.7 KB
<!-- Reference: the read/write protocol. Adapt into the agent's own standing
instructions file (CLAUDE.md, AGENTS.md, .cursorrules, or a rules dir).
This is the piece that makes the brain live — without it, the folder is
never opened. -->
# Shared brain protocol
This repo is the shared brain. Read from it at session start; write back at
session end.
## At session start
1. Read `MEMORY.md` — the index. One line per memory; scan for what's relevant.
2. Read the current-status file for what exists / is live / is in flight.
3. Read the specific memory files, decisions, or plans the task touches.
## At session end (write back what changed)
| If you… | Write to… |
|---|---|
| Learned a durable fact or preference | a new one-fact memory file + a line in `MEMORY.md` |
| Changed what's live / shipped / in flight | the current-status file (overwrite to current state) |
| Made a settled decision | append it to the decisions log, with the why |
| Started time-bound work | a dated plan file (status: draft/active) |
## Rules
- **One fact per memory file**, with frontmatter (`name`, `description`, `type`).
Link related memories with `[[name]]`.
- **Current state, not history** in status files — the git log holds the past.
- **Artifacts over chat** — file what's meant to compound; don't leave it only in
a reply.
- **Don't store the derivable** — nothing recoverable from the code, git history,
or a ticket. Store the non-obvious.
- **Recalled memory is point-in-time** — before acting on a memory that names a
file, flag, or function, verify it against the live code.
- Before saving, check for an existing memory that already covers it — update that
file rather than create a duplicate.
reference/memory-file.example.md1.1 KB
<!-- Reference: one durable memory = one small file with this frontmatter.
`description` is what an agent reads to judge relevance before loading the body. -->
---
name: deploy-target-is-staging
description: App pushes go to the staging environment, which is what real users hit
type: reference # user | preference | project | decision | reference
---
App builds are pushed to the **staging** environment, not a separate prod — staging
is what real users are on. Verify the target before any release.
Related: [[release-checklist]], [[no-direct-prod-deploys]]
<!-- Notes on the fields:
name — stable kebab-case slug; also the link target for [[name]]
description — ONE line; the recall filter, so make it specific
type — the four homes: durable knowledge (user/preference/reference),
project status, or a decision. Plans live as dated files, not here.
body — the single fact. For preferences/decisions, add a line on WHY
and HOW to apply it. Link related memories liberally. -->
reference/MEMORY.index.example.md1.4 KB
<!-- Reference: the index (step 4). One line per memory file, so an agent can
scan what exists BEFORE loading any bodies. Keep it short — a hook, not a
summary. Regenerate or hand-edit whenever a memory file is added, renamed,
or retired; a stale index is worse than no index. -->
# Memory index
One line per durable memory. Format: `- [name](relative/path.md) — description`.
## User / preferences
- [deploy-target-is-staging](memory-file.example.md) — app pushes go to
staging, which is what real users hit; verify the target before any release.
## Project / reference
- [release-checklist](release-checklist.md) — the steps that precede any deploy
(not written yet — a link to a memory that doesn't exist is fine; it marks
something worth writing later).
## Decisions
- [no-direct-prod-deploys](no-direct-prod-deploys.md) — all releases go through
staging first; settled, with the why, in the decisions log (illustrative —
your decisions log has its own home; see RECIPE.md step 2).
<!-- Notes:
- Group however makes sense for your project (by type, by area) — the
index is a scan surface, not a schema.
- A link to a memory that doesn't exist yet is fine; it marks something
worth writing later (see RECIPE.md, "link related memories").
- Keep entries current: retire the line when the file is archived, don't
just delete the file and leave a dangling index entry.
-->
Where this comes from
Abstracted from the shared brain of a production agent fleet. It shares patterns, with no source code. The storage discipline is stable and long-proven; it is deliberately separate from the fleet's execution layer, which is not (and is not part of this recipe).
Make an AI voice feature start playing in seconds, not after a long wait
You hand LLM-generated narration to a text-to-speech provider and users stare at a loading spinner for tens of seconds before anything plays, or you reach for a faster voice model and it drops your pauses, mispronounces markup, or wanders accent mid-clip. Here's the pipeline that streams audio starting in seconds, keeps pauses and loudness consistent across voice tiers, and degrades gracefully instead of hanging.
Run a fleet of AI agents on real work without babysitting them
Several agents at once, on a schedule, while you're not watching, and it keeps going wrong: they clobber each other, run on your laptop with your credentials, stop to ask permission for everything, or fail silently for days. Here's the pattern that keeps a fleet safe and honest: isolated ephemeral workers, output-gated not permission-gated, fan-out caps, and a dumb watchdog that pages on silence.