Reference · CLI

BrainBox CLI reference: init, login, ingest, sync and more (0.20)

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.

  • Run it with npx, or install it globally.
  • init signs you in and installs the plugin; login signs you in only.
  • sync never archives deletes silently; prune applies the ones you approve.

Sign in and first run

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 whoami

The two commands you use most

ingest 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-run

Sync and prune

New 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.md

Script your Brain

tool 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.json

Step by step, and locally

For 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 push

Configuration and environment

Each 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
Commands (0.20.1)
CommandWhat it does
initFirst-run setup: sign in, pick sample data or a project, install the plugin for Claude Code or Codex
login, logout, whoamiSign 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 olistCopy the Olist sample Brain into your organization
meta ingest db|doc|dbt|mcp|nosql|skillStage or upload a single source type
repo init|clone|commit|push|pull|log|meta create|meta approveStep-by-step version management
dev start, dev stopServe 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, recipeCollect a source into local markdown; browse, install and check context recipes

FAQ

How do I install the CLI?
Run it without installing as npx -y @brainbox-labs/cli@latest <command>, or install it globally with npm install -g @brainbox-labs/cli. It needs Node 24 or later.
Where are credentials stored?
brainbox login stores a token in ~/.brainbox/credentials.json (mode 0600), used by every command unless you pass --api-key or set BRAINBOX_API_KEY. brainbox logout revokes it.
Does the CLI read my .env file?
Not automatically since 0.20.1. Set BRAINBOX_ENV_FILE to the path of the file you want loaded, or export the variables in your shell.
How do I sign in over SSH?
brainbox login --no-browser prints the sign-in URL.
How do I call the Brain from a shell script?
Use brainbox tool <name> --project <name>, with --args or --args-file for arguments. It uses your brainbox login, prints bare JSON, and needs --write for tools that write. Exit code 2 means you are not signed in.
What replaced the repo init flow?
ingest and sync cover the common cases. The step-by-step repo and meta commands still exist for finer control.

Give your agents a brain.

Sign in and ask your first question.

Book a Demo