Build and deploy from your terminal
The appbricxcommand lets you, a script, or any coding agent with a shell do everything the web app and MCP server do: create a project, check and apply your app's contract, test it as each user, look at the data, deploy, and operate the running app (SQL, rows, schema, snapshots, rollbacks, workflow runs, logs, secrets). It needs Node.js 20 or newer and has no dependencies.
When you would use it
- In CI. Check and verify on every pull request, and deploy only when verify passes. Exit codes tell your pipeline what happened.
- With your app in git. Keep the contract as
appbricx.jsonnext to your code, review changes like any other file, and apply them from the terminal. - With an agent that has a shell but no MCP support.
Each command is one call to the developer HTTP API, so the CLI gives the same answers as MCP and HTTP.
@appbricx/cli) will be published to npm soon. Until then, run it from a clone of the repository.Install from the repo
git clone https://github.com/Naveenbhargav-m/appbricx-examples
node appbricx-examples/cli/bin/appbricx.mjs helpTo get an appbricx command on your PATH:
cd appbricx-examples/cli
npm link
appbricx versionThe examples below assume appbricx is on your PATH.
Sign in
With your browser (the default):
appbricx login
# self-hosted: appbricx login --api https://your-host/api- The CLI opens Appbricx in your browser. Sign in, pick the workspace, click Authorize, and come back to the terminal.
- It stores a one-hour access token and a 90-day refresh token in
~/.config/appbricx/config.json(file mode 0600) and refreshes them by itself. The refresh token changes on every use. - The CLI shows up under Authorized agents in Workspace settings, Coding agents. Revoke it there, or run
appbricx logout. - No browser on this machine?
appbricx login --no-browserprints the URL instead. The sign-in finishes on ahttp://127.0.0.1port on the machine running the CLI.
With a token (CI, headless machines)
Create a token in Workspace settings, Coding agents, then:
appbricx login --token apx_pat_...
# or skip login: export APPBRICX_API=https://appbricx.com/api APPBRICX_TOKEN=apx_pat_...Or with your email and password, which mints a token for you:
appbricx login --email you@example.com --password '...'
# optional: --workspace <workspace-id> (default: your first workspace)- A password login mints a token named
cli YYYY-MM-DDwithread,applyanddeployscopes. Revoke it like any other token. - Accounts with multi-factor sign-in can't use the password login. Use the browser sign-in or
--token.
Commands
| Command | What it does |
|---|---|
login | Sign in with the browser, or save a token (--token) or a password login (--email and --password). --api for self-hosted |
logout | Revoke the browser sign-in and forget the saved tokens |
whoami | The signed-in user, scopes and workspaces |
projects | List projects |
create <name> | Create a project and link this directory to it |
link <project-id> | Link this directory to an existing project |
pull [file] | Write the project's contract to ./appbricx.json (or file) |
check [file] | Normalize and report; no changes |
apply [file] [--force] | Build the dev environment from the contract |
patch <ops.json> [--dry-run] | Apply typed edit ops from a JSON file (an array or one op) |
verify | The verify report |
query <table> [--where col=value ...] [--limit n] | Rows from the dev database (--where repeats) |
logs [--workflow id] [--limit n] | Workflow runs and notifications |
deploy [--subdomain <name>] [--skip-verify] [--preview] | Publish to production (or the preview environment). Runs verify first |
schema [--env dev|prod] | The real database schema: tables, columns, keys, indexes, triggers, views, functions, and which tables the contract manages (read) |
sql "<sql>" | sql --file <f.sql> [--env] | Run SQL like the builder's SQL editor. Reads need read; writes need apply (dev) or deploy (prod) |
rows <insert|update|delete> <table> [--data json|@file] [--id id] [--ids a,b] [--patch json|@file] [--as admin|role] [--env] | Edit rows through the app's rules, RLS and change events (apply on dev, deploy on prod) |
snapshots [list | create | restore <id>] [--env] | Database snapshots (create needs apply, restore needs deploy) |
deploys [list | rollback <deployment-id>] | Deploy history; roll back what's live (deploy) |
run workflow <id> [--input json|@file] [--as role] [--env] | run get <run-id> | run dead-letters | run replay [job-id ...] | Run a workflow now (waits up to 30s for the result), read a run, list and replay dead letters |
tail <events|requests|errors> [--since 15m] [--limit n] [--env] | Recent change events and topic messages, requests or errors |
secrets [list | set <name> <value|-> | delete <name>] [--env dev|prod|all] | The app's secrets; list shows names only. - reads the value from stdin (set and delete need apply and a workspace owner or admin) |
mcp-config | Print an .mcp.json entry for this project |
docs | Print the contract guide (markdown) |
help, version | Usage and version |
The CLI has no screenshot or component-check command. Use the MCP tools or the HTTP API for those.
The operate commands (schema through secrets) take --env dev (the default) or --env prod. Every prod write takes a database snapshot first and prints its id, so appbricx snapshots restore <id> undoes it. Indexes, views, functions, triggers and extra tables or columns you add with sql are kept by apply and deploy; schema marks them as hand-made.
A typical session
mkdir field-desk && cd field-desk
appbricx create "Field Desk" # links ./.appbricx/project.json
appbricx docs > GUIDE.md # the contract reference
# write ./appbricx.json
appbricx check
appbricx apply # prints the demo sign-ins
appbricx verify
appbricx query job --where status=open --limit 10
appbricx deploy
appbricx tail errors --env prod --since 1h
appbricx sql "CREATE INDEX job_due ON job (due)" --env prod # snapshot first
appbricx schema --env prodFiles
| Path | Holds |
|---|---|
~/.config/appbricx/config.json | { api, token, refreshToken?, expiresAt?, oauth? } |
./.appbricx/project.json | The linked project |
./appbricx.json | The contract you edit |
Environment variables
These override the files. Use them in CI and agent sessions.
| Variable | Meaning |
|---|---|
APPBRICX_API | API base URL: https://appbricx.com/api |
APPBRICX_TOKEN | An access token (apx_pat_…) |
APPBRICX_PROJECT | Project id, instead of the directory link |
APPBRICX_CONFIG | Path of the config file |
export APPBRICX_API=https://appbricx.com/api
export APPBRICX_TOKEN=apx_pat_...
export APPBRICX_PROJECT=3f2c9a10-...
appbricx verifyGlobal flags
--json: print the server's raw JSON instead of the human summary. On an error, the error body is printed to stdout.--project <id>: use this project instead of the link orAPPBRICX_PROJECT.--help: usage.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | The server said no (invalid contract, red verify, missing scope, API error), or check found errors, or verify did not pass |
| 2 | Usage error (missing argument, not signed in, no linked project), or no command given |
mcp-config
Prints an MCP server entry for Claude Code's .mcp.json, pinned to the linked project (or --project). It has no token: the agent signs in with the browser the first time it connects. Add --token-header for CI, which adds "headers": { "Authorization": "Bearer ${APPBRICX_TOKEN}" } (the token itself stays out of the file):
$ appbricx mcp-config
{
"mcpServers": {
"appbricx": {
"type": "http",
"url": "https://appbricx.com/api/mcp?project=3f2c9a10-..."
}
}
}With --token-header, export APPBRICX_TOKEN in the shell that starts your agent. Cursor uses ${env:APPBRICX_TOKEN} instead; see the coding agents quickstart.