Format, read protocol and write protocol of the repo's brain (docs/brain/) - the distilled memory of rules, decisions and lessons, one idea per note, indexed and anchored to code. Use whenever a flow command investigates (read), when an implementation settles something durable (write), in /flow:learn, and when brain.py check reports a stale note.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Brain?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/eusilvio-brain)
---
name: brain
description: "Format, read protocol and write protocol of the repo's brain (docs/brain/) - the distilled memory of rules, decisions and lessons, one idea per note, indexed and anchored to code. Use whenever a flow command investigates (read), when an implementation settles something durable (write), in /flow:learn, and when brain.py check reports a stale note."
user-invocable: false
---
# The brain
Issues and PRs are **episodic** memory: what happened in one change. The
brain is **distilled** memory: what stays true across changes. An issue
records; a note teaches.
```
docs/brain/ (FLOW_BRAIN_DIR overrides; local brain: .flow/brain/)
├── INDEX.md one line per note - the only file read every time
├── domain/ business rules, glossary, invariants of the product
├── decisions/ why X and not Y - the alternative that was rejected
├── lessons/ a mistake that already cost something, and the guard
└── qa-playbook.md QA setup + test traps (owned by flow:qa)
```
Tool: `${CLAUDE_PLUGIN_ROOT}/scripts/brain.py` - `init [--local]`, `dir`,
`find <terms>`, `check [--changed [BASE]]`.
**Where it is:** always ask `brain.py dir` (`tracked|local|none<TAB>dir`),
never assume `docs/brain/`. A **local brain** (`brain.py init --local`) lives
in `.flow/brain/` of the main checkout, listed in `.git/info/exclude`: never
committed, and `brain.py dir` finds it from any worktree (a worktree has no
untracked files).
## Note format
File name = slug in kebab-case, the note's subject (`quote-discount-once.md`).
```markdown
---
type: domain | decision | lesson
source: "#231, PR #232"
anchors: [apps/api/src/modules/quotes/calc.ts, packages/shared/src/quotes.ts]
updated: 2026-11-10
---
<the rule, decision or lesson in 1-3 sentences - stated as a fact, present tense>
**Por quê:** <what happens if ignored; the incident or the rejected alternative>
**Como aplicar:** <when it matters and what to do - concrete enough to act on>
Ver [[other-note-slug]].
```
INDEX line, under the section of its type, alphabetical:
```
- [Desconto aplicado uma vez](domain/quote-discount-once.md) - total só em calc.ts; service só persiste
```
### Rules
- **One idea per note.** Two rules = two notes linked with `[[slug]]`.
- **Anchors are mandatory when the note describes code.** They are how
`brain.py check` knows the note may be stale. Pure product rules with no
single home may have none.
- **`source` is mandatory.** Issue, PR, or `conversa <date>` for something
the user said. A note nobody can trace is a rumor.
- **Short.** A note over ~25 lines is a doc, not a note - split it or link
to a doc.
- **Never in the brain:** what the code or git already says (structure,
signatures, history), one-off bugs that teach nothing, secrets, task
status, anything only true for one branch.
- The language follows the repo's docs.
## Read protocol (every investigation)
1. Read `INDEX.md` (cheap - it is one line per note).
2. Open only the notes whose line touches the task; `brain.py find <terms>`
when the index is long.
3. A note is a claim, not proof. Before relying on one, check its anchors
still say what the note says. Code contradicts the note: the code wins,
and the note is flagged for update (in an issue: under `## Problem` as
`Brain note <slug> is stale: <how>`; in an implementation: fix the note
in the same diff).
4. Cite what you used. Issues carry a header line `Brain: [[slug]], [[slug]]`
so the implementer reads the same notes.
## Write protocol
Write a note only when one of these happened, and only what will still be
true next month:
| Trigger | Type | Who |
|---|---|---|
| The user stated or corrected a business rule | domain | the session (`/flow:learn`), or the implementer when the issue's settled facts state a general rule |
| A choice between real alternatives was made and someone will ask "why not X" | decision | implementer (in the PR diff) |
| A mistake cost a QA round, a revert or a production bug, and a rule prevents it | lesson | implementer, or `/flow:learn --from` |
| Something fooled QA | trap in `qa-playbook.md` | flow:qa writes it pending in the flow state; `/flow:learn --playbook` promotes it |
Before writing:
- **Dedupe.** `brain.py find` the subject. An existing note that covers it
gets updated (new `source` appended, `updated` bumped), never duplicated.
- **Contradiction.** If the new fact contradicts a note, update or retire
the old one in the same change - two notes that disagree are worse than
none.
After writing: add or fix the INDEX line, then run `brain.py check
--changed` - it must come back clean for the notes you touched.
Notes ship **inside the PR diff** (or the user's working tree for
`/flow:learn`), reviewed like code. Never commit them straight to a shared
branch.
**Local brain:** there is no diff to ship in. Write the note straight into the
directory `brain.py dir` prints (the main checkout, also from a worktree) and
list it in the PR body under `Brain:` so the reviewer sees what was learned.
Never `git add` it - it is excluded on purpose.
## Hygiene
- `brain.py check --changed <base>` runs in `/flow:implement` self-review:
every note anchored to a file the diff touches comes up as `STALE?`.
Reread it against the new code; still true -> bump `updated`; no longer
true -> fix or delete it (and its INDEX line).
- `ANCHOR` (file gone) and `LINK` (broken `[[slug]]`) are always fixed in
the change that caused them.
- Retiring a note: delete the file and its INDEX line. Git keeps history;
the brain keeps only what is true now.