CLI reference
Binary:
schemabrain. Global flags: --version / -V, --verbose / -v (counted: -v → INFO, -vv → DEBUG). Default log level: WARNING (stderr only).--store-path (the SQLite store) and one of --source / --url-env (the Postgres source); --url-env VARNAME is preferred over --source URL because the URL never enters argv that way.
Global flags
| Flag | Purpose |
|---|---|
--version, -V | Print the installed schemabrain version and exit. |
--verbose, -v | Increase logging verbosity (stderr only). -v shows INFO; -vv shows DEBUG. Default WARNING. |
serve under Claude Desktop or another host that swallows CLI flags, set SCHEMABRAIN_LOG_LEVEL=DEBUG in the host’s env block instead.
Subcommand catalog
Setup and serve
schemabrain demo
Zero-setup showcase. Sample SaaS data, the firewall, and the dashboard — no API key.
schemabrain init
Activation wizard. Index, curate, wire your MCP host in one command.
schemabrain index
Reflect a Postgres schema into the local SQLite store.
schemabrain serve
Run the MCP server on stdio against the indexed store.
schemabrain dashboard
Boot the local read-only dashboard UI on 127.0.0.1.
Semantic-layer curation
schemabrain entities
list, apply, suggest, export, export-all.schemabrain metrics
list, apply, suggest, show, audit, export, export-all.schemabrain joins
list, apply, suggest, export, export-all.Project-level operations
schemabrain apply
Walk a project tree (
entities/, metrics/, joins/) and load every YAML.schemabrain diff
Drift check between an on-disk project tree and the store.
Observability and verification
schemabrain audit
list, verify — inspect and verify the hash-chained audit log.schemabrain tail
Stream MCP tool-call events from a running
serve process.schemabrain doctor
Health-check host config, store, and (optionally) source.
schemabrain check
Detect drift between persisted definitions and the live source schema.
schemabrain inspect
Browse the indexed schema + semantic-layer surface (no source needed).
Developer and niche commands
schemabrain eval, mine-queries, fixture-path, import
Retrieval scoring, query log mining, fixture paths, dbt manifest import.
Conventions you can rely on
Source URLs and credentials
Every command that touches Postgres accepts both--source URL and --url-env VARNAME. The two are mutually exclusive. The env-var form is preferred because the URL — and any embedded password — never appears in argv (visible to ps, shell history, journald). The positional and --source forms emit a deprecation warning when the URL contains a password.
postgresql+psycopg:// (psycopg v3). A bare postgresql:// will fail with ModuleNotFoundError: No module named 'psycopg2'.
Store path
The local SQLite store defaults to./schemabrain.db. Pass --store-path PATH to override. The directory is created on first write; subsequent runs are idempotent.
Cost caps
Every command that calls an LLM (index, entities suggest, metrics suggest, the LLM stages of init) enforces a hard USD cap. The default is conservative; override with --max-cost-usd or the per-command equivalent. Caps abort cleanly with a guided error — no partial writes.
Exit codes
| Code | Meaning |
|---|---|
0 | Success. |
1 | Drift / mismatch / non-fatal disagreement (e.g. diff found differences). |
2 | Operational error — bad input, missing flag, malformed config, unreachable source. |
3 | Cost cap exceeded. |
audit verify follows the same 0 / 1 / 2 convention specifically — 0 intact, 1 mismatch, 2 operational error.
Output streams
Human-readable output goes to stderr (so it can be redirected separately from machine-readable payloads). Commands that emit JSON do so on stdout, gated by a--json flag where applicable. Progress bars auto-disable when stderr is not a TTY (CI-friendly).
Auto-detected configuration
Several commands auto-resolve their inputs when the standard env vars are set:DATABASE_URL— not auto-detected on its own: the source URL is read via the--url-env <VAR>flag, which takes the name of the variable to read. These examples pass--url-env DATABASE_URL, so setDATABASE_URL(in your shell or.env) to match — or pass the name you use, e.g.--url-env SCHEMABRAIN_DATABASE_URL(the nameinitreads by default and writes into the host snippet). Pick one name and use it consistently.ANTHROPIC_API_KEY— required for any LLM-touching command; cost-free--no-enrich/--dry-runmodes skip the check.DBT_PROJECT_DIR—initwalks this (or the cwd, looking fordbt_project.yml) and auto-routes the curation stages through the dbt importer when found.SCHEMABRAIN_LOG_LEVEL— read when-v/-vvflags are not available (e.g.serveunder Claude Desktop).SCHEMABRAIN_EVENTS_PATH— overrides the default events JSONL path forserve+tail.SCHEMABRAIN_MAX_LLM_COST_USD— fallback cost cap when--max-cost-usdis not passed onsuggestcommands.SCHEMABRAIN_STUB_RESPONSE— used by--provider stubfor CI smoke tests.
.env file in the current working directory is also loaded automatically before any subcommand runs. Shell exports always win — .env only fills gaps.
Related
Setup
The end-to-end install walkthrough that uses these commands.
MCP tool reference
The twelve typed MCP tools
schemabrain serve exposes.Dashboard
The local UI launched by
schemabrain dashboard.Architecture
Where each command sits in the pipeline.