How to Build Your Own AI Memory with Markdown Files
Part 1 explains the design and where each idea comes from. Part 2 follows one decision through the system. Part 3 is a prompt you can paste into Claude Code, Codex or Gemini CLI to build your own.
Part 1 — Why and how
The problem
Coding agents (Claude Code, Codex, Gemini CLI) are the most capable assistants available today, and they are built to work on code. Since June 2026 I have used them for something else: thinking about my life. That means yearly reflection, money, health, work, a house purchase, trips, investments.
Out of the box this fails in three ways:
- Nothing accumulates. Every session starts from zero, or from a vendor memory you cannot see, edit or move.
- Changing your mind erases history. When a target or a value changes, the old one is overwritten. But the drift itself is the most interesting signal.
- The agent's ideas silently become your decisions. An agent writes a lot. Three sessions later, nobody remembers whether "target allocation 60/40" was your decision or its suggestion.
So I built a plain-markdown git repository that any agent CLI can read and write. After four months it holds 18 life domains, and it is the first thing I open when a real decision comes up. This post explains the design, credits where each idea came from, and ends with a prompt your own agent can build from.
Glossary
I use everyday words for the parts of the system. The table maps them to the terms used elsewhere.
| My term | Common names elsewhere |
|---|---|
| Memory (the repository) | Agent memory, long-term memory, second brain, knowledge base, twin |
| Data (corpus, sessions) | Raw sources (Karpathy), episodic memory (for sessions), source of truth |
| Wiki | LLM wiki (Karpathy), semantic memory, summaries, materialized view |
| Schema (AGENTS.md files, skills) | System prompt, agent instructions, procedural memory (for skills) |
| Domain | Namespace, workspace, project |
| Session | Episode, conversation, thread |
| Close-session | Memory consolidation, reflection, write-back, compaction |
| Provenance and status | Provenance, lineage, trust, confidence |
| Supersession, validity windows | Bi-temporal facts, fact invalidation, versioning |
| Lint | Memory evaluation, consistency checks |
| Stance | Persona, role prompt |
| Decided (set only by the owner) | Human-in-the-loop approval, governance |
| None, on purpose: the system models documents and decisions, not entities | Ontology, knowledge graph, entity types (people, assets, accounts and the links between them) |
What I borrowed
- Andrej Karpathy, "LLM Wiki" (April 2026). Raw sources that never change, a wiki the LLM maintains, and a schema file that configures it, plus three operations (ingest, query, lint) and an append-only log. My three layers adapt this directly. Gist
- Google Cloud, Open Knowledge Format (June 2026). Markdown files with a YAML header, one concept per file, no SDK. I use its field names so my files stay compatible. Blog post · Spec
- Zep's Graphiti. Its two timelines (when a fact was true, when it was recorded) shaped my validity dates. I didn't use it as a store, because it moves memory into a graph database. GitHub
- Architecture Decision Records (Michael Nygard, 2011), for changes to the system's own rules. Article
- AGENTS.md, one instruction file for every vendor, with CLAUDE.md and GEMINI.md as symlinks to it. agents.md
- Agent Skills, for repeatable procedures such as closing a session. Anthropic
Other approaches to agent memory
Agent memory changes quickly. These are the other projects I compared against.
- Daniel Miessler, Personal AI Infrastructure. The project closest in spirit to mine. GitHub
- Basic Memory. I didn't adopt it because it writes its own syntax into your files. GitHub
- llm-wiki-agent and claude-obsidian, two implementations of Karpathy's LLM wiki. llm-wiki-agent · claude-obsidian
- qmd, local search over markdown files. GitHub
- agentcairn and the OpenClaw memory model, two more memory designs I compared against. agentcairn · OpenClaw
- Microsoft Fabric IQ, Ontology (preview). The enterprise approach: business entities, their relationships and rules, bound to data that stays where it lives. It covers a gap in my system, which has no model for entities such as people or accounts. What is ontology?
- Nous Research, Hermes Agent. Memory lives in two small markdown files, one about the world and one about the user, with a size cap that pushes the agent to consolidate. The agent reviews the conversation itself and decides what to save, and turns solved problems into skills. It is the opposite choice to my propose / decide split. Docs
The system I am using
The memory is a set of domains. Shared rules sit in a root AGENTS.md, and each domain has its own AGENTS.md that adds its rules and stance. Each domain keeps its record (corpus and sessions) as OKF-style markdown, and a central wiki in Karpathy's style summarizes it: one page about me, and one per domain.
But Karpathy's wiki and OKF are both about accumulating knowledge. A life is mostly about judgments, and neither has a place for them. Everything below exists to protect that decision layer.
1. Every record says who wrote it and how settled it is
Each document records who wrote it (me, the agent, or both) and how settled it is (raw, proposed, reflected, decided, superseded). One rule has no exceptions: an agent may propose, but only I can mark something as decided. Both fields sit in each file's header, so a script can check the rule.
2. Changing your mind is supersession, not deletion
A new decision never overwrites the old one. Old and new documents point to each other, down to a single section, and each carries the dates it was valid. The agent can then tell me what changed, when and why, and confront me with that drift. My first version only pointed one way and went unused for a month, so the pointers now go both ways.
3. The wiki is read first, and it is always regenerable
The wiki holds a page about me and one current-view page per domain. Every session reads these before the record, so reading cost stays flat as history grows. Nothing durable may live only in the wiki: if a wiki page surfaces an insight, it goes back into the record as a proposal.
4. The close ritual is what makes it compound
Writing the session down is easy. Updating the current view is the step that gets skipped, because it comes last, when the context is longest. So "close the session" is a skill with a fixed procedure:
- Depth (Note / Standard / Full) is chosen by the agent according to what changed.
- Mode (silent / interactive) is chosen by me alone. Silent is the default: a close never ends by asking me questions. It records open items instead. Only when I ask for a "full closure" does it go through blocking issues with me, one question at a time.
- Before writing anything, the agent lists every important point from the conversation, then checks that each one landed somewhere in the record.
5. A lint that can only get cleaner
Karpathy's "lint" became two checks. A script verifies that every wiki line cites a document that exists, is still current, and isn't an agent proposal I never adopted. Then one agent per domain reviews the wiki page against the record. Each finding gets an ID, and every close must mark each open finding as carried, changed or resolved. A new serious finding blocks the close, so the number of known problems can only go down.
6. Each domain has its own stance
Each life domain has its own AGENTS.md that sets the agent's personality. Lifecrafting is confrontational: no cheerleading, it surfaces goals I've carried for years without acting on them. Finance has a calm steward mode and a confrontational analyst mode. The house purchase acts as a transaction operator. The agent must take a position, cite the primary source, and give a confidence level. Health is the one exception, for safety.
Part 2 — One decision, followed end to end
Here is one change of mind traced through the system. It comes from the finance domain, where my targets follow the method I describe in The Secret of Resilient Wealth: money split into buckets by goal and horizon, each with a loss tolerance, a target allocation and rebalancing rules. The numbers are simplified.

July: a first target
In a first session I talked my targets through with the agent and settled them. The agent recorded the result in one file. The decision is mine, so the file is marked as mine and decided, even though the agent typed it:
---
type: decision
provenance: owner
status: decided
title: Bucket targets, July 2026
valid_from: 2026-07-01
---
## Long-term bucket {#equity-target}
60% equities, 40% bonds and cash. Horizon 20 years.
## Rebalancing
Twice a year, or when a class drifts more than 5 points.
The finance wiki page says the same thing in one line and cites this file.
October: the agent proposes, I decide
In October I opened a finance session in analyst mode. The agent read the finance wiki page first, a few lines instead of three months of sessions. Its argument: with a 20-year horizon and a 40% loss tolerance, 60/40 was too cautious. It proposed 75/25.
That proposal is recorded as the agent's, with status proposed. Repeating it in later sessions doesn't turn it into my target. If the agent had written 75/25 into the wiki as the current target, the lint would have flagged a wiki claim resting on an agent proposal.
I agreed with the direction but not the size, and settled on 70/30. The new file records who contributed what:
---
type: decision
provenance: mixed
provenance_note: "Agent proposed 75/25; owner chose 70/30"
status: decided
title: Bucket targets, October 2026
valid_from: 2026-10-15
supersedes:
- domains/finance/corpus/reference/targets-2026-07.md#equity-target
---
The July file is neither edited nor deleted. It gets a pointer to its replacement, for that one section only:
superseded_by:
- section: "#equity-target"
by: domains/finance/corpus/reference/targets-2026-10.md
Its rebalancing rule still applies, so the July file stays decided.
Closing the session
A new target is a major change, so the agent does its most thorough close, without stopping to ask me questions. It first lists what I said: the horizon, the tolerance, my choice of 70/30, the rejected 75/25 and my reason, and a note to revisit in a year. Then it writes the session file and checks that each of those points landed in it. Last, it updates the current views:
wiki/finance.md: "Long-term bucket: 70/30 since October 2026 (was 60/40)", citing the October file.wiki/core/olivier.md, drift trail: "Risk appetite up one step in October 2026."log.md: one line with the date, the depth, the session path and the lint result.
The lint then checks that the new citation resolves and that no wiki line still points at the superseded section.
Six months later
When I ask "why am I at 70/30?", the agent reads one wiki line, follows its citation to the October decision, and from there to the session and to the July target. It can tell me what I decided and when, what it had proposed, and why I went for less. Nothing was overwritten, so the change and its reasons are still there.
Part 3 — Build your own
Paste the prompt below into Claude Code, Codex or Gemini CLI, in an empty folder. It describes the same system in a shorter form; Part 1 explains why each rule is there.
Build me a personal "life memory" system in this empty folder, using plain markdown files and git only: no database, no external service, no SDK. Ask me for my first name and my first two life domains (for example finance and health), then create everything. Never invent personal facts; leave placeholders.
Layout
- AGENTS.md at the root holds the rules below. CLAUDE.md and GEMINI.md are symlinks to it.
- domains/<domain>/ holds an AGENTS.md that sets your stance in that domain, corpus/ for reference material, and sessions/YYYY-MM-DD-<topic>.md for session records. This is the Data layer: append-only.
- wiki/ holds wiki/core/<owner>.md (current stance, values, preferences, open tensions, drift trail) and one wiki/<domain>.md current view per domain. You write it, and it must always be possible to regenerate it from Data.
- log.md gets one line per closed session. docs/adr/ holds numbered records of changes to these rules.
Every Data file starts with YAML frontmatter: type, title, tags, timestamp, provenance (owner | agent | mixed, with a provenance_note when mixed), status (raw | proposed | reflected | decided | superseded), valid_from, valid_until, and supersedes / superseded_by, which may point to a single #section.
Rules
1. Read wiki/core and the domain's wiki page before any corpus file. Read Data only for detail or provenance.
2. You may propose; only I mark something decided. A file with agent provenance can never be decided.
3. Never overwrite a decision. Write a new file with supersedes:, add superseded_by: to the old one (section-level if only part changed), and set validity dates.
4. Nothing durable lives only in the wiki. Every wiki claim cites a Data file.
5. Take a position, cite the primary source, and give a confidence level. "Consult a professional" is not an answer, except on health.
6. Never send a message or make a git commit without my explicit approval.
Close-session skill (shared/skills/close-session/SKILL.md), run at the end of every session:
- Pick a depth: Note (nothing decided), Standard (new facts from me) or Full (a new target or structural decision). Close silently, without ending on questions, unless I ask for a full closure.
- List every point I made, write the session file, and check that each point landed in it.
- Add supersession pointers in both directions, update the wiki pages, add a line to log.md, and run the lint.
Lint (shared/tools/corpus-lint.py, no model): wiki citations resolve and point at nothing superseded; no wiki claim rests on an agent proposal; frontmatter values are valid; both ends of every supersession pointer exist. Give findings stable IDs in log.md. Each close marks every open finding as carried, changed or resolved, and a new serious finding blocks a clean close.
Finish with a short first session in one domain, and close it, to show the loop works end to end.
To check the result, try three things. Ask the agent to mark one of its own suggestions as decided: it should refuse. Change a decision: both versions should remain, linked both ways. Delete the wiki folder and ask the agent to rebuild it: nothing should be lost.
Leave a private comment
Have a question or feedback? Send me a private message directly. It won't be published.