Add durable knowledge to the repo's brain (docs/brain/, or a local .flow/brain/). With a sentence, turns a business rule, decision or lesson into a note. With --from <issue-or-PR>, distills 0-3 notes from a finished issue, its PR and QA reports. With --check, reviews stale notes. With --playbook, promotes the QA traps pending in the flow state into the repo's QA playbook. Writes to the working tree; never commits.
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 Learn?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/eusilvio-learn)
---
name: learn
description: "Add durable knowledge to the repo's brain (docs/brain/, or a local .flow/brain/). With a sentence, turns a business rule, decision or lesson into a note. With --from <issue-or-PR>, distills 0-3 notes from a finished issue, its PR and QA reports. With --check, reviews stale notes. With --playbook, promotes the QA traps pending in the flow state into the repo's QA playbook. Writes to the working tree; never commits."
argument-hint: "\"<fato em uma frase>\" | --from <issue#|pr#> [--auto] | --check | --playbook [--auto]"
allowed-tools: Bash(gh:*), Bash(git:*), Bash(ls:*), Bash(rm:*), Bash(${CLAUDE_PLUGIN_ROOT}/scripts/brain.py:*), Bash(${CLAUDE_PLUGIN_ROOT}/scripts/codemap.py:*), Bash(${CLAUDE_PLUGIN_ROOT}/scripts/flowctl.py:*), Read, Write, Edit, Grep, Glob, AskUserQuestion
model: sonnet
---
(`<brain>` = the directory `${CLAUDE_PLUGIN_ROOT}/scripts/brain.py dir` prints (`docs/brain/` by default; `.flow/brain/` of the main checkout for a local, unversioned brain).)
Arguments: $ARGUMENTS
Follow the `brain` skill (`${CLAUDE_PLUGIN_ROOT}/skills/brain/SKILL.md`) for
format and rules - read it first. No `<brain>/` yet: run
`${CLAUDE_PLUGIN_ROOT}/scripts/brain.py init` and show the user the CLAUDE.md
line it prints (or `init --local` when the user wants the brain out of git).
## Mode 1 - a sentence (`/flow:learn "fabricante é a marca, fornecedor é o parceiro com CNPJ"`)
1. Classify: `domain`, `decision` or `lesson`. Business vocabulary and rules
are domain; "we chose X over Y" is decision; "this broke because" is
lesson.
2. `brain.py find <2-3 key terms>`. A note already covers it: update that
one (append source, bump `updated`, reconcile wording) instead of adding.
3. Find anchors with `${CLAUDE_PLUGIN_ROOT}/scripts/codemap.py find <terms>`:
the files where the rule lives. Read them enough to confirm the rule
matches the code. If the code contradicts the sentence, say so and ask
which is right before writing - do not record a rule the code breaks
without the user knowing.
4. Write the note and its INDEX line. `source: conversa <today>` unless the
user named an issue.
## Mode 2 - distill (`/flow:learn --from 231`)
1. Load the record in one parallel batch: `flowctl.py spec view N --json`
(GitHub issue or local spec `.flow/specs/N.md`), the linked PR
(`gh pr list --state all --search "<term> in:body" --json number,title,body`,
term from `flowctl.py spec ref N --search`: `#N` or `Flow-Spec: N`) and its diff stat
(`gh pr diff <pr> --name-only`).
2. Extract candidates - only what will still be true next month:
- **domain**: settled facts in the issue that are general product rules,
not this feature's details; user answers recorded from the 1.5 gate.
- **decision**: `## Open decisions` with their resolution, and the
"why not X" from the implementer's decision comment.
- **lesson**: each QA FAIL whose cause generalizes (the defect class, not
the instance), each `spec-mismatch`, each revert.
3. Drop everything the code, git or an existing note already says. Zero
candidates is a valid and common outcome - say so and stop.
4. Present at most 3 candidates in one `AskUserQuestion` (multiSelect),
each with its type, slug and first sentence. Write only the chosen ones,
with `source: "#N, PR #M"` and anchors from the PR's diff.
### `--auto` (called by `/flow:merge`, nobody to ask)
Same steps 1-3, but step 4 has no question: you decide, with a stricter bar.
Write a candidate only when all hold:
- **It changes what the next agent does.** Someone working in that area
next month, reading only the code and the brain, would plausibly make the
same mistake or break the same rule without this note.
- **The code does not already say it.** A type, a test, a constraint or a
comment at the anchor that makes the rule obvious beats a note.
- **It is general.** It names a defect class or a product rule, not this
issue's instance ("validate route ids as uuid before querying", not "the
departments route returned 500").
- **Nothing covers it yet**: no brain note, CLAUDE.md line or playbook trap.
Covered but outdated -> update that note instead of adding one.
At most 2 notes. Zero is the expected outcome for most issues: a fix that
QA caught and the implementer corrected in one round, with a test guarding
it, usually needs no note - the test is the memory. Report each written note
in one line (path + why it passes the bar) and the dropped candidates in one
line with the reason.
## Mode 3 - review (`/flow:learn --check`)
Run `brain.py check`. For every `STALE?`, read the note and its anchors,
then: still true -> bump `updated`; changed -> rewrite to match the code;
obsolete -> delete note and INDEX line. Fix every `ANCHOR`, `LINK`,
`UNLISTED`, `INDEX` and `META` line. Rerun until clean.
## Mode 4 - promote QA traps (`/flow:learn --playbook`)
`flow:qa` never writes the playbook inside a PR (parallel PRs would conflict
on it). It leaves one file per issue in
`$(${CLAUDE_PLUGIN_ROOT}/scripts/flowctl.py playbook-dir)/<N>.md`. This mode
moves them into the repo.
With `--auto` (called by `/flow:merge`) nothing changes except that the
user is not asked about unmerged files: they simply stay pending.
1. List the pending files. None: say so and stop.
2. Open the repo's playbook (`<brain>/qa-playbook.md`, an existing legacy
`docs/memory/qa-playbook.md`, or the path CLAUDE.md names). Missing:
create it from `${CLAUDE_PLUGIN_ROOT}/skills/verify/playbook-template.md`.
3. For each pending file whose issue PR was merged (`gh pr list --state
merged --search "<term> in:body"`, term from `flowctl.py spec ref N --search`) - unmerged ones stay pending unless the
user says otherwise:
- `## Setup` lines: append those the playbook does not already say.
- Traps with an existing id (`T<n>`): apply the bump (`seen`, `last`,
`Source`) to that entry.
- New traps (`T?`): dedupe against the playbook by `Trigger` + probe
(same -> bump instead); otherwise append with the next free `T<n>`.
4. Cap at 30 traps: over it, merge the closest pair or drop the one with the
lowest `seen` and oldest `last`. A trap at `seen 3x` or more: list it
in the report with a suggestion to make it automatic (test helper, lint
rule, CLAUDE.md rule, schema constraint).
5. Delete each promoted pending file (`rm`), only after the playbook edit
is written.
## End
Run `brain.py check --changed` and report the notes written, updated or
retired (or the traps promoted), as paths. Do not commit: notes are reviewed like code, so leave them
in the working tree (or the current PR branch) and say so.