{"slug": "markdown-is-perfect-for-small-databases-here-s-how", "title": "Markdown is perfect for (small) databases. Here's how ...", "summary": "A developer outlined the \"Markdown Database Pattern,\" in which a folder of markdown files with YAML frontmatter serves as a lightweight database: each file is a record, each frontmatter field a column, and the folder a table. The approach requires no server or schema, can be queried with a short Python list comprehension or grep, and is editable by AI coding agents like Claude Code and Cursor, which can read the files and add new records in plain English. The developer recommends it for hundreds to a few thousand records, pointing to Postgres for millions of rows or concurrent writes.", "body_md": "Here's a database: five markdown files about Harry Potter characters, sitting in a folder. No server, no schema. Obsidian shows it as a table I can sort and edit, ten lines of Python query it, and when I ask Claude Code in plain English to add Ron, it does.\n\nThe folder:\n\n```\ncharacters/\n  harry-potter.md\n  hermione.md\n  malfoy.md\n  dumbledore.md\n  luna.md\n```\n\nAnd each file looks like this:\n\n```\n---\nname: Harry Potter\nhouse: Gryffindor\nstatus: Alive\ncreature: Hedwig (Owl)\n---\n\n# Harry Potter\n\nThe boy who lived. Notes go here, as long as you like.\n```\n\nCharacters without a pet get `creature: -`.\n\nThe bit between the `---` lines is frontmatter: plain YAML at the top of a markdown file. Almost every markdown tool understands it already.\n\nThat's it. You've made a database:\n\n```\nmarkdown file      →  record\nfrontmatter field  →  column\nfolder             →  table\n```\n\nNo install, no schema. Want a new column? Add a field to a file.\n\nOpen the folder in Obsidian, add a [Base](https://help.obsidian.md/bases), and there it is:\n\nSort by house, filter to the living, edit a cell and it writes straight back to the file. This is the thing Notion is good at, structured fields *plus* free text in one place. Except here every record is a text file on your own disk, in git if you like, editable in any editor, and still there if Obsidian disappears tomorrow.\n\nYou don't need a database engine either. Frontmatter is so simple that a query is a list comprehension:\n\n``` python\nimport pathlib\n\ndef records(folder):\n    for f in sorted(pathlib.Path(folder).glob(\"*.md\")):\n        head = f.read_text().split(\"---\")[1]\n        yield dict(line.split(\": \", 1) for line in head.strip().splitlines())\n\nalive_with_pets = [r for r in records(\"characters\")\n                   if r[\"status\"] == \"Alive\" and r[\"creature\"] != \"-\"]\n\nfor r in alive_with_pets:\n    print(f'{r[\"name\"]:<18} {r[\"house\"]:<11} {r[\"creature\"]}')\nHarry Potter       Gryffindor  Hedwig (Owl)\nHermione Granger   Gryffindor  Crookshanks (Cat)\n```\n\nNo libraries. (That little parser only handles simple `key: value` lines and assumes every file has every field; for real YAML use a YAML library. You get the idea.) And for quick questions plain `grep` works fine:\n\n``` bash\n$ grep -l \"house: Gryffindor\" characters/*.md\ncharacters/dumbledore.md\ncharacters/harry-potter.md\ncharacters/hermione.md\n```\n\nThis is why I think the pattern has gone from \"neat trick\" to \"obviously the right way\" in the last year.\n\nAI agents are brilliant at plain files. Point Claude Code or Cursor at the folder and the query language is English:\n\nWhich characters are dead? Add Ron Weasley with the same fields.\n\nIt reads the files, tells you Dumbledore, and writes `characters/ron.md`:\n\n```\n---\nname: Ron Weasley\nhouse: Gryffindor\nstatus: Alive\ncreature: Scabbers (Rat)\n---\n\n# Ron Weasley\n\nHarry's best friend. Sixth of seven Weasley children.\n```\n\nRun the Python again and Ron shows up. You and the agent are working on the same files, and git shows you exactly what it changed. With Notion you'd be wiring up an API integration before you got this far.\n\nHundreds of records, a few thousand, great. Millions of rows, lots of joins, many people writing at once: use Postgres.\n\nBut a surprising amount of life fits in a few thousand records: books you've read, recipes, people you've met, projects, a team's decisions, a product catalog, a blog.\n\nI call this the Markdown Database Pattern. The full write-up, plus a step-by-step guide to building one from an empty folder, is on The Way of Markdown: [wayofmarkdown.com/markdown-database](https://wayofmarkdown.com/markdown-database)\n\nWhat have you got in markdown that's secretly a database? 😎", "url": "https://wpnews.pro/news/markdown-is-perfect-for-small-databases-here-s-how", "canonical_source": "https://dev.to/flowershow/markdown-is-perfect-for-small-databases-heres-how--1hgk", "published_at": "2026-11-27 20:31:28+00:00", "updated_at": "2026-11-27 20:44:43.453297+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Claude Code", "Cursor", "Obsidian", "Notion", "Postgres", "The Way of Markdown"], "also_reported_by": [], "takeaway": "Storing records as markdown files with YAML frontmatter lets a ten-line Python list comprehension or grep query them and lets coding agents like Claude Code add or edit records in plain English, with git tracking every change.", "recommendation": {"advice": "Store small datasets as markdown files with YAML frontmatter so coding agents can read and edit records directly, and keep the folder in git to review each change.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/markdown-is-perfect-for-small-databases-here-s-how", "markdown": "https://wpnews.pro/news/markdown-is-perfect-for-small-databases-here-s-how.md", "text": "https://wpnews.pro/news/markdown-is-perfect-for-small-databases-here-s-how.txt", "jsonld": "https://wpnews.pro/news/markdown-is-perfect-for-small-databases-here-s-how.jsonld"}}