Local-first knowledge management system built on the Model Context Protocol (MCP). Enables bidirectional communication between LLMs and markdown files, creating a personal and team knowledge graph that persists across conversations.
Fork of basic-memory adapted for internal Box use.
git clone git@git.dev.box.net:jackzhang/agent-brain.git
cd agent-brain
pip install -e ".[dev]"
# Verify
ab --versionCLI aliases: ab, agent-brain, bm (all point to the same binary).
Agent Brain serves two purposes:
-
Personal knowledge — tool learnings, debugging findings, architecture decisions captured automatically from your Claude Code sessions into
~/agent-brain/knowledge/. -
Team knowledge — shared investigations, decisions, and code change context written to Box Drive via the
team-knowledgeproject. Syncs to everyone's machine automatically.
Run the setup script to register the team knowledge project and install hooks:
bash ~/Library/CloudStorage/Box-Box/Shield/3.\ Shield\ Engineering/Classification\ Team\ Knowledge/setup-team-knowledge.shThis:
- Registers the Box Drive team folder as an
abproject - Installs Claude Code hooks (signal collector, stop hook, prompt hook)
- Appends team knowledge instructions to your
~/.claude/CLAUDE.md - Verifies connectivity
See the team knowledge README for full onboarding details.
# Search personal knowledge
ab tool search-notes "topic" --tag repo-name
# Search team knowledge
ab tool search-notes "deadletter" --project team-knowledge
# Recent activity
ab tool recent-activity --timeframe 7d
ab tool recent-activity --project team-knowledge --timeframe 7d
# Read a specific note
ab tool read-note "memory://oncall/investigations/slug" --project team-knowledge
# Write a note
ab tool write-note --title "Finding title" \
--folder "oncall/investigations" \
--tags "oncall,classification" \
--project team-knowledge
# Deep context (follows relations between notes)
ab tool build-context "memory://knowledge/decisions/slug"
# Project management
ab project list
ab project info team-knowledge# Install dev dependencies
just install
# Run tests (SQLite only, fast)
just test-sqlite
# Run tests (SQLite + Postgres, needs Docker)
just test
# Fast local loop (lint + format + typecheck + impacted tests + smoke)
just fast-check
# Lint / format / typecheck
just lint
just format
just typecheck
# Create a database migration
just migration "Your migration message"Requires Python 3.12+. Postgres tests use testcontainers (Docker required).
Agent Brain watches a directory of markdown files, parses them into a knowledge graph, and exposes that graph via MCP tools. Notes use structured markdown with three parts:
- Frontmatter — YAML metadata (
title,tags,permalink) for indexing - Observations —
- [category] content #tag (context)— categorized facts that search indexes - Relations —
- relation_type [[Target]]— links between entities thatbuild_contexttraverses
Example:
---
title: DLQ Replay Fix
tags: [oncall, classification]
---
# DLQ Replay Fix
## Observations
- [finding] Root cause was expired TTL on retry messages #classification
- [decision] Switched to exponential backoff for DLQ replays #architecture
- [context] Found while investigating alert CLASSIFY-4082 #classification
## Relations
- discovered_in [[classification]]
- relates_to [[DLQ Retry Logic]]The hooks write notes in this exact format. If you're modifying hooks or writing notes manually, follow it — if the format is wrong, the file still syncs but won't appear in search or graph traversal.
Full format reference with schemas, permalinks, and edge cases: docs/NOTE-FORMAT.md
See CLAUDE.md for detailed architecture, code style, and development guidelines.
Key layers:
- MCP server (
src/basic_memory/mcp/) — tools exposed to LLMs via Model Context Protocol - API (
src/basic_memory/api/) — FastAPI REST endpoints - Services (
src/basic_memory/services/) — business logic - Repository (
src/basic_memory/repository/) — data access (SQLAlchemy 2.0 async) - Sync (
src/basic_memory/sync/) — file watcher and markdown-to-DB synchronization - CLI (
src/basic_memory/cli/) — Typer CLI (abcommand)
AGPL-3.0. Upstream: basicmachines-co/basic-memory