zain_
ai lab · intervention
← all of the ai labSystem2026 → presentself

Second Brain: a Knowledge OS

A Git-versioned Markdown vault that runs my work and life, kept current by AI agents. The same system, made public, is the chat box on this site: ask it something and you're querying the second brain live.

role
Designed and built it end-to-end: the vault architecture, the AI grooming loop, and the retrieval that answers on this site
stack
Knowledge management · AI agents · Retrieval · Personal infrastructure
status
in progress

How I got here

I don't keep my thinking in chat windows. Threads scroll away, context evaporates, and every new session starts cold. I wanted the opposite: a place where the state of my work lives in files I own, that any AI agent can read to pick up where the last one left off.

So I built one: a single Git-versioned vault of Markdown, my "second brain." The rule that shaped everything: state lives in files, not chat. Read the files and you have the full context; no memory of the conversation required.

That's the same idea behind a field note I wrote after an AI × Design meetup: "the knowledge base is the moat, not the model." The model is swappable. The curated, structured knowledge underneath it is the durable asset. This project is me taking my own advice.

How I thought about it

A few decisions did the heavy lifting.

Files, not chat. Plaintext Markdown, versioned in Git. Every change is a commit; nothing is lost; I can grep, diff, and roll back my own thinking. It's portable and it outlives any single tool.

PARA, so things have a home. Projects (things with an end), Areas (ongoing), Resources (reference), Archive (done), plus an inbox for triage. A predictable shape means an agent, or me six months later, always knows where to look.

Provenance on every note. Each file carries a source: tag: human, ai-assisted, or ai-generated. I always know whether a note is my own words, a draft I directed, or unverified autonomous output that hasn't earned trust yet. Autonomous output stays quarantined in the inbox until a human reviews it.

photo drops here
A vault note's frontmatter: the source: and type: tags that mark whether a note is human-written, AI-assisted, or unverified AI-generated

Reality and rules, kept apart. state.md files hold what's true right now; CLAUDE.md files hold the stable decisions. Each area carries its own instructions, so an agent working there loads the right context automatically.

Bookkeeping is safe to automate; judgment isn't. An agent keeps the index, the wikilinks, and the routine state files current. But distilling raw notes into conclusions, and pushing to the remote, stay manual. A human gate sits on anything that matters.

What I actually did

Two halves, and the second one is the proof.

The vault + the grooming loop. The Markdown vault above, plus an AI bookkeeping pass that maintains its connective tissue (the index, the links, the session log) without me hand-maintaining any of it. Boring, mechanical, exactly the work you want an agent doing.

photo drops here
The vault's PARA folder tree: 00-inbox, 01-projects, 02-areas, 03-resources, 04-archive, each area holding its own CLAUDE.md and state.md

The retrieval that answers on this page. The chat box on this site is that second brain, made public. Ask it something and it doesn't just call a model. It runs a real pipeline you can watch:

  • It scans a set of curated, public-safe notes. The private vault stays private; only a hand-picked public layer feeds this chat.
  • It scores every note against your question deterministically: plain TypeScript, no embedding service, no extra API call. Keyword and title matches weigh heaviest; body matches are capped so one long note can't win on word count alone.
  • It picks the top few notes that actually matched, and shows you which files it read as source chips.
  • Then it answers from exactly those notes, and only those, streaming the reply. A provider chain (a fast model, a fallback, and a crafted offline reply) keeps it alive on free tiers, behind a rate limit so the quota survives a busy day.
photo drops here
The on-site brain chat mid-answer: the retrieval trace narrating 'scanning the vault · N notes' then 'reading identity.md · hiring-fit.md', the matched notes shown as source chips, and the grounded reply streaming in

The trace you see isn't theater. Every "scanning the vault," every "reading X.md," is a step that genuinely happened in the retrieval. And the system is built to refuse: if the notes don't cover your question, it says so and points you to email rather than invent an answer. It won't discuss compensation, employer internals, or my personal life. Those redirect, warmly.

That's the whole thesis, demonstrated in something you can poke at: curated knowledge plus honest, grounded retrieval beats a bigger model with nothing underneath it.

Where it's heading

The method proved itself on one person. The interesting question is whether it scales to a team: the same shape (files not chat, provenance, PARA, agent-run bookkeeping, retrieval that cites its sources) pointed at an org's shared knowledge instead of mine. That's the direction: an org-wide knowledge plan built on the same bones.

Same bet, bigger surface: the knowledge base is the moat, not the model.