Repository navigation
feat(cli): add brain hooks so the memory loop runs by itself - #2
Merged
Merged
Conversation
Adds Memory.Title(), which every display path now shares. Effectiveness memories previously rendered as "## Outcomes" — their body's first line is a markdown heading, not a summary — so they reached users and models as a stray fragment. Their identity is structured, so the title is built from persona and domain rather than parsed back out of prose. - Removes the duplicated firstLine helpers in recall and the MCP handlers - Keeps recall, the MCP tools, and the session-start hook from drifting into three different answers for the same memory
Adds brain hooks, which prints the configuration that makes the memory loop run by itself, and brain hooks session-start, the hook that injects a project's highest-authority memories into a new session. brAIn prints and the human installs — it never edits a settings file someone else owns. - session-start always exits 0: a hook exiting 2 blocks the session, and an empty or absent .brain/ is ordinary rather than exceptional - --tool cursor emits .cursor/rules/brain.mdc; the default emits Claude Code's settings.json block and the CLAUDE.md rules - The settings block carries a timeout, since nothing inside the hook can bound a wedged recall portably - hooks joins the commands that run without a .brain/, building its own engine per the contract documented in root.go
Pins the behaviour that would otherwise fail invisibly inside someone's editor. The scan resolving every "brain <command>" in the printed setup and in the README against the real command tree is the load-bearing one: the definition docs already carry "brain recall --for council", a flag that has never existed. - Session start exits 0 and stays silent with no .brain/, an empty one, or a stale --dir - Authority ordering and the five-memory cap are asserted, not assumed - The settings snippet is parsed as JSON and its named command executed
Adds an Editor Setup section covering install, brain hooks, paste, done, and updates Status now that editor integration ships. States the split a fresh clone actually gets: memories are committed and travel with the repository, while hook configuration is per-developer.
brAIn is ten pitches deep and has never remembered anything about its own construction. Seeds sixteen memories: settled decisions that otherwise live only in gitignored files, and lessons from building that exist nowhere else. - Decisions and corrections from .doc/ and CLAUDE.md, neither of which git carries, so a session could never reach them - Lessons the work taught, including that definition-doc examples drift from the CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
brAIn shipped every part of the memory loop and nothing ever called it — a session
started cold unless someone remembered to type
brain recallfirst. This adds theeditor integration that closes it: a session-start hook that loads project memory
automatically, plus the rules covering what a hook cannot know.
Pitch
.doc/pitches/02-04-claude-code-hooks.md— local only, since.doc/stays out ofthe public repo.
Changes
New command
brain hooksprints Claude Code'ssettings.jsonblock and the CLAUDE.md rules;--tool cursorprints.cursor/rules/brain.mdcbrain hooks session-startinjects the top five memories, ranked by layer authorityDisplay
Memory.Title()is now shared by recall, the MCP tools, and the hook. Effectivenessmemories no longer render as
## OutcomesThis repository
.brain/seeded with sixteen memories and committedArchitecture Highlights
an install step, a
chmod, a bash dependency, and a test that has to reconstruct ahostile PATH to exercise ten lines.
session-startalways exits 0. A SessionStart hook exiting 2 blocks the session,and
brain recallexits 2 on an empty store — an ordinary state, not an error.local commit is not a ship: ten of them would walk a domain from
asktonotifyontyping alone. Recording stays with merges, deploys, and Beacon.
startup|clear|compact. Compaction matters most — it is wherea correction gets summarised away.
resumeandforkinherit a context that alreadyhas the injection.
Test Plan
.brain/, an empty one, or a stale--dir## Outcomesbrain <command>in the printed setup and in the README resolves against the realcommand tree — mutation-checked by injecting
brain verify, which fails the testalwaysApply: true; the Cursor setup never claimsa hook loads memory
--toolexits 3make cipasses (build + test + lint, 0 issues); coverageinternal/cmd79.5% → 82.6%,internal/memory0% → 62.5%Follow-ups
08-ai-workflow.mdshows.cursorrules, which is absent fromCursor's current docs, and
06-mcp-and-cli.mddocumentsbrain recall --for council, a flagthat has never existed.
correction permanently occupies a session-start slot ahead of any decision. Worth its own pitch.