Skip to content

Reference

CLI reference

Every gbrain subcommand, flag, and exit-code, grouped by domain.

gbrain is a single binary that exposes the entire brain over a Unix-style CLI. This page documents every subcommand grouped by domain. For the authoritative flag list on your installed version, run gbrain --help or gbrain <command> --help.

These flags apply to every subcommand and may appear before or after the command name.

FlagDescription
--db <PATH>Database path. Env: GBRAIN_DB. Default: ./brain.db.
--model <ALIAS|HF_ID>Embedding model. Env: GBRAIN_MODEL. Default: small. Recognized aliases: small, base, large, m3. Any other value is treated as a Hugging Face model ID (online build only).
--jsonEmit JSON instead of human-readable text. Most commands honor this.
--help, -hPrint help. Works at root or per-command.
--version, -VPrint version and exit.

Create a new brain database. Records the active embedding model in brain_config so subsequent opens validate against it.

Terminal window
gbrain init ~/brain.db
gbrain init ~/brain-large.db --model large # online build only

Read a page by slug. Slugs may be collection-qualified (<collection>::<slug>) when more than one collection is attached.

Terminal window
gbrain get people/alice
gbrain get research::people/alice

Write or update a page from stdin. For updates, supply --expected-version to enable optimistic concurrency (OCC). On a conflict the call fails and you must re-fetch before retrying.

Terminal window
cat updated.md | gbrain put people/alice --expected-version 7
FlagTypeDefaultNotes
--expected-version <N>i64noneRequired for safe updates; absent means “create only”.

List pages with optional filters.

FlagTypeDefault
--wing <NAME>stringnone
--type <TYPE>stringnone
--limit <N>u3250

FTS5 full-text search. By default the input is sanitized so natural-language queries with ?, !, etc. work without escaping. Pass --raw to send the query verbatim and use FTS5 expert syntax (quoted phrases, boolean operators, prefix wildcards).

FlagTypeDefault
--wing <NAME>stringnone
--limit <N>u3210
--rawflagfalse
Terminal window
gbrain search "river ai"
gbrain search '"local-first" AND (sqlite OR fts5)' --raw

Hybrid retrieval: FTS5 + vector similarity, fused via set-union. Use --depth auto to enable progressive expansion — the engine grows the context window until the token budget is exhausted.

FlagTypeDefault
--depth <auto|''>stringauto
--limit <N>u3210
--token-budget <N>u324000
--wing <NAME>stringnone
Terminal window
gbrain query "who is interested in offline-first knowledge systems?"

Single-file ingestion with SHA-256 idempotency. Re-running on the same file is a no-op unless --force is set.

FlagTypeDefault
--forceflagfalse

Batch import a markdown directory. Page types are inferred from a PARA-style folder layout (projects/, areas/, resources/, archives/).

FlagTypeDefault
--validate-onlyflagfalse

Export every page to a markdown directory.

FlagTypeDefault
--rawflagfalse
--import-id <ID>stringnone

--raw writes byte-for-byte the original ingested content (preserves frontmatter ordering and whitespace); without it, the export is the canonicalized form.

Generate or refresh embeddings.

FlagTypeDefault
--allflagfalse
--staleflagfalse
Terminal window
gbrain embed people/alice # one page
gbrain embed --stale # only re-embed pages whose chunks changed
gbrain embed --all # rebuild every embedding

Create a typed temporal cross-reference. Both ends must exist as pages.

FlagTypeDefault
--relationship <NAME>stringrelated
--valid-from <DATE>ISO-8601none (open-start)
--valid-until <DATE>ISO-8601none (open-end)

Close an open temporal link interval by setting valid_until.

FlagType
--valid-until <DATE> (required)ISO-8601

List outbound links from a page, with link IDs.

FlagTypeDefault
--temporal <current|all>stringcurrent

Remove a cross-reference entirely. With --relationship, only that edge is removed.

FlagTypeDefault
--relationship <NAME>stringnone (remove all)

List inbound links to a page.

FlagTypeDefault
--temporal <current|all>stringcurrent

N-hop neighbourhood graph from a page (BFS over links, with temporal filtering).

FlagTypeDefault
--depth <N>u322
--temporal <current|all>stringcurrent

Manage tags. Both --add and --remove are repeatable.

Terminal window
gbrain tags people/alice # list
gbrain tags people/alice --add infra --add ops # add two tags
gbrain tags people/alice --remove ops # remove one

Show timeline entries for a page.

FlagTypeDefault
--limit <N>u3220

Append a structured timeline entry. --date and --summary are required.

FlagTypeRequired
--date <DATE>ISO-8601yes
--summary <TEXT>stringyes
--source <REF>stringno
--detail <TEXT>stringno

Run contradiction detection on a single page or, with --all, every page. Heuristic; backed by the assertions table.

FlagType
--allflag
--type <TYPE>string

List unresolved knowledge gaps. By default only unresolved gaps are returned.

FlagTypeDefault
--limit <N>u3220
--resolvedflagfalse

Brain integrity checks. With no flags, all checks run.

FlagType
--allflag
--linksflag
--assertionsflag
--embeddingsflag

Checkpoint the SQLite WAL into a single file. Safe to run while no writers are active.

Brain statistics: page count, link count, gap count, active embedding model.

Terminal window
gbrain stats
gbrain stats --json

collection groups all vault-sync subcommands. See Manage collections for end-to-end guidance.

Terminal window
gbrain collection add notes ~/Documents/Obsidian --writable
gbrain collection list
gbrain collection info notes
gbrain collection sync notes
gbrain collection ignore add notes "_attachments/**"
gbrain collection quarantine list notes

Subcommands: add · list · info · sync · restore · restore-reset · reconcile-reset · ignore add|remove|list|clear · quarantine list|export|discard|restore.

Read or write runtime config keys.

Terminal window
gbrain config get default_token_budget
gbrain config set default_token_budget 6000
gbrain config reset default_token_budget

Subcommands: get <KEY> · set <KEY> <VALUE> · reset <KEY>.

See Configuration for the full key list.

Start the MCP stdio server. Connects any MCP client to this brain.

Terminal window
GBRAIN_DB=~/brain.db gbrain serve

serve ships on macOS and Linux today; Windows parity is on the roadmap.

Skills are agent-shaped markdown files embedded in the binary, extractable to ~/.gbrain/skills/, and overridable from the working directory.

Terminal window
gbrain skills list # show resolution order
gbrain skills doctor # verify hashes; report shadowing

Subcommands: list · doctor.

Invoke a raw MCP tool from the CLI. Useful for debugging and for shell scripts.

Terminal window
gbrain call brain_search '{"query":"alice","limit":3}'

JSONL streaming mode. Reads one JSON request object per line on stdin, writes one response per line on stdout. Designed for shell pipelines and lightweight harnesses.

Print the version and the brain’s schema-version state.

CodeMeaning
0Success
1General failure (validation, IO, business-rule violation)
2Argument or flag parsing error

When --json is set, errors are also emitted as a JSON object with an error field on stderr.