Skip to main content

brain

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:

  1. Scan -- query the graph for context before responding
  2. Respond -- with full awareness of entities, relationships, and history
  3. 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.

brain scan


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).

brain signals


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.

CCL's production brain -- 320 nodes, 975 edges

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 node
  • brain write edge --json-data '<json>' -- create or update an edge
  • brain write batch --file <path> -- bulk import operations

Delete group

  • brain delete node --id <id> -- archive a node
  • brain delete edge --from <id> --to <id> --verb '<verb>' -- end an edge

Query group

  • brain query cypher "<cypher>" -- raw Cypher (use --read-only for safety)
  • brain query depends-on <id> -- what this node depends on
  • brain query blast-radius <id> -- what depends on this node
  • brain query chain <id> -- full dependency chain
  • brain query changed-since <date> -- nodes modified since
  • brain 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 them
  • brain embed status -- coverage report

Hygiene group

  • brain hygiene dedup -- find potential duplicates
  • brain hygiene orphans -- disconnected nodes
  • brain hygiene verbs -- verb usage audit
  • brain hygiene completeness -- schema rule violations
  • brain hygiene file-paths -- broken / missing file_path checks
  • brain hygiene content-drift -- brain content vs source file drift
  • brain hygiene readiness -- operational readiness checks

Config group

  • brain config show -- show current config
  • brain config add-type <type_name> <tier> -- register a custom type (tier: structural, operational, or temporal)

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 with No 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 xarc-memory
# brain init and brain dream will index past Claude Code 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.

x-arc.ai | GitHub

Metadata

Release files for xarc-brain 0.3.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 xarc-brain 0.3.0
File Size Uploaded Provenance
xarc_brain-0.3.0.tar.gz 187.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for xarc-brain 0.3.0
File Interpreter ABI Platform
xarc_brain-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 362.7 kB

Release files / xarc_brain-0.3.0.tar.gz

Download URL xarc_brain-0.3.0.tar.gz
Size 187.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e7411dc574bb625e64824477762f32d239a3af046018a16e090eb9d9b2b64f9a
BLAKE2b-256 checksum
How to use checksums
99edfdd4def861c413ee656e6418627f49deb304249c18a4af60020edc53b434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / xarc_brain-0.3.0-py3-none-any.whl

Download URL xarc_brain-0.3.0-py3-none-any.whl
Size 174.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c70f1d8b0e217534c29b9d36e6e42d587bbca97de50ede410444fe946a3711dc
BLAKE2b-256 checksum
How to use checksums
c1eda3b6b979b5ee20525811ed154680ad14df5251f7593d5a60018ddcddf75c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for xarc-brain 0.3.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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