Most of us work on more than one project. A day job, a product or two of our own, maybe a client on the side. Claude Code is very good inside one of them and blind to all the others: a session knows the folder it starts in, its CLAUDE.md and its code, and nothing else.
So the same fix gets written twice. A retry guard that took a day to get right in one repo is rebuilt from scratch in the next one, a little worse. Good patterns stay in the project where they were born. Out of repo, out of mind.
This is the setup I use to fix that, now a small open source repo: shared-brain.
The hypothesisLink to this section
If every session gets one small map of all my projects, a session in one project will find and reuse what another project already solved. And it has to do that without leaking: notes from a day job must never show up in a session working on my own products, and the other way round.
A map that loads everywhereLink to this section
The map is one Markdown file, imported from ~/.claude/CLAUDE.md, so every session reads it. It stays under 100 lines. Most of it is a catalog: every product, what it does, and the parts worth copying, down to the file and its test.
| Product | What it does | Worth copying |
|---|---|---|
| Invoicer | Billing for small shops | double charge guard, src/claims.js with its race tests |
| Scheduler | Recurring tasks | time zone safe recurrence engine, src/recur.js |
| Reports | PDF exports | owner only results, src/jobs/owner.js |
The file path is the point. A summary of a solution invites the agent to write its own version of it. A path sends it to code that already runs in production, next to a test that already caught the bugs.
Group brains that load only where they belongLink to this section
Some context should not travel. A day job has its own rules, people and systems. My own company has release rules and the status of every product. Each group gets one file, and a SessionStart hook loads it only inside that group's folders. A small table maps folder prefixes to groups, and the longest prefix wins.
The map that loads everywhere never holds a group's details. That one rule is what makes sharing safe at all.
Try it: where does the session start?
One person, four folders: a day job, two products of their own and a blog. Pick the folder a Claude Code session starts in, then switch the shared brain on and off.
- This folderCLAUDE.md and the code in ~/projects/scheduler
- The mapnot loaded
- Group brainnot loaded
- Kept outnothing to keep out: the session does not know the other folders exist
The session knows ~/projects/scheduler and nothing else. Invoicer already solved double runs, but that is out of repo, out of mind: the fix gets written a second time.
What this shows: the map loads everywhere and holds no group's details. A group brain loads only inside its own folders. So a session in Scheduler can copy Invoicer's fix, and still never sees the notes from the day job.
Writing to the brainLink to this section
A brain that nobody updates rots, and a brain that updates itself fills up with noise. So every write goes through one skill, /brain. It shows what it will write in five lines, waits for "ok", writes to the right file, checks the size limits and commits. Lessons that help more than one project go into a lessons file, together with where the fix lives. Unsolved ones stay marked open.
Hard limits keep it readable: 100 lines for the map, 9,000 characters for a group brain, 15,000 for the lessons. The group limit is not arbitrary. Claude Code cuts long hook output, and a brain cut in half is worse than a short one.
What happenedLink to this section
In daily use, the change is where a session starts looking. Before writing something new, it checks the catalog, and more than once the answer was already in another repo, with its tests. The lessons file does the same for mistakes: a pain that cost a day in one project is a line the next project reads before it starts.
For the public version I wanted the same confidence without my own data, so I tested it the way I would test anything that edits someone's configuration.
- 41 tests, each one proven to fail. I broke the code on purpose 20 times: removed the path guard, loosened the folder match, skipped the backup, replaced the settings instead of merging them. Two broken versions passed at first. Both times the test fixture hid the bug, so I fixed the tests, not the code.
- One bug only macOS could show. A check for em dashes passed on my Mac while matching nothing, because BSD grep reads
\|differently from GNU grep. CI now runs on Linux and macOS. - A real session, from an empty brain. I typed
/brainand described two products. The skill previewed its plan, waited, and corrected me: the file I had called retry logic was a guard against double charges. After "ok" it wrote four files and committed them. Then, from the other product's folder, which that session had never opened, the hook loaded the new group.
Try itLink to this section
git clone https://github.com/nactusem/shared-brain.gitcd shared-brain./install.shThe installer shows the two changes Claude Code needs and asks first, backs up both files, and never overwrites an existing brain. ./uninstall.sh takes it out again and leaves your brain where it is. Then start a session in any project and fill the map in with /brain.
Did this help?
Send Pip to my mailbox. Each press delivers one thank-you packet; the box holds ten.
You have sent 0 of 10 packets.