Skip to main content

Brain Framework logo

Brain Framework

From scattered information to informed actions, using plain files you own forever.

CI PyPI Python License: MIT

AI coding agents lose context between sessions, while proprietary memory platforms lock your knowledge inside opaque databases. Brain Framework (bf) turns a plain Git folder of Markdown notes, schema-validated JSONL records, and shell or Python loops into a fast, offline knowledge brain for humans and AI coding agents.

  • Plain files, zero lock-in: YAML for config, Markdown for humans, canonical JSONL for records. Inspect or query your data anytime with git, rg, jq, or DuckDB.
  • Instant offline BM25 search: A strictly disposable SQLite FTS5 cache ranks authored notes ahead of raw memories, resolves aliases and backlinks, and never mutates disk on read-only commands.
  • Least-privilege automation loops: Run deterministic collectors (sensors/), maintenance jobs (routines/), coding agents (agents/), and stream daemons (when: daemon) with per-loop secret allowlists (env_from:) and live bf watch supervision.
  • Lean, model-agnostic core: Three runtime dependencies (jsonschema, markdown-it-py, pyyaml) on Python 3.12+, zero built-in LLMs, and zero global config.

Brain Framework terminal demo: ranked BM25 query, backlinks, staleness review, and failure-first live bf watch

Quick start

Requires Linux or macOS and uv (Python 3.12+). No model API key, database server, or cloud account is required:

uv tool install brain-framework
bf init ~/brain
cd ~/brain
bf check --format text
bf status --format text
bf query "welcome" --format text

Output on a fresh brain:

Check: brain  [OK]
  notes=1  memories=0  errors=0  warnings=0

Brain: brain  [HEALTHY]
  notes=1  memories=0  loops=0  events=1

Query (fts5): 1 result(s) for 'welcome'

  concepts/welcome.md#welcome  Welcome

If BF_BRAIN is already exported in your shell, unset it or pass --brain ~/brain.

Next, follow Getting started to ingest records and write linked decisions, or run the four-tool walkthrough with synthetic Workspace, Jira, GitHub, and Google Cloud fixtures.

How it works

Gather, normalize, connect, act, and learn loop

A brain is one portable directory organized around a 3x3 layout (three note folders, three loop folders, three JSONL record streams):

my-brain/
├── bf.yaml         # Config: notes, brains, search.exclude, concurrency pools, loops
├── concepts/       # Durable knowledge (<slug>.md or <slug>/index.md bundles)
├── projects/       # Ongoing initiatives and decisions
├── actions/        # Scoped requests, deliverables, and attachments
├── sensors/        # Deterministic collectors (stdout JSONL -> memories/)
├── routines/       # Maintenance scripts and continuous daemons (when: daemon)
├── agents/         # Coding-harness or LLM tasks
├── schemas/        # Optional domain JSON Schemas (core record schema always enforced)
├── evals/          # User-owned Python/pytest contract checks
├── memories/       # Canonical JSONL (_notes.jsonl + <source>.jsonl; gitignored)
├── logs/           # Private 0700 structured JSONL loop logs (gitignored)
└── .bf/            # Private 0700 runtime: disposable cache/index.sqlite3, state/, locks/
  • Authoring: Write CommonMark Markdown with YAML frontmatter, #id heading anchors, checklist tasks, typed links ({rel=cites}), universal refs (source:id, bf://), and optional schemas/<source>.json validation.
  • Retrieval: Search ranked BM25 hits and --links-to backlinks with bf query, resolve notes, #anchor sections, or aliases with bf read, track freshness with bf review, and run rg, jq, or DuckDB directly on memories/*.jsonl.
  • Operations: Declare explicit loops: with named concurrency: pools, per-loop env_from: secrets, trailing-edge debounce:, delayed bf emit --in|--at wakeups, live bf pause/bf resume, and bf watch supervision.
  • Reference: Full CLI contract (strict read-only vs write commands), exit codes, BF_* env vars, {{...}} placeholders, bf.yaml config, and published Draft 2020-12 JSON Schemas (bf schema).

Start small, automate when ready

You only need the core commands on day 1; add sensors and bf watch only when you want automated collection:

Tier Goal Commands
1. Core Write Markdown notes, validate links, and search offline init, build, query, read, review, check, status, schema
2. Automation Ingest tool feeds, trigger routines or agents, and supervise continuously ingest, run, watch, emit, events, pause, resume, state

Works with your AI coding harness

bf pairs with Claude Code, Codex, Antigravity, Gemini CLI, OpenCode, or any terminal agent without an MCP server:

  • Inside a brain: Agents read the repo's AGENTS.md, orient with bf status and bf review, edit Markdown notes directly, and verify with bf build && bf check plus evals/.
  • From any repository: Set export BF_BRAIN=~/brain and install the optional /bf skill (npx skills add fmind/brain-framework --skill bf) so your harness queries and updates your brain on demand.
  • Always-on supervision: Run bf watch in a terminal for a live failure-first loop table (or headlessly as jsonl under systemd --user / launchd), and attach anytime with read-only bf status --watch.

Typical coding-agent session from another repository (BF_BRAIN=~/brain):

bf status --format text                          # Orient: counts, health, unbuilt notes
bf query "launch decision" --kind note           # Ranked BM25 search across notes
bf read "projects/new-website.md#decision"       # Load only the cited #anchor section
bf query --links-to "workspace:brief"            # Follow backlinks to linked records
bf review --format text                          # Spot stale notes with newer evidence

Design principles

  1. Strict read/write boundary: bf status, bf review, bf read, bf query, bf events, bf check, and bf schema never touch disk. Cache readers open .bf/cache/index.sqlite3 in strict read-only mode (mode=ro) with automatic JSONL fallback.
  2. Private and confined by default: Every path opens via O_NOFOLLOW directory descriptors, .bf/ and logs/ enforce 0700/0600 owner-only permissions, secrets stay scoped to each loop's env_from:, and logs redact credentials automatically.
  3. Git-native collaboration: Track notes, config, schemas, loops, and evals in Git while keeping generated memories/, private logs/, .env, and .bf/ local.

Documentation · Examples · Issues · Contributing · Governance · Security · Third-party notices

Metadata

Release files for brain-framework 34.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brain-framework 34.1.0
File Size Uploaded Provenance Actions
brain_framework-34.1.0.tar.gz 145.1 kB With provenance Details for brain_framework-34.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brain-framework 34.1.0
File Interpreter ABI Platform Actions
brain_framework-34.1.0-py3-none-any.whl Python 3 none any Details for brain_framework-34.1.0-py3-none-any.whl

Total release size: 300.1 kB

Release files / brain_framework-34.1.0.tar.gz

Download URL brain_framework-34.1.0.tar.gz
Size 145.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c23263786cb3da59c6be7f09a021844c29f3d31f8bf0ef435760e161092bbf35
BLAKE2b-256 checksum
How to use checksums
fac7e3dce95d76ad9a0988f4048c4da7427b08ab5bdc19a9c26ed403daf64829
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / brain_framework-34.1.0-py3-none-any.whl

Download URL brain_framework-34.1.0-py3-none-any.whl
Size 155.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
411384fdef75b21374ef4c67fd2084f9724c7abdd1e243b6fcfa56deb26a4ca7
BLAKE2b-256 checksum
How to use checksums
ee7f10607071e4531c3519c1cd0be941201a8a5daffc9a7ea5a7850cdd0134bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for brain-framework 34.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for brain_framework-34.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

34.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page