AI Brain
Personal AI memory layer — a Convex-backed MCP server, a Next.js web UI, and a Claude Code plugin. Captures thoughts across sessions, syncs project context, and synthesizes what you've learned — with citable sources.
Plugin for Claude Code
The ai-brain Claude Code plugin lives at plugins/ai-brain/. It's the recommended way to interact with AI Brain from Claude Code — five skills covering capture, sync, review, and navigation.
Install:
/plugin marketplace add flippyhead/ai-brain-plugin
/plugin install ai-brain@ai-brain-plugin
See plugins/ai-brain/README.md for details.
Development
This is a pnpm monorepo (apps/, packages/, plugins/). Install dependencies with pnpm install and see the per-package README files for specifics.
For a private deployment, follow the self-hosting runbook. It covers the two-service layout, account isolation, configuration preflight, and the point where hosted accounts and provider credentials become necessary.
Run the local verification suite with:
pnpm lint
pnpm check-types
pnpm test:once
pnpm build
Structured facts, narrative memory, and grounded recall
AI Brain uses a hybrid memory model:
entities give people, organizations, projects, and places stable identities.
facts store precise typed subject-predicate-value knowledge such as exact
dates, relationships, providers, schools, employers, and scalar preferences.
thoughts store one coherent narrative decision, project state, commitment,
or recurring pattern.
Readable fact statements are generated from structured data for search and
display; the typed value remains authoritative. The MCP server instructs
capable clients to call remember_fact or capture_thought automatically for
explicit durable information. This remains client-mediated: an MCP server
cannot observe a conversation unless the client invokes one of its tools.
For relevant prompts, recall_context combines current facts about any entity
the message names (by stored name or alias), a small set of explicitly marked
core facts, and query-specific fact and thought search results. Clients are
instructed to send the user's complete current message so exact names,
identifiers, and version strings reach retrieval unchanged. The result also
says what the brain does not know: when the newest relevant memory is older
than six weeks, two current facts disagree, or the question asks for an
attribute no fact records, a gaps block follows the memories.
list_core_memories returns the same explicitly marked core facts and
memories on their own, without a query and without running a search, so a
client can load standing context at the start of a session; the Claude Code
plugin's SessionStart hook uses it to inject that context unprompted.
Precise facts are account-isolated, source-labelled, and optionally associated
with an import batch. A single-valued fact change creates a new current record
and preserves the former record as superseded; a correction marks the
inaccurate record retracted. Derived ages are rejected in favor of an exact
date_of_birth value when the date is actually known.
Smart Save compares each capture with the account's current memories:
- Independent information is added.
- Duplicate information is ignored.
- Information that changed creates a new current memory and marks the former
memory as
superseded.
- A correction creates a new current memory and marks the incorrect memory as
retracted.
- Broad, incidental, inferred, derived, or non-atomic candidates are returned
as
ASK or SKIP without being stored.
Superseded and retracted memories are preserved and linked to their replacement;
they are not overwritten or deleted. Normal search and browsing return current
memories. MCP clients can request historical results when answering questions
about prior states or how something changed.
Forgetting is the one exception. Retract when a memory was wrong; forget when
it must not remain in storage regardless, such as a mis-captured credential or a
third party's private detail. forget_thought, forget_fact, and
forget_entity hard-delete the record with no undo and no tombstone. A
forgotten memory's neighbours are repaired rather than left dangling: an
earlier memory it had replaced stays retired (forgetting a change is not an
undo of it), and its replacement stays current. Forgetting an entity also
deletes every fact about it and every fact on another subject whose value is
that entity, because those facts' readable text carries the entity's name.
Each call requires a reason, which is echoed back but not stored — nothing
remains to store it on.