Skip to main content

schemabrain index

Reflects every user-visible table from the source database into the local SQLite store. Optionally enriches column descriptions via Claude Haiku 4.5 and computes local sentence embeddings so the MCP retriever can do semantic search.
Idempotent. Running against an unchanged schema is a no-op (~0.1s, zero LLM calls, zero embedder calls). Schema-changed tables are re-enriched and re-embedded selectively.

Source

One of these is required: The URL must use the postgresql+psycopg:// scheme.

Storage and embedding

Enrichment

--no-pii-classify emits a stderr warning on every run. It is a privacy-paranoid setting, not a performance setting — the classifier is heuristic, local, and fast.

Cost guards

Dry-run preview

The --dry-run estimate ignores --enable-sonnet tier routing and reports Haiku pricing only.

Output


What gets stored

For each table:
  • Full structural reflection (columns, types, nullability, defaults, primary keys, foreign keys).
  • One LLM-written column description per column, when enrichment is enabled (~$0.0003/col on Haiku 4.5).
  • One local sentence embedding per description (BAAI/bge-small-en-v1.5, ~67MB ONNX, ~10ms/col warm), when embedding is enabled.
  • Heuristic PII tags per column, when classification is enabled.
The store is the input every other command reads from. serve, entities, metrics, joins, inspect, check, audit, and dashboard all operate against the SQLite file index writes.

Examples

Standard run

Cost-free dry run

Preview the cost of catching up after a long pause

CI smoke without LLM

Cryptic schema, accept higher cost


Exit codes


schemabrain init

Wizard that runs index plus everything else.

schemabrain check

Detect drift after a schema migration.

schemabrain eval

Score retrieval quality against a golden set.

schemabrain inspect

Browse the store without re-indexing.