a storage closet for agents

🧠 The brain

Your project folder is the desk: what you are working on right now, and what a compaction is allowed to summarise away. The brain is the storage closet behind it: durable facts, decisions and gotchas that outlive the conversation, written down once so nobody has to work them out twice.

📄 The desk

Source code, config, build output, anything the shipped product needs. Compacted freely.

🧠 The closet

What was learned, what was decided and why, what bit us. Not in the code, so nothing summarises it away.

Connecting to the brain server… if this stays, start it with ./brain/brain serve.

Start here

Browse

Visualizer →

Every entry as a card. Filter by project, type or tag. Add and edit without touching a file.

Reference

API →

Every route this server answers, with a link that runs it.

Catalogue

INDEX.md →

The whole brain as one readable page: every project, every entry, every tag with a count.

Conventions

House rules →

The rules that keep it readable, and the mistake each one exists to prevent.

The four commands that matter

./brain/brain search "build command"        # find something
./brain/brain add --scope myproject --type knowledge "Title" "Body"
./brain/brain list --scope myproject         # everything about a project
./brain/brain doctor                         # is this brain healthy?

On Windows use brain\brain.cmd instead. The launcher finds Node by itself, so it works whether or not Node is on your PATH. Every command takes --json if something else is reading the output.

Every command

CommandWhat it does
addWrite an entry. --title --body --type --tags --scope --source. --body @file reads a long body from a file, which is far easier than escaping quotes in a shell.
searchFull text across title, tags and body. Combine with --tag, --type, --scope.
listEverything, newest first. Same filters, plus --limit N.
getOne entry in full.
updateChange any field of an entry. Use this instead of writing a near-duplicate.
deleteRemove an entry.
tagsEvery tag in use, with counts. Check here before inventing one.
scopesThe project registry, with entry counts.
indexRebuild INDEX.md and index.json. --dry to see what it would write.
doctorCheck the corpus. Exits non-zero when something is actually wrong.
serveStart the HTTP API and this site. --port to move it.
infoWhere this brain lives, its name and its port.

What lives where

PathWhat it is
entries/One Markdown file per entry, with a frontmatter block. This is the source of truth. Hand-editable.
lib/vocab.jsThe project registry. Add a project here and run index. This is the only place to register one.
lib/store.jsReads and writes entries. Atomic writes, so two agents never corrupt one.
lib/index.jsBuilds the catalogue.
lib/doctor.jsThe health checks.
lib/config.jsThis brain's own port and name, so several brains can run at once.
ui/This homepage, the visualizer and the export page.
tools/normalise.js tidies old entries (dry run by default) and test-normalise.js tests its rules.
templates/Entry templates. They are not entries and do not appear in search.
INDEX.md, index.jsonGenerated. Read them, never edit them; brain index rewrites both.

Types

Four, and the choice matters because it is how a reader decides whether to trust a line.

TypeMeans
knowledgeA durable fact, established by evidence.
memoryWhat happened: a session outcome, current state, an open thread.
decisionA choice, with the reason. The reason is the part nobody can re-derive.
noteEverything else.

When an agent should write here

Read the brain before starting work on a project, and write to it after learning something. The test is simple: if a future session would have to rediscover this, it belongs in the closet. If the product needs it at runtime, it belongs on the desk.

The house rules

The short list. Each of these exists because it was broken once, not because it reads well.

  1. Every entry has a frontmatter block. An entry without one is indexed silently, with no title and no tags, which makes it invisible to everything.
  2. A title is a name, not a sentence. Keep it under about 90 characters and put the detail in the body.
  3. Register a project before filing anything under it. Add it to lib/vocab.js and run index, or its entries render with no name or colour.
  4. global means workspace-wide. Project facts go under the project, even the internal ones.
  5. An entry carries its own scope as a tag. So --scope and --tag agree.
  6. Reuse a tag before inventing one. A tag used once is a detail, not navigation.
  7. Plain hyphens, never long dashes. No em or en dashes anywhere. It reads better and it is a house rule.
  8. Templates live in templates/. Anything in entries/ is an entry, and will show up as one.
  9. Update before you duplicate. Two entries that disagree are worse than one that is vague.
  10. Never overwrite another agent's entry. Read, merge, write. Several agents share this folder.
  11. Run doctor before you trust it. It catches what you cannot see by reading: empty titles, unregistered scopes, dangling references.
  12. Generated files are not yours to edit. INDEX.md and index.json are built by brain index; never hand-edit them or the next rebuild silently destroys your changes.
  13. Em dashes and en dashes prohibited. No U+2014, U+2013, or dash-like characters (~, ~~, - used as substitute). Use `node -e "process.stdout.write('—'.charCodeAt(0))"` to check. `normalise` will fix them, but it is easier not to type them.
  14. Keep secrets out, keep their locations in. Where a key lives, yes. The key itself, no. Entries are copied into exports, zips and other people's machines. Never commit secrets or platform tokens.
  15. Record a decision with its reason. A decision entry says what was chosen and why the alternative lost. The reason is the part nobody can re-derive. Six months later someone will ask why, and "because it seemed right" is not an answer.
  16. Total detail wipe resets the brain. `./brain/brain reindex --wipe` clears `entries/`, `index.json`, `INDEX.md`, and all generated reports, leaving only `lib/vocab.js`, `lib/config.js`, and the `entries/` folder structure. No entries, no scope registry, no tags — a clean slate for a fresh brain.

The full rules, with the reason behind each one →

Quick reference

15 rules, the essentials:

Read the full rules with incidents →

HTTP API

For other tools and webviews. CORS is open and it binds to localhost only.

RoutePurpose
GET /api/indexEverything in one object: counts, projects, tag frequencies, every entry. Add ?entries=0 for just the shape.
GET /api/scopesThe project registry, for building a picker.
GET /api/entriesList, filtered by type, tag, scope.
GET /api/entries/:idOne entry.
POST /api/entriesCreate.
PATCH /api/entries/:idUpdate.
DELETE /api/entries/:idDelete.
GET /api/searchSearch.
GET /api/tagsEvery tag with a count.