| name | brainctl |
| description | Unified agent memory CLI — read, write, search, and maintain the shared memory spine (brain.db). Use for persistent cross-session memory, knowledge graph, event logging, decisions, affect tracking, and consolidation. |
| version | 1.6.1 |
| tags | ["memory","agents","sqlite","knowledge-graph","mcp","cli"] |
| trigger | When you need to store durable facts, log events, track entities/relations, record decisions, search past context, or orient yourself in a multi-agent environment. |
brainctl — Agent Memory CLI
Overview
brainctl is the single interface for agent memory. One SQLite file (brain.db), no server required. All agents share it. Every write is attributed to the writing agent.
- GitHub: https://github.com/TSchonleber/brainctl
- Database:
~/agentmemory/db/brain.db (override with BRAIN_DB env var)
- CLI binary:
~/bin/brainctl or ~/.local/bin/brainctl
- MCP server:
brainctl-mcp (201 tools, same DB)
Already installed on this machine. If missing, see GitHub README for install instructions.
Design Principle: Model-Agnostic
brainctl has ZERO LLM dependencies. No Anthropic, no OpenAI, no vendor SDK. It is pure SQLite + Python stdlib. The agent does the thinking, brainctl does the remembering. If an agent wants LLM-powered consolidation, the agent calls its own LLM and feeds results back via brainctl memory add. Functions like consolidate_memories() and compress_memories() accept an optional llm_fn parameter — callers can inject their own, but brainctl never calls one itself.
Agent Attribution
ALWAYS pass -a AGENT_NAME to attribute writes. Examples:
-a my-agent — your agent's unique name
-a human — manual/human entries
-a unknown — fallback if unsure
Commands — Quick Reference
Memories (durable facts)
brainctl -a my-agent memory add "All timestamps in logs are UTC" -c convention
brainctl -a my-agent memory search "python version"
brainctl -a my-agent memory list --limit 10
Events (timestamped logs)
brainctl -a my-agent event add "Deployed v2.0 to production" -t result -p myproject
brainctl -a my-agent event search -q "deploy"
brainctl -a my-agent event tail -n 20
Entities (typed knowledge graph)
brainctl -a my-agent entity create "Alice" -t person -o "Engineer; Likes Python; Based in NYC"
brainctl -a my-agent entity get Alice
brainctl -a my-agent entity observe "Alice" "Now leads the infrastructure team"
brainctl -a my-agent entity relate Alice works_at Acme
brainctl -a my-agent entity search "engineer"
Decisions
brainctl -a my-agent decision add "Switch to local inference" -r "Need local-first fallback"
Cross-Table Search
brainctl -a my-agent search "deployment"
Prospective Memory (Triggers)
brainctl trigger create "Alice mentions vacation" -k vacation,alice -a "Remind about project deadline"
brainctl trigger check "alice is going on vacation"
Reports & Lint
brainctl report
brainctl report --topic "deploy"
brainctl report --entity "Alice"
brainctl lint
brainctl lint --output text
brainctl lint --fix
Stats
brainctl stats
Init (first-time setup)
brainctl init
Output Formats
Control token consumption with --output:
brainctl search "deploy" --output json
brainctl search "deploy" --output compact
Affect Tracking
Functional affect states (frustration, urgency, satisfaction, confusion, confidence, curiosity) — not sentiment analysis. Influences memory formation and retrieval.
brainctl affect classify 'the deploy failed and rollback is stuck'
brainctl affect log 'finally resolved the outage after 4 hours'
brainctl affect check
brainctl affect monitor --watch
Consolidation Engine
Pure-math memory maintenance — no LLM required. Run periodically or via cron:
brainctl-consolidate decay
brainctl-consolidate compress
brainctl-consolidate promote
brainctl-consolidate cycle
Also includes: Hebbian co-retrieval strengthening, temporal demotion, EWC importance locking, recall boost, experience replay. All pure SQLite math — no external calls.
MCP Server (201 tools)
If your adapter supports MCP, configure brainctl-mcp as an MCP server:
{"mcpServers": {"brainctl": {"command": "brainctl-mcp"}}}
Core tools: memory_add, memory_search, event_add, event_search, entity_create, entity_get, entity_search, entity_observe, entity_relate, decision_add, search, stats, handoff_add, handoff_latest, trigger_check
201 tools total covering memory, events, entities, decisions, triggers, handoffs, consolidation, affect, beliefs, temporal reasoning, and more. See MCP_SERVER.md for the full list and decision tree.
All tools accept optional agent_id and profile (task-scoped search presets). CLI and MCP are fully interchangeable — same DB.
Post-Checkout Orientation (Task-Based Agents)
After checking out a task, orient yourself:
brainctl -a YOUR_AGENT search "keywords about your task"
brainctl -a YOUR_AGENT memory search "relevant topic"
brainctl event tail -n 10
brainctl -a YOUR_AGENT event add "what you did and the outcome" -t result -p PROJECT_NAME
brainctl -a YOUR_AGENT memory add "the fact or lesson" -c lesson
brainctl -a YOUR_AGENT decision add "what was decided" -r "why"
Architecture
brain.db (single SQLite file, 80+ tables)
├── memories FTS5 full-text + optional vector search
├── events timestamped logs with importance scoring
├── entities typed nodes (person, project, tool, concept...)
├── knowledge_edges directed relations between any table rows
├── decisions recorded with rationale
├── memory_triggers prospective memory (fire on future conditions)
├── affect_log per-agent functional affect state tracking
└── 60+ more consolidation, beliefs, policies, epochs...
Valid Categories & Types
- Memory categories: identity, user, environment, convention, project, decision, lesson, preference, integration
- Event types: observation, result, decision, error, handoff, task_update, artifact, session_start, session_end, memory_promoted, memory_retired, warning, stale_context
- Task statuses: pending, in_progress, blocked, completed, cancelled
- Task priorities: critical, high, medium, low
Pitfalls
- Namespace collision: If
~/agentmemory/ exists as a directory, Python may pick it up as a namespace package instead of the installed agentmemory. Set PYTHONPATH explicitly if needed.
- FTS5 special characters: brainctl sanitizes queries automatically, but if calling the DB directly, strip
. & | * " ' \ ( ) - @ ^ ? ! , ; :` from search terms.
- Agent attribution: Always use
-a. Writes without attribution default to "unknown" and are harder to trace.
- Token costs: Use
--output compact in automated pipelines to save ~24% tokens.
- Vector search optional: brainctl works fine without embeddings. Only needed for semantic similarity search.
- Broken local install: If
~/bin/brainctl throws import errors, the wrapper may have a circular import. Run from the repo directly: cd ~/agentmemory && python3 -m agentmemory.cli or use ~/.local/bin/brainctl.
- When debugging brainctl itself: Don't chase broken local wrappers — check the GitHub repo (
https://github.com/TSchonleber/brainctl) for the canonical source. The local install has namespace collisions with ~/agentmemory/ directory.
- No batch command: The
brainctl batch subcommand was removed (vendor lock-in). If you need bulk LLM operations, do them in your own agent code and write results back via brainctl memory add.