A Claude Code plugin that gives each repository a durable memory in .brain/, so a fresh session starts out knowing what earlier sessions decided, learned and deferred.
Claude Code sessions start blank. What one session learned about a repo (why a design was chosen, which approach failed, what was put off) is lost unless someone writes it down where the next session will look. brain keeps that knowledge in plain Markdown under .brain/, committed with the code: glossary, journal, backlog, capabilities, decisions, principles, rubrics, evals and superpowers plans. At session start it injects a short digest of it. Once a week it reads your recent sessions in that repo, drafts additions from the corrections you made, and flags entries that contradict each other. You review every proposal before anything is written.
A session in this repo starts with a digest like this, trimmed:
Principles (.brain/principles.md):
- Test Behavior (Not Implementation): call the code as its user does and check what they would see
- Boundary Discipline: check data where it enters, trust it inside
Journal 2026-11-28:
- Plain rg skips .brain unless --hidden
- Distill now flags obsolete decisions
Recent decisions:
- 2026-11-28: Delete replaced decisions instead of marking them superseded
- 2026-11-28: Journal on a Stop-hook nudge per batch of new commits, not at session end
- Claude Code with plugin support.
python33.12 or newer onPATH. The plugin uses only the standard library.git, for the journal nudge.- The
claudeCLI onPATH, for the weekly distill run.
In a Claude Code session:
/plugin marketplace add MichaelD-42/dotbrain
/plugin install brain@dotbrain
From a shell:
claude plugin marketplace add MichaelD-42/dotbrain
claude plugin install brain@dotbrain # --scope user|project|local
claude plugin marketplace update dotbrain # later: fetch new versions
claude plugin update brain@dotbrain --scope user # ...and install themChanges load on the next restart.
In a repository, ask Claude to set up .brain/ (the brain skill runs brain.py init). It creates:
| Path | Holds |
|---|---|
glossary.md |
project terms a newcomer would misread, ## Term each |
backlog.md |
deferred work as - [ ] lines, deleted once done |
capabilities.md |
what the project can do, a dated line per shipped capability, newest first |
principles.md |
the repo's engineering standard, twelve rules adapted from Uncle Bob's ub-mode, headings shown in every digest; edit it to fit the repo |
decisions.md |
choices that would otherwise be relitigated, a heading and at most ~80 words: why and what lost; a replaced decision is deleted, git keeps it |
journal/YYYY-MM-DD.md |
what happened, what was learned, what's next |
plans/, specs/ |
superpowers plans and specs, instead of docs/superpowers/ |
rubrics/ |
the project's quality bar per kind of output, one checkable criterion per line |
evals/ |
rerunnable checks of output quality or agent behaviour, each with a README.md |
scripts/ |
helpers worth keeping for the repo |
Commit it with the code. Reading needs nothing special: the digest points sessions at .brain/, and Claude Code's Grep tool searches it, though plain rg needs --hidden. The skill tells Claude when to write each file and in what format. It also tells Claude to check work against matching rubrics and rerun covering evals before calling it done.
When the digest lists a pending proposals file, go through it with Claude: accept, edit or drop each proposal, then delete the file. Proposals of kind user-memory are about how you work in general, so they go to Claude's user memory, not .brain/.
brain's SessionStart hook runs brain.py context. It is silent in repos without .brain/. Otherwise it prints a guide and a digest capped to stay small, about 1,100 tokens in this repo. The rest of the brain is one search away.
The same hook checks .brain/.distill-stamp. If the stamp is missing or a week old, the hook updates it and starts distill.py in the background. Distill reads ~/.claude/projects/*/*.jsonl and keeps only your own prompts made inside this repo, deduplicated across forked sessions. It pairs each prompt with the end of the reply it answered and asks a tool-less claude -p which ones were corrections, preferences or quality bars worth keeping. The answers go to .brain/proposals/<date>.md, and the next session's digest lists that file. Only repos you open get distilled, and each run covers everything since the previous stamp. The stamp, log, status and proposals are machine-local and gitignored. A failed run shows up in the digest.
Distill also checks the brain itself: decisions that contradict each other, run past the length limit or no longer apply, open backlog items that the decisions, journal or capabilities show are done or obsolete, a term defined two ways, a rubric or principle that contradicts a decision. Each problem becomes a conflict proposal with the exact edit that fixes it. This is the only enforcement there is; git history keeps whatever an edit removes.
A Stop hook keeps the journal current in long sessions and loops, which may never end or get compacted before they do. At the end of a turn it compares the newest commit outside .brain/journal/ with the journal's last commit, the newest entry's file time and its own stamp. If the commit is newer, it continues the turn once and asks Claude to add an entry if the work taught anything a later session needs. Turns without new commits pass straight through, so it costs one git log per turn and never asks twice about the same commits.
These come from this repo's own evals in .brain/evals/, on sonnet with one or two runs per cell, so treat them as directional.
- Retrieval: 15 questions in fresh sessions. On the 10 that only
.brain/can answer, sessions without.brain/answered 0 from a record and sessions with it answered 10, with or without the digest. The digest only cut tool calls, from 1.8 to 1.2 per question. - Proactive: tasks that contradict a recorded decision. Sessions with the digest flagged the conflict in 12 of 12 runs, sessions with only
.brain/in 11 of 12, with no false alarms on 4 control runs. Every task here names.brain/or its scripts, so sessions open the brain anyway; a repo whose tasks don't is the real test of the digest. - Trigger: ordinary tasks that yield something worth keeping. With the plugin, sessions wrote the expected journal, glossary, decision and backlog entries in 8 of 8 runs and nothing in the controls; without it, 4 of 8. Of the plugin's writes, 9 came unprompted and 2 after the journal nudge.
- Distill: planted corrections and conflicts in short transcripts. It found 12 of 12 corrections and 14 of 14 conflicts, with no false proposals.
Early. The .brain/ format still changes between minor versions; capabilities.md lists what has shipped, newest first.
Bug reports and pull requests are welcome; open an issue first for anything larger than a fix. To work on the plugin:
uv run pytest # the plugin's tests and the evals' own tests
claude --plugin-dir plugins/brain # a session running your working copyAn installed plugin is a copy in ~/.claude/plugins/cache/, so edits here reach a session only through --plugin-dir or a marketplace update. The evals start nested claude sessions and need your credentials, so run them outside Claude Code's sandbox. Each eval's README has its command and cost.
For agents working on this repo:
- Before changing anything: read the digest, then search
.brain/before re-deciding anything.decisions.mdrecords why the layout is what it is. - Tests: a new eval's tests go next to it and into
testpathsinpyproject.toml. - Evals: an eval that tests Claude must stage a copy of the repo without
.brain/evals/, asstage()in.brain/evals/retrieval/retrieval.pydoes, so the answer keys never reach the session under test.
The seeded principles.md is adapted from Robert C. Martin's ub-mode, under its MIT license, whose notice the file carries. plans/ and specs/ hold the output of the superpowers plugin.
MIT, see LICENSE.