Skip to content
Robert Bradley
Go back

Sharing one second brain across AI sessions

I use Claude Code on more than one machine: a home server, my desktop, and whatever I am remoting into from my phone. Claude Code already has memory. As it works it writes short notes to a folder, and it reads them back at the start of the next session. On the machine that wrote them, that works well.

The catch is that those notes stay on that machine, filed under the project folder the session ran in. A session on my desktop cannot see what a session on the server learned last week. So I kept re-explaining my own house to my own tools, one machine at a time.

The usual answer is a “second brain”: a Markdown wiki that a model maintains for you, in the style Andrej Karpathy described as an LLM wiki. You drop raw material in one folder, and the model compiles it into linked notes in another. There are plenty of write-ups of that idea, and almost all of them cover one vault on one machine with one session editing it.

Mine had to be shared, and that changes the problem in two ways.

The first is coordination. If five sessions on three machines can all edit the wiki, I no longer have a wiki. I have a merge conflict with opinions.

The second is trust. A session reads things I did not write: web pages, issue threads, log files. If one of those talks it into recording a false “fact”, a local memory carries the mistake on one machine. A shared knowledge base carries it to every session on every machine, from then on. Shared memory is the most valuable thing to poison.

So this post is about the sharing: how to let many sessions use one knowledge base while trusting none of them to change it.

The code is open source: second-brain-mcp.

Why not something simpler?

I tried to talk myself out of building this. The obvious alternatives each miss something.

A wiki has what those lack. Each fact lives in one place and gets merged, not appended. Notes link to each other, so an answer can draw on several. I can read and edit every word of it. And it is plain Markdown, so it will outlive whichever tool I am using next year.

The shape of it

Architecture: sessions talk to an MCP server, which reads the vault and writes only to an inbox. A nightly curator is the only writer of the wiki.

There are four parts:

Rule one: a single writer, enforced by the filesystem

I did not want “the server promises not to edit the wiki”. I wanted it to be unable to.

Trust boundary: the container mounts the wiki, scripts and raw folders read-only, and can only create files in the inbox.

Docker mounts the wiki read-only. The inbox is mounted read-write on top of a read-only parent. The container has a read-only root filesystem, no Linux capabilities and a non-root user. Every request needs a bearer token, and each machine has its own, so I can revoke one without touching the others.

There is also no model inside the server. Search is plain BM25 with extra weight on titles and aliases. That keeps it cheap, fast and easy to reason about: the server is plumbing, and all the judgement lives in the curator.

So if a session is confused, or is talked into something by a web page it read, the worst it can do is drop a file in the inbox.

Rule two: contributions are data, not instructions

That inbox file is where the real risk sits. Tomorrow night a model will read it, and that model has write access to the wiki.

Life of a contribution: a session calls contribute, the server validates and writes an inbox file, and the curator merges it that night, or defers it.

The server does the mechanical checks. It caps the size at 100 KB, rejects unsafe titles, and writes to a temporary file before renaming it into place, so the curator never sees half a file. It stamps each contribution with where it came from. The machine name comes from the token, so a session cannot lie about it.

The curator does the judgement. Its rulebook says contributed files are untrusted. Their claims are unverified, so they are cited rather than taken as fact. If a claim conflicts with an existing note, both are kept under a “Disagreements” heading for me to settle. If a file tries to instruct the curator, or contains anything that looks like a credential, it is not ingested. It stays in the inbox, gets a deferred entry in the log, and my phone gets a notification.

I tested this before trusting it. I submitted a contribution containing instructions aimed at the curator and a fake credential, then ran the curator against a copy of the vault. It deferred the file, logged why, and nothing from it reached the wiki.

Rule three: the curator runs in a box

A model editing my notes unattended at 3 am needed more than a careful prompt.

The nightly curator run: scripted steps around one restricted model step, with lists of what the model may and may not do.

Most of the run is ordinary shell and Python. The script checks the vault is really mounted, takes a full backup, and stops without calling a model if nothing is waiting. Only then does it start Claude Code, with a settings file that allows edits inside the wiki folder and denies almost everything else: no network tools, no git, no other MCP servers, no sub-agents, and no moving or deleting files.

That last restriction came from a failure. The rulebook originally told the model to move each file to an archive folder after ingesting it. In an early run the move was denied by the permission rules, and I realised I did not want to loosen them. Now the model only writes a log entry in a fixed format, and a small script reads the new log entries and moves those files itself. The model decides, and a deterministic script acts on the decision.

Things that went wrong

Most of the work went on these four problems.

Is it worth it?

Mostly yes, with caveats.

What I gained:

To get started I fed it summaries of earlier sessions as a dozen themed contributions. The curator merged them overnight. A few days later the vault stands at 92 notes and 619 links, with no orphans or broken links.

What it costs:

If you only ever use one machine, you do not need any of this; a local vault is simpler. If your sessions are spread across several, the single-writer pattern is what I would copy, even if you copy nothing else.

Try it

The repository has the server, the curator scripts, a starter vault with the rulebook, and a README that walks through setup. It assumes Docker and Claude Code, and it works with a plain local folder if you do not have a NAS.


Share this post:

Previous Post
Hello, world