How the second brain works
A plain-Markdown wiki that an agent maintains, a graph that connects facts across pages, and a thin harness where the model writes the words and code checks the facts.
I built an employer knowledge base from policies, help documentation and Q&A. An agent maintains a linked Markdown wiki. The answer system retrieves relevant sections and relationships, then checks answers against their cited sources.
Built the LLM Wiki way
It runs locally and follows Andrej Karpathy's "LLM Wiki" pattern: plain Markdown in ordinary folders, raw sources in one and the agent-written wiki in the other. Obsidian is the reader, for browsing pages and following links. The knowledge graph makes relationships between source documents explicit.
Why a graph: chunks lose the chain
A question about which procedure applies to a request may need a policy, an exception and a separate procedure. A knowledge graph connects those facts across documents.
The graph fills that gap. Each page declares typed links in its frontmatter, and every link carries an evidence quote that must appear word for word on the page it cites. graph.py walks those links and shows the evidence for each hop. For questions that span several documents, the system retrieves the linked evidence too.
The diagram shows the design with representative sources.
Policies, help documentation and Q&A.
An agent turns source material into topic pages.
Markdown pages record facts, sources and review dates.
Evidence-backed links connect related facts across pages.
Code selects relevant sections and graph links. The model drafts a response.
Code checks citations and quotations. Unverified answers are withheld.
A person can inspect the evidence and correct the source page.
Automated checks track broken links, stale material and conflicting claims.
Figure 1 Second Brain architecture: sources, knowledge base, answer path, users and checks.
Five components
- Raw and wiki. Source files are read-only. The agent writes one reconciled page per topic, so retrieval returns settled facts, not fragments.
- Knowledge graph. Typed links between pages, each carrying a quote that must appear word for word on the page. It answers multi-hop questions that chunked retrieval misses.
- Answer harness. Retrieve with code, compose with one model call, verify with code. A failed check withholds the answer and returns the sources.
- Trust and freshness. Every page has a trust tier (human-reviewed, machine-confirmed, unverified) and a stale-after date. Key counts come from a sealed query, never a typed value.
- Distribution. An MCP server with two tools, shipped as a checksummed package built daily. The build stops on a failed lint, a failed probe, or a scan hit for credentials, prices or personal data.
Five lessons from shipping it
Each one comes from something that broke, or nearly broke, during the build.
- Start with the verifier, not the prompt. A better prompt still produces confident, wrong answers. A code check that every quote appears in the cited page, and that every link and page really exists, catches them. If the check fails, withhold the answer and hand back the sources.
- Partial beats a guess. Most real questions have several parts. Answer the parts the sources prove and leave the rest blank. An unsupported "probably" is worse than no answer, because people repeat it.
- Chunking cuts facts apart. Put the chain in a graph. A question may depend on facts kept on several pages. Evidence-backed links connect them.
- Never type a number you can compute. A count copied into a page goes stale silently. Store the query, seal it with a hash, and let lint fail if someone types the value or changes the query without review.
- Test what you ship, in the place it runs. The answer server worked on my machine and crashed at start in the installed package, because its isolated environment lacked a library I had installed globally. Release cleanup sorted versions as text and would have deleted the wrong builds. Each fix was small. Each was found only by running the real package in a clean environment.
Python · SQLite FTS5 + sqlite-vec · MCP · Claude Code (claude -p) · Obsidian · PowerShell and bash installers · Windows and Mac