Markdown database: notes as memory for humans and AI agents
Your notes folder is already a database — you just haven’t been querying it like one. Here’s what falls out when you treat it as a first-class store: primary keys, a schema, two kinds of relationships, and a CRUD surface, all in plain Markdown.
There’s a tendency right now to look at agent memory and ask, “What do agents need?” It’s the wrong question. Agents are trained on how people work — they need what we want. Plain text. Files. The filesystem. Git. Search commands. Familiar systems wherever possible. Build for what a human enjoys using directly, and the agent will use it efficiently.
This post is one application of that principle: turning a folder of Markdown notes into a queryable database, without introducing anything new on either side of the keyboard. If you want the hands-on version first, the Markdown database guide builds one step by step.
Most stacks split your knowledge in two. A database holds the structured stuff — tasks, statuses, dates, relationships. A pile of files holds the prose — notes, drafts, design docs. You write integration code to glue them together, and you spend the rest of the project apologizing when they drift apart.
There is a different shape available. Keep it all in one place. The Markdown files are the database. The schema is the YAML block at the top of each file. The relationships are Markdown links — and there are two kinds, which the engine distinguishes. The hierarchy is inclusion links — a Markdown link on its own line, which makes one document a structural child of another. The query language is a CLI; the join is what its operators do when they walk those relationships. There is no separate store, no export step, no sync drift. git diff shows you what your queries did.
The implementation I’ll use for the worked examples is IWE, a Rust binary that turns a directory of .md files into a queryable graph. But the interesting thing here is the surface, not the tool — what falls out when you treat a notes folder as a first-class data store. This post is a tour of that surface, mapped to the database primitives you already know.
1. Primary keys are file paths
Every document has a Key — its path relative to the workspace root, with the .md dropped. tasks/alpha.md has key tasks/alpha. The filesystem enforces uniqueness for free, and the key is what every other operator points at.
iwe find -k tasks/alpha
iwe find -k tasks/alpha -k tasks/beta
Repeat -k to ask for a set.
Renaming a key is a corpus-wide refactor: every link to the old key gets rewritten. You don’t propagate the change by hand; the editor does.
2. Folders are convenience, not structure
Folders organize file paths on disk. The query engine doesn’t care about folder boundaries — it sees keys (strings) and the relationships between documents. A note can live in any folder and still belong to a project’s tree, because what makes it part of that tree is an inclusion link, not where it sits in the filesystem. We’ll see those operators in section 5.
In short: keys give you identity, frontmatter gives you fields, the graph gives you structure. Folders are just where the bytes happen to live and a way to group them.
3. Documents are schemaless
Frontmatter — the YAML block fenced by --- at the top of each Markdown file — is where structured fields live. It’s untyped and schemaless: each document carries whatever keys make sense for it. The filter operators are the ones you already know:
iwe find --filter 'status: draft, priority: {$gte: 8}'
iwe find --filter 'author.email: {$exists: true}'
iwe find --filter '$or: [{status: draft}, {status: review}]'
The shipped operator set covers $eq, $ne, $in, $nin, $gt/$gte/$lt/$lte, $exists, plus $and / $or / $not / $nor for composition. Nested fields use dot notation (author.email) or nested mappings — both forms are equivalent. Multiple constraints in one filter document AND together by default; spell out $or when you want a union.
For arrays, a bare scalar tests membership: tags: rust matches when rust is in the tags array. Cross-type comparisons are always false — priority: "3" does not match an integer field. There’s no implicit coercion to bite you later.
If you’ve written queries against MongoDB or Elasticsearch, this is the same shape. The difference is what those queries hit: a directory of plain text files, not a server.
4. The body is not opaque
The Markdown body — everything after the frontmatter block — is the unstructured payload. Most queries don’t need to look inside it; you put the queryable bits in frontmatter and leave the prose alone. But when you do need to reach in, the body is parsed into an AST (headers, paragraphs, lists, code blocks, references, quotes), and a small surface of structural predicates becomes available. The database is opaque to the body when you want it opaque, and structured when you want it structured. You don’t have to choose up front.
A fast LLM is very good at promoting fields out of prose into frontmatter. Run it across a corpus and it will pick out due dates, owners, statuses, tags — turn the structure already implicit in your writing into explicit, queryable keys. That’s effectively a manual indexing pass, except the indexer reads English. The result is a database whose schema grows alongside the notes, on demand. (Structured questions need a query layer walks through that promotion step in detail.)
5. Two kinds of relationships — this is a graph database
This is where the model parts company with most stores. It’s a graph database, and the graph has two distinct edge types:
- Reference links are inline links in body text.
See [Auth](auth) for the login flow.They mean “see also.” Many-to-many, no structural commitment. - Inclusion links are a Markdown link on its own line, not inside a sentence or a list. They mean containment: the linked document is logically a child of this one.
The same syntax — [label](key) — does both jobs; the difference is whether the link is alone on a line. That’s what lets a plain Markdown file declare structure without leaving the format.
Each relationship gets its own pair of traversal operators, walking its own kind of edge:
iwe find --references people/alice # docs that mention alice inline
iwe find --referenced-by people/alice # docs alice mentions inline
iwe find --includes tasks/alpha # docs alpha pulls in via inclusion
iwe find --included-by tasks/alpha # docs that sit under alpha's tree
You can stack flags to compose a multi-edge query:
iwe find --included-by tasks/alpha:0 \
--references people/alice \
--filter 'status: draft'
Read that as: “drafts somewhere under the tasks/alpha subtree that also link to people/alice inline.” Three relationships, three flags, no JOIN ... ON. The graph operators are the join — what the query does when it walks an existing relationship — and they’re aware of which kind they’re walking.
The depth syntax is KEY:DEPTH for inclusion (--includes, --included-by) and KEY:DISTANCE for reference walks (--references, --referenced-by). Default is 1 hop; :0 means unbounded. --max-depth N and --max-distance N set session-wide defaults if you’d rather not annotate each anchor.
6. The same predicates drive find, count, update, and delete
Reads, counts, mutations, deletes — all share one filter language. The verbs are siblings, not separate dialects:
iwe count --filter 'status: draft'
iwe update --filter 'status: draft, reviewed: true' \
--set status=published \
--set published_at=2026-05-02 \
--unset draft_notes
iwe delete --filter 'status: archived' --dry-run
update and delete require an explicit filter — passing the empty filter {} on purpose is the only way to operate on the whole corpus, which is precisely the design intent. --dry-run previews without writing. Atomicity is per-document: each file is rewritten as a unit, but there’s no cross-document transaction. If you need rollback, you have one — git.
7. Projection and shaping
The shape of the result set is yours to choose. --project f1,f2,f3 gives you inclusion-only field shaping; --sort field:-1 and --limit N round it out:
iwe find --filter 'status: draft' \
--project title,tags,modified_at \
--sort modified_at:-1 \
--limit 20
That’s “the 20 most recently modified drafts, projected to three fields.” Pipe it to jq, feed it to a script, hand it to an agent.
8. What this surface has that most databases don’t
- Files outlive the tool. Uninstall the binary tomorrow and your data is still there, readable in any text editor. There is no proprietary file format, no schema migration tool, no vendor.
- Git is the audit log.
git logtells you who changed what, when, and why.git diffshows what your lastupdateactually did. Branch your data the way you branch code. If you’re driving the database from an agent, instruct it to commit after every step — you get a per-action audit trail and a per-action revert button, both for free. - Two kinds of relationships. Containment is a different relation from reference, and the database knows it. Most stores collapse both into one foreign-key column and lose the distinction; here it shows up at the link level (a link alone on its own line vs. a link in running text) and stays queryable through separate operators.
- One store for humans and agents. A human edits a note in their editor; an agent queries it through the CLI or MCP. They share one source of truth, byte for byte. No translation layer where mental models can drift.
And it holds up at scale: we benchmarked it on 20,000 documents — under a second to load, most queries under 20 milliseconds.
Closing
A Markdown file that’s also a queryable document — with a primary key, a schema, two kinds of relationships, and a CRUD surface — is what that workload looks like when you build for it directly instead of bolting a database next to a folder of notes.
The honest answer to “what does my agent need to remember?” turns out to be the same as “what do I need to remember?” Markdown notes in a folder, with structure and links. The query language above is what it takes to operate on that shape without leaving the format. Build for what humans already do; the agent inherits it. (For the agent-memory framing of the same idea, see Five components of agent memory.)
If this resonates and you want to try the surface described here, IWE is the open-source implementation: a Rust binary, on Homebrew and crates.io, with editor integrations over LSP and an MCP server for agents. Point it at a directory of .md files and run iwe find.