For engineers using the BrainBox CLI to connect sources and keep the Brain current.
Updated
The BrainBox CLI (@brainbox-labs/cli, Node 24 or later) signs you in with init or login, ingests databases, SQL files and documents in one step with ingest, keeps a docs folder current with sync, and archives reviewed deletes with prune. Step-by-step meta and repo commands remain for finer control, and dev start serves a local MCP server.
init signs you in through the browser (sign-up works too) and installs the plugin for the agent that ran it. login signs you in only. Use --no-browser over SSH.
npx -y @brainbox-labs/cli@latest init
npx -y @brainbox-labs/cli@latest whoamiingest takes one or more sources and runs the whole pipeline. sync keeps a docs folder in step. Both accept --org and --project (or BRAINBOX_ORG and BRAINBOX_PROJECT).
npx -y @brainbox-labs/cli@latest ingest postgres://user:pass@host/db ./sql/ --review
npx -y @brainbox-labs/cli@latest sync ./docs --namespace kb --dry-runNew and edited docs are ingested and unchanged ones skipped. Deleted files are never archived silently: on a terminal sync asks, and without one it reports pendingDeletes. --prune archives all of them; prune archives named keys. --transform runs a script over each doc, and --flat puts every page in one namespace.
npx -y @brainbox-labs/cli@latest prune kb%2Fold.mdtool runs one Brain tool, the same verbs as the SDK's brain.recall and brain.update, using your brainbox login, so a script can use a Brain right after init without minting an API key. The result is bare JSON on stdout, so it pipes into jq. --project is required (or BRAINBOX_PROJECT) and a project is never created. Read tools run as they are; tools that write (create_*, save_*, archive_*, retire_learning, report_context_gap, process_event) need --write. The call runs as whoever is signed in, and the server's permissions apply. Exit codes: 0 ok, 1 usage error or the tool failed, 2 not signed in, login expired or credentials refused (run brainbox login). Errors go to stderr and stdout stays empty on failure.
npx -y @brainbox-labs/cli@latest tool get_index --project support-brain
npx -y @brainbox-labs/cli@latest tool recall_wiki --project support-brain --args '{"q":"refund policy"}' | jq '.pages[].title'
npx -y @brainbox-labs/cli@latest tool create_learning --project support-brain --write --args-file learning.jsonFor finer control, stage with meta ingest, then commit, push, create and approve with repo. dev start serves the active layer as a local MCP server. Defaults come from BRAINBOX_API_KEY, BRAINBOX_API_URL, BRAINBOX_ORG and BRAINBOX_PROJECT (see Configuration and environment).
npx -y @brainbox-labs/cli@latest repo init --org "Acme" --project "Finance"
npx -y @brainbox-labs/cli@latest meta ingest db postgres://user:pass@host/db
npx -y @brainbox-labs/cli@latest repo commit -m "schema"
npx -y @brainbox-labs/cli@latest repo pushEach setting is resolved in order: a command-line flag, then an environment variable, then your brainbox login, then the default. For credentials that means --api-key, then BRAINBOX_API_KEY, then the token from brainbox login. For the API URL it means --api-url, then BRAINBOX_API_URL, then the URL stored by brainbox login, then https://ctx.brainbox-ai.app. BRAINBOX_ORG, BRAINBOX_PROJECT and BRAINBOX_TENANT are read from the environment too. Since 0.20.1 the CLI no longer reads a .env file from the folder you run it in. To load one, point BRAINBOX_ENV_FILE at it; variables already set in your shell take precedence over the file. If a script relied on a .env next to it, set BRAINBOX_ENV_FILE or export the variables.
BRAINBOX_ENV_FILE=./.env.brainbox npx -y @brainbox-labs/cli@latest whoami| Command | What it does |
|---|---|
| init | First-run setup: sign in, pick sample data or a project, install the plugin for Claude Code or Codex |
| login, logout, whoami | Sign in or up in the browser, revoke the token, show who is signed in (whoami exits 1 when not signed in) |
| ingest <source...> | Ingest a database, SQL files or documents and publish a new version in one step |
| sync <dir> | Keep a folder of docs in step with the Brain by stable key |
| prune <sourceKey...> | Archive specific synced pages without a prompt |
| tool <name> | Call any Brain tool from a script with your CLI login; bare JSON on stdout |
| demo olist | Copy the Olist sample Brain into your organization |
| meta ingest db|doc|dbt|mcp|nosql|skill | Stage or upload a single source type |
| repo init|clone|commit|push|pull|log|meta create|meta approve | Step-by-step version management |
| dev start, dev stop | Serve the active layer as a local MCP server (default port 3100) |
| profile preview <url> | Show locally what column profiling would upload; no API call |
| collect, recipe | Collect a source into local markdown; browse, install and check context recipes |