Skip to content

Latest commit

Β 

History

234 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Brain Framework logo

Brain Framework

From information to informed actions.

CI PyPI Python License: MIT

Brain Framework turns a regular Git folder into a living second brain that you own forever. Combine plain Markdown memory that humans and coding agents can search offline with continuous loops that keep sensors, listeners, and always-on agents running around the clock.

  • Plain files, zero lock-in: Markdown, YAML, and JSONL with three dependencies, versioned in Git, and zero built-in LLMs.
  • Shared memory, backed by evidence: Edit Markdown in any editor, query offline from any coding agent, and flag stale decisions when linked facts change.
  • Continuous loops for always-on agents: Supervise scheduled sensors, live channel daemons, and event-driven agents together with bf watch and per-loop secret allowlists.

Brain Framework terminal demo: ranked search, backlinks, staleness review, and live bf watch supervision

Quickstart

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

Install the CLI and initialize a brain folder:

uv tool install brain-framework
bf init ~/brain
cd ~/brain

Ingest a source record, write a decision note that cites it, and build the local search index:

bf ingest workspace <<'EOF'
{
  "id": "brief",
  "title": "Website brief",
  "type": "doc",
  "text": "Start with one clear product page before signup.",
  "created": "2026-11-10T09:00:00Z",
  "updated": "2026-11-10T09:00:00Z"
}
EOF

cat > projects/launch.md <<'EOF'
---
type: project
status: active
created: 2026-11-12
updated: 2026-11-15
description: Launch one focused product page.
---

# Launch site

## Decision {#decision}

Ship one product page first ([brief](workspace:brief){rel=cites}).
EOF

bf build

Search offline to see your decision rank ahead of the raw brief. Then update the brief and let bf review catch the stale decision automatically:

bf query "product page" --format text

bf ingest workspace <<'EOF'
{
  "id": "brief",
  "title": "Website brief",
  "type": "doc",
  "text": "Add a pricing table before signup.",
  "created": "2026-11-10T09:00:00Z",
  "updated": "2026-11-20T14:00:00Z"
}
EOF
bf review --format text

Output:

Query (fts5): 2 result(s) for 'product page'

  projects/launch.md#decision  Launch site
    Launch site Decision Ship one product page first (brief).
  workspace:brief  Website brief
    Start with one clear product page before signup.

Review: brain  [STALE (1)]
  stale=1  open_tasks=0

  REF                 REASONS                 DETAIL
  projects/launch.md  newer_evidence          newer: workspace:brief

Next, follow Getting started, wire continuous loops in Loops, or explore the offline example brain.

How it works

Perceive, normalize, connect, act, and learn loop connecting your tools, your brain folder, and your routines and agents

A brain is one portable directory where perception, memory, and action feed each other:

  • Perceive: Small sensors collect records from your tools into flat JSONL files, while always-on daemons listen to live channels such as chat or webhooks.
  • Remember: Humans and agents curate Markdown notes linked to raw evidence. A read-only, disposable offline search index finds answers in milliseconds and flags notes when linked facts change.
  • Act and learn: Routines, event-driven agents, and interactive coding harnesses read that context, act through your existing CLIs or APIs, and write outcomes back to the brain.

Memory and continuous loops sit on the same level inside one bf.yaml and 3x3 layout, and either side works on its own:

  • Memory: Plain Markdown notes with instant offline search, section reads, staleness checks, and agent recall.
  • Loops: Scheduled tool feeds, live daemon listeners, event-driven agents, and 24/7 bf watch supervision.
my-brain/
β”œβ”€β”€ bf.yaml         # Declarative config for notes, search, and loops
β”œβ”€β”€ concepts/       # Durable knowledge, standards, and conventions
β”œβ”€β”€ projects/       # Ongoing initiatives and decisions
β”œβ”€β”€ actions/        # Scoped requests, deliverables, and attachments
β”œβ”€β”€ sensors/        # Scheduled scripts collecting records from your tools
β”œβ”€β”€ routines/       # Maintenance jobs and always-on stream daemons
└── agents/         # Scheduled and event-driven coding-harness tasks

See the full layout and runtime folders (memories/, logs/, .bf/) in the reference.

Works with your AI coding harness

Brain Framework works with Claude Code, Codex, GitHub Copilot, Antigravity, Gemini CLI, OpenCode, and any terminal agent without running an MCP server.

  • Inside a brain: Agents read the folder's AGENTS.md, check health and stale notes, edit Markdown directly, and verify changes with bf build and bf check.
  • From any repository: Export BF_BRAIN to point to your brain folder and install the optional /bf skill with npx skills add fmind/brain-framework --skill bf.

A typical read-only lookup from another repository:

bf status --format text                     # Orient: health, counts, and attention items
bf query "product page" --kind note         # Search curated notes first
bf read "projects/launch.md#decision"       # Load one cited section without extra noise
bf query --links-to "workspace:brief"       # Follow backlinks to every citing note
bf review --format text                     # Spot stale decisions and open tasks

Run continuous loops and always-on agents

Declare plain shell or Python scripts in bf.yaml to keep your brain updated and run always-on agents without an external orchestrator. bf watch supervises scheduled sensors, passive channel daemons, delayed timers, and event-driven agents together, forwarding only the secrets each loop allowlists:

version: 20
name: my-brain
concurrency:
  default: 4
  interactive: 2
loops:
  github-issues:
    description: Pull GitHub issues every 30 minutes.
    run: [python3, sensors/github-issues.py, owner/repo]
    env_from: [GH_TOKEN]
    ingest: upsert
    when: 30m
  chat:
    description: Stream incoming messages from a live channel.
    run: [python3, routines/chat.py, listen]
    emit: loop.message
    mode: daemon
  triage:
    description: Run hourly checks and reply immediately to live messages.
    run: [python3, agents/triage.py]
    pool: interactive
    timeout: 15m
    env_from: [ANTHROPIC_API_KEY]
    when:
      - every: 1h
      - event:
          kind: loop.message
          source: chat

Passive mode: daemon listeners stay running cheaply in plain code, while agents wake on a schedule or matching event, run your preferred coding harness, and write outcomes back to the brain.

  • Preview or run once: Inspect resolved commands and secrets with bf run triage --dry-run, or run a single cycle with bf run github-issues.
  • Supervise around the clock: Run bf watch interactively for a live terminal dashboard, or under systemd or launchd for 24/7 structured JSONL logging.
  • Control live loops: Mute flaky jobs with bf pause and attach a read-only live view from another terminal with bf status --watch.

See Loops for sensor contracts, event predicates, and concurrency pools, Operations for 24/7 supervision, and Security for secret allowlists and limits.

How it compares

Approach Storage and ownership Search and agent interface Automation and trust
Brain Framework Plain Git Markdown + flat JSONL Read-only CLI, ranked offline search, rg/jq/DuckDB Continuous bf watch loops with per-loop secret allowlists
Plain Markdown / Obsidian Local Markdown files Filename or grep search; no staleness checks Manual upkeep or UI plugins; no structured feeds
Hosted / MCP memory Opaque or remote database Always-on MCP schemas and model-mediated recall Extra services and API keys; hard to audit in Git
Generic vector RAG Chunked embeddings in a vector index Similarity over opaque chunks Needs embedding pipelines; weak provenance and backlinks
Monolithic agent platforms App-owned database or plugin state Bundled LLM runtime and platform-specific SDKs Broad host or token permissions; hard to swap harnesses or edit

When not to use

  • You want turnkey SaaS connectors, built-in LLM synthesis, or an MCP server instead of running your own CLI scripts and coding harness.
  • You need semantic vector search, multimodal blob storage, or multi-user concurrent web editing across millions of records.
  • You run primarily on native Windows without WSL (Brain Framework targets Linux and macOS POSIX confinement).

More

Documentation | CLI reference | Example brain | Issues | Security | License (MIT)

Releases

Packages

Used by

Contributors

Languages