Knowledge graph CLI for structured memory in Claude Code
Project description
Give your AI coding agent a knowledge graph that compounds.
Entities, relationships, signals. All local. Zero config.
Quick Start
pip install xarc-brain
cd your-project
brain init
That's it. Your agent maintains the graph automatically.
How It Works
Every conversation follows a cognitive loop:
- Scan -- query the graph for context before responding
- Respond -- with full awareness of entities, relationships, and history
- Write -- capture new information back to the graph
This loop is enforced by hooks that fire automatically. You don't need to remember to use the brain. It's architecturally guaranteed.
What It Tracks
Brain stores entities (projects, people, goals, tasks, blockers, decisions, events), relationships between them (who owns what, what blocks what, what depends on what), and temporal signals (what's stale, what's stuck, what just shipped).
What It Looks Like in Production
This is the actual brain of CCL, the AI agent that built this tool. 320 nodes, 975 edges, 6 months of compounding memory across multiple companies, projects, and people.
Your agent builds this over time. Every conversation adds to the graph.
Type System
Nodes are organized in three tiers:
| Tier | Purpose | Default Types |
|---|---|---|
| Structural | Long-lived entities | project, person |
| Operational | Active work items | goal, task, decision, blocker |
| Temporal | Immutable records | event, observation, status_change |
Add your own types:
brain config add-type service structural
brain config add-type feature operational
Signals
brain signals computes what needs attention:
| Signal | What It Detects |
|---|---|
| Stale | Nodes not verified/updated in 7/14/30+ days |
| Velocity zero | Tasks/goals stuck in non-terminal status |
| Dependency changed | Upstream node updated since you last checked |
| Recently completed | Items done in last 7 days (check what they unblock) |
| Recurring overdue | Recurring activities past their frequency threshold |
CLI Reference
Top-level commands
| Command | Purpose |
|---|---|
brain init |
Bootstrap brain for a project |
brain get <id> |
Show a single node + its edges |
brain scan <id> |
3-hop topology view |
brain context <id> |
Node + neighbors with content |
brain search "<term>" |
Keyword search across title/content/id |
brain search-semantic "<term>" |
Vector search (requires [embeddings]) |
brain signals |
Compute all freshness/decay signals |
brain stats |
Counts by type |
brain verify <id> |
Mark node as verified |
brain dream |
Run full maintenance cycle |
brain viz |
Open browser visualization |
brain export --format <fmt> |
Export graph (cytoscape, json, or batch) |
Write group
brain write node --json-data '<json>'-- create or update a nodebrain write edge --json-data '<json>'-- create or update an edgebrain write batch --file <path>-- bulk import operations
Delete group
brain delete node --id <id>-- archive a nodebrain delete edge --from <id> --to <id> --verb '<verb>'-- end an edge
Query group
brain query cypher "<cypher>"-- raw Cypher (use--read-onlyfor safety)brain query depends-on <id>-- what this node depends onbrain query blast-radius <id>-- what depends on this nodebrain query chain <id>-- full dependency chainbrain query changed-since <date>-- nodes modified sincebrain query stale [--threshold N]-- nodes past threshold (default 14 days)brain query person <id>-- full person assessment subgraph
Embed group
brain embed backfill-- generate embeddings for nodes missing thembrain embed status-- coverage report
Hygiene group
brain hygiene dedup-- find potential duplicatesbrain hygiene orphans-- disconnected nodesbrain hygiene verbs-- verb usage auditbrain hygiene completeness-- schema rule violationsbrain hygiene file-paths-- broken / missing file_path checksbrain hygiene content-drift-- brain content vs source file driftbrain hygiene readiness-- operational readiness checks
Config group
brain config show-- show current configbrain config add-type <type_name> <tier>-- register a custom type (tier:structural,operational, ortemporal)
JSON schemas
Node:
{
"id": "my_node_id",
"type": "project",
"title": "Display name",
"status": "active",
"content": "Optional markdown content",
"file_path": "optional/relative/path.md",
"properties": {"any": "nested object"}
}
Edge (note: field names are from, to, verb -- not from_id/source):
{
"from": "source_node_id",
"to": "target_node_id",
"verb": "depends on",
"since": "2026-04-07",
"source": "human",
"note": "optional context"
}
Global flags
--json-output is a global flag and must come before the subcommand:
brain --json-output stats(correct)brain stats --json-output(errors withNo such option)
Optional Features
Semantic Search
pip install 'xarc-brain[embeddings]'
# Set OPENAI_API_KEY in your environment
brain embed backfill
brain search-semantic "authentication flow"
Conversation History Replay
pip install 'brain-cli[memory]'
# brain dream will index and replay past conversations
Architecture
your-project/
.brain/ Brain data (add to .gitignore)
db/ Kuzu embedded graph database
exports/ Visualization data
viz/ Cytoscape.js graph visualization
hooks/ Enforcement hooks (stable across upgrades)
config.json Type tiers, custom settings
.claude/
settings.local.json Hooks (auto-installed by brain init)
CLAUDE.md Brain instructions (auto-installed)
How It's Built
- Kuzu -- embedded graph database, no server
- Rich -- terminal formatting
- Click -- CLI framework
- Cytoscape.js -- graph visualization (bundled offline)
~3,500 lines of Python. Fully auditable. No magic.
Nothing leaves your machine. No cloud services. No telemetry. The only
optional external call is OpenAI for semantic search embeddings, and that's
opt-in via pip install 'xarc-brain[embeddings]'.
Roadmap
v0.1 (current): Core engine, Rich TUI, visualization, hooks, brain init, brain dream
Next:
- Graph diff (what changed since last session)
- Auto-dream on session boundaries (Claude Code Stop hook)
- Multi-agent graph sharing
- MCP server for native tool integration
Contributions welcome. See CONTRIBUTING.md.
How This Was Built
This project was built by CCL, an AI agent deployed on X-Arc's CCX platform. CCL manages operations, builds tools, and ships code across multiple projects. You can see CCL as a contributor on this repo.
Brain started as CCL's internal memory system. After 6 months of daily use (320 nodes, 975 edges, 5 signal types, 7 hygiene checks running nightly), CCL packaged and open-sourced it.
X-Arc deploys AI agents that ship real work. Manage it like a hire. It works like ten.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xarc_brain-0.2.2.tar.gz.
File metadata
- Download URL: xarc_brain-0.2.2.tar.gz
- Upload date:
- Size: 186.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30dbed05d6de23b64a2186f81532985d5191cc5336f79bbf3d6c569b26c9a6cb
|
|
| MD5 |
70f4953a02f2ca102f93ee3b251b2d0a
|
|
| BLAKE2b-256 |
d5ef5e5a6e08ec793dcfd87d1daedd2c23cdbd90abdad606c9a3cdf8c7fc629d
|
File details
Details for the file xarc_brain-0.2.2-py3-none-any.whl.
File metadata
- Download URL: xarc_brain-0.2.2-py3-none-any.whl
- Upload date:
- Size: 174.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a21a4b4070b598d4aa646be6d94f787cf177efb54b3c70ca83bb275ca126a9
|
|
| MD5 |
a10c1a04b1ba25046ae46ddb99369c2d
|
|
| BLAKE2b-256 |
2b4055c50dfbd9e1cd9114743aa5498c4b4e4d3ff26045c73c1f25d4278c6412
|