← All work

cli-memoria

A shared memory for all my AI agents: ~300 Markdown notes in git, driven through a CLI with write rules enforced in code.

Role
Solo project
When
Oct 2026 – present
Stack
TypeScript · Node.js · CLI · Git · SQLite FTS5 · MCP · NixOS · Vitest
Links
Diagram: Badulaque and the local shell use the memoria CLI (with an optional MCP server in the same repo); writes pass through code-enforced rules into Markdown notes in git, with a SQLite FTS5 index rebuilt from git

Every AI client keeps its own memory, and none knows what the others learned. cli-memoria centralises it on my own server: around 300 Markdown notes in git that all my agents query and update through the memoria CLI (via Badulaque or locally). Open source (Apache-2.0), powering my self-hosted assistant.

Three premises that shaped the architecture

1. Keywords over embeddingsSQLite FTS5
Local embeddings fit easily (1.8 s / 0.2 ms) → dropped on evidence

When an agent actively searches, lexical retrieval beats vectors and hybrid fusion often hurts queries. The CLI tries exact phrases then keywords, returns summaries and change dates, and navigates long notes by section.

2. Git underneath, hidden from agentsAuditable history
Overwriting erases the past · rewriting flattens temporal nuance

Agents never touch git, yet every write becomes a commit with author and reason, prevents concurrent overwrites and provides automatic modification dates.

3. Rules in code, not in prompts0 / 926 false blocks
389 real writes → 9 genuine pollution writes stopped · 142 tests

Rejects only newly introduced issues (invalid types, missing metadata, altering my verbatim quotes or undated present-tense mentions of retired tools) with a one-line fix hint.

How a write flows

Agent (CLI)Reads locally and sends writes without knowing git.
Server + rules
  • single writer queue
  • blocks new violations
  • protects verbatim quotes
Git + FTS5Atomic commit and refreshed index.

Under the hood

  • Right-sized notes: splitting overgrown notes (from up to 59,551 chars down below 11,000) lifted accuracy from 28/30 to 30/30 on real-data benchmarks.
  • Pure Markdown, no LFS or OCR: binary documents live separately on the server and notes cite them by a stable ID that survives renames; when a scan needs reading, the agent inspects it on demand.
  • CLI first, optional MCP: I use it day-to-day through the CLI (reading from a local checkout and routing writes directly to the server for concurrency and rules); the same repo also serves the stateless MCP endpoint (with per-agent static tokens) for clients without a shell.
  • Stack: TypeScript on Node.js 24, built-in node:sqlite (FTS5), MCP SDK, NixOS module and unit, real-git, HTTP/MCP, end-to-end CLI and NixOS VM tests.

Full benchmarks — including discarded ideas like a tree index and local embeddings — plus supporting papers are in this blog post.