docs / reference
CLI reference
Every botdb command, argument and option.
botdb [--home <dir>] [-F json|table|csv] [-q] <command> [args]
Run botdb <command> --help for the same information in a terminal.
Global options
| Option | Description |
|---|---|
--home <dir> |
botdb’s data directory. Env BOTDB_HOME. Default ~/.botdb. |
-F, --format <f> |
Output format: json, table or csv. Env BOTDB_FORMAT. Default: table on a terminal, json otherwise. |
-q, --quiet |
Suppress informational messages on stderr. |
-V, --version |
Print the version. |
Output and errors
- Queries print rows: a table on a terminal, a JSON array of row objects otherwise, CSV with
-F csv. An empty result prints(no rows)to stderr in table format. - Writes print
{"ok":true,"changes":N}as JSON, orok (N rows changed)in table format. - JSON is compact when stdout is not a terminal and indented when it is.
- Errors exit with status 1. When the format is JSON or stderr is not a terminal, they print JSON to stderr; otherwise
error:andhint:lines.
{"error":{"code":"integer_primary_key","message":"...","hint":"..."}}
The code is stable and the hint says how to fix the problem.
Selecting a database
-d, --db <DB> takes a database name (case-insensitive) or an id prefix of at least 4 hex characters. Without it, botdb picks:
BOTDB_DB- the database in
BOTDB_INVITE, if set - the default set with
botdb use(the first database you create or join becomes the default) - the only database, if there is exactly one
Times
Options that take a <time> (--at, --since) accept:
| Format | Example | Meaning |
|---|---|---|
| Relative | 90s, 30m, 2h, 3d, 1w |
Seconds, minutes, hours, days or weeks ago |
| Now | now |
The current time |
| Unix milliseconds | @1791734400000 |
Exact instant |
| RFC 3339 | 2026-10-01T14:30:00Z |
Exact instant |
| Date | 2026-10-01 |
Local midnight |
| Date and time | 2026-10-01 14:30, 2026-10-01 14:30:15 |
Local time (T also works as the separator) |
Remotes
| Form | Type |
|---|---|
http://host:port, https://host |
Relay |
~/path, /path, file:///path |
Shared folder |
cloud |
botdb cloud (its URL is stored) |
Any other scheme:// is rejected with invalid_remote.
Setup
botdb login
botdb login [--restore] [--remote <url|path|cloud>]... [--no-remote] [--phrase-stdin]
Creates a vault on this device, or restores an existing one.
Without --restore, botdb asks for a default remote, generates a vault and prints its 24-word recovery phrase. On a terminal it offers botdb cloud first, then the cloud folders it detects (iCloud Drive, Dropbox, Google Drive, OneDrive), each with a botdb subfolder, plus u to enter your own relay URL or another folder path and n for none. Without a terminal it doesn’t prompt: it uses the --remote values (botdb cloud if there are none, nothing with --no-remote) and prints {"vault","phrase","remotes"} as JSON. Choosing botdb cloud creates a free account for the vault; its token is stored in the vault, so your other devices use the same account.
With --restore, botdb reads the recovery phrase (from BOTDB_PHRASE, stdin, or a hidden prompt), asks where the vault syncs, pulls the vault catalog and then every database in it. It prints the restored databases and any remote errors.
| Option | Description |
|---|---|
--restore |
Restore an existing vault from its recovery phrase. |
--remote <url|path> |
Default remote, instead of the prompt. Repeatable. cloud is botdb cloud. |
--no-remote |
No default remote. Databases stay on this device. |
--phrase-stdin |
Read the recovery phrase from stdin. |
Databases joined before logging in are added to the vault. A device that already has a vault fails with already_logged_in.
botdb logout
botdb logout --yes
Forgets the vault key on this device. Databases stay on disk; log back in with botdb login --restore. Without --yes it fails with confirm.
botdb vault
botdb vault phrase [--yes]
botdb vault verify [--phrase-stdin]
botdb vault status
| Subcommand | Description |
|---|---|
phrase |
Print the recovery phrase. Asks for confirmation on a terminal; elsewhere --yes is required. |
verify |
Type the phrase back to confirm you saved it. Reads stdin with --phrase-stdin or without a terminal. Fails with phrase_mismatch. |
status |
Vault id, where the key is stored (keychain, file or env), whether the phrase was verified, default remotes and the number of databases. |
Databases
botdb create
botdb create <name> [--remote <url|path>]... [--no-remote]
Creates a database with a new random id and key and adds it to the vault. Requires a vault (not_logged_in otherwise). It syncs to the default remotes unless you pass --remote (repeatable) or --no-remote.
Names use letters, digits, -, _ and ., start with a letter or digit, and are at most 64 characters.
botdb ls
botdb ls [--all]
Alias: botdb list. Lists databases with their id, remotes and notes (read-only, not in vault, in trash); * marks the default. --all includes databases in the trash.
botdb use
botdb use <db>
Sets the default database for commands that take -d.
botdb rename
botdb rename <db> <new-name>
Renames a database. The id, keys and data stay the same.
botdb rm
botdb rm <db>
Moves a database to the trash. Trashed databases are purged locally after 30 days.
botdb trash
botdb trash ls
botdb trash restore <db>
botdb trash empty [--remote] [--yes]
| Subcommand | Description |
|---|---|
ls |
List databases in the trash. |
restore <db> |
Restore a database. Fails with exists if another database now has its name. |
empty |
Permanently delete the local data of trashed databases. Requires --yes. --remote also deletes their data from remotes (for databases you can write). |
Data
botdb sql
botdb sql [-d <db>] [SQL] [-f <file>] [-p <value>]... [--params <json>] [--readonly]
Alias: botdb q. Runs SQL in SQLite’s dialect. The SQL comes from the argument, -f, or stdin (also when the argument is -). Several statements run atomically: all or nothing.
| Option | Description |
|---|---|
-d, --db <db> |
Database. |
SQL |
Statement(s) to run, or - for stdin. |
-f, --file <file> |
Read SQL from a file. |
-p, --param <value> |
Value for a positional ?. Repeat in order. JSON numbers, true, false and null are typed; anything else is text. |
--params <json> |
Parameters as JSON: an array for ?, an object for :name. Can’t be combined with -p. |
--readonly |
Reject anything that would modify the database. |
Parameters only work with a single statement (params_multi_statement). The output shows the last statement that returned rows; if none did, the total number of changed rows. On a database shared with you read-only, writes fail with read_only.
botdb sql "SELECT title FROM watched WHERE rating >= ?" -p 4
botdb sql "UPDATE watched SET rating = :r WHERE id = :id" --params '{"r": 5, "id": "a1b2"}'
botdb sql -f migrations/002_add_genre.sql
echo "SELECT count(*) AS n FROM watched" | botdb sql
See SQL support and table rules.
botdb schema
botdb schema [-d <db>] [table]
Shows tables (columns, row counts and CREATE statements), indexes and views, or a single table. Local-only tables are marked.
botdb history
botdb history [-d <db>] [table] [--pk <value>] [--since <time>] [--limit <n>]
Lists recorded changes, newest first: inserts, deletes, cell values and schema changes, with the time and the device that made them.
| Option | Description |
|---|---|
table |
Only changes to this table. |
--pk <value> |
Only changes to the row with this primary key. Use a JSON array for composite keys. |
--since <time> |
Only changes after this time. |
--limit <n> |
At most n entries. Default 50. |
botdb revert
botdb revert [-d <db>] --at <time> [--table <t>]
Restores the database, or one table, to its state at <time>. botdb replays the change log up to that time, compares it with the current data and writes the difference as new changes, so the revert syncs, appears in history and can itself be reverted.
- Tables dropped since then are recreated (with a
_restoredsuffix if the name is taken). - Only columns that still exist are restored.
- A device that was bootstrapped from a snapshot without history can’t go back further than that snapshot (
history_unavailable).
botdb export
botdb export [-d <db>] [--type json|csv|sqlite] [--table <t>] [--out <file>]
Exports data unencrypted.
| Option | Description |
|---|---|
--type <t> |
json (default): {"table": [rows...]}. csv: one table. sqlite: a plain SQLite file without botdb’s bookkeeping. |
--table <t> |
Export one table. Required for CSV. |
--out <file> |
Output file. Default: stdout, or <name>.sqlite for SQLite. Existing SQLite files aren’t overwritten. |
botdb import
botdb import [-d <db>] <file> --table <t> [--type csv|json]
Inserts rows from a file into an existing table, in one transaction. The type defaults to JSON for .json files and CSV otherwise. CSV needs a header row of column names (values are imported as text); JSON must be an array of objects.
Sync and sharing
botdb sync
botdb sync [-d <db>] [--watch]
Pulls and pushes now. Without -d, it syncs the vault catalog and every database. Sync also runs automatically (see Automatic sync).
| Option | Description |
|---|---|
--watch |
Keep syncing until interrupted. Relays are long-polled; output is printed when something changes. |
Fails with offline if no remote could be reached, or sync_failed if every remote failed.
botdb status
botdb status [-d <db>]
Shows the replica file and size, the number of changes (total and made on this device), the newest local snapshot and, per remote, pending changes, last pull, last push and last error.
botdb invite
botdb invite [db] [--read-only]
Prints an invite (bdb1_...) with the database’s keys and remotes. Invites are secrets. --read-only omits the write key; members with read-only access can only create read-only invites. As JSON: {"invite","database","read_only"}. Warns if the database has no remote.
botdb join
botdb join <invite> [--as <name>] [--remote <url|path>]...
Joins a database from an invite and downloads it.
| Option | Description |
|---|---|
--as <name> |
Local name. Defaults to the invite’s name (with a suffix if it’s taken). |
--remote <url|path> |
Use these remotes instead of the invite’s. Repeatable. |
join works without a vault: the database is kept in config.json (shown as not in vault) and added to the vault at the next botdb login. Joining a database you already have upgrades its key if the invite is newer or grants write access.
botdb rotate-key
botdb rotate-key [db]
Rotates a database’s keys. Remotes switch to the new keys and drop data from older key epochs, then everything is re-uploaded under the new key with a fresh snapshot. Your own devices pick up the new key through the vault catalog. Old invites stop working; re-invite the members you keep. Read-only members can’t rotate keys. See Sharing and invites.
botdb remote
botdb remote ls [-d <db>]
botdb remote add <url|path> [-d <db> | --default]
botdb remote rm <url|path> [-d <db> | --default]
botdb remote add cloud syncs through botdb cloud and creates an account if this vault doesn’t have one yet. Without --default, add and rm act on -d or the default database. With --default they change the default remotes for new databases. Defaults are stored in the vault, so your other devices use them too, and the vault catalog itself syncs to them. Existing databases keep their remotes. remote ls without -d lists the defaults and every database.
Backups
botdb backup
botdb backup create [--out <file>]
botdb backup restore <file> [--phrase-stdin]
botdb backup restore --remote [-d <db>] [--at <time>]
botdb backup ls [--remote] [-d <db>]
| Subcommand | Description |
|---|---|
create |
Write an encrypted archive of every database with a local copy (including trashed ones), their keys and full history. Default file: botdb-backup-<YYYYMMDD-HHMMSS>.botdb. Won’t overwrite. |
restore <file> |
Restore an archive or merge a local .snap snapshot. Archives need a vault on this device; --phrase-stdin reads the phrase of the vault that made the archive, if it’s a different one. |
restore --remote |
Download the newest daily backup a remote kept (with --at, the newest taken at or before that time) and merge it in like a .snap file. -d vault restores the vault catalog. It prints the botdb revert command that rolls the data back to the backup’s moment. |
ls |
List automatic local snapshots. With --remote, list the daily backups your remotes keep (botdb cloud keeps them; folders don’t). |
See Backups and recovery.
Servers and agents
botdb relay
botdb relay [--host <ip>] [--port <port>] [--data <dir>] [--token <t>] [--max-db-bytes <n>] [--retention-days <n>]
Runs a relay server. Put it behind a TLS reverse proxy.
| Option | Env | Default | Description |
|---|---|---|---|
--host <ip> |
BOTDB_RELAY_HOST |
127.0.0.1 |
IP address to listen on. Use 0.0.0.0 in Docker or behind a proxy on another host. |
--port <port> |
PORT |
8787 |
Port. |
--data <dir> |
BOTDB_RELAY_DATA |
<home>/relay |
Data directory. |
--token <t> |
BOTDB_RELAY_TOKEN |
Require this token to register new databases. | |
--max-db-bytes <n> |
BOTDB_RELAY_MAX_DB_BYTES |
Storage limit per database, in bytes. | |
--retention-days <n> |
BOTDB_RELAY_RETENTION_DAYS |
7 |
Days to keep batches after a snapshot covers them. |
Logging uses BOTDB_LOG (a tracing filter, default info). See Self-hosting a relay.
botdb mcp
botdb mcp
botdb mcp install [--client all|claude|opencode|codex|cursor|agents]
botdb mcp runs the MCP server on stdio. install registers it with agent clients; the default all only touches clients whose config directory exists. See Using with agents.
botdb skill
botdb skill
botdb skill install [--client all|claude|opencode|codex|cursor|agents] [--dir <dir>]
botdb skill prints the agent skill (SKILL.md, embedded in the binary). install writes it for agent clients, or to <dir>/botdb/SKILL.md with --dir. See Using with agents.
botdb cloud
botdb cloud [status]
botdb cloud signup
Shows your botdb cloud account: plan, databases used out of the plan’s limit, encrypted storage per database. signup creates the account explicitly; botdb login and botdb remote add cloud already do it. See botdb cloud.
botdb doctor
botdb doctor
Checks the vault, whether the recovery phrase was verified, the default remotes, whether every remote is reachable, and for each database: remotes, local copy, unsynced changes, sync errors and the age of the newest local snapshot. Each check is ok, warn or error, with a hint.
botdb completions
botdb completions <shell>
Prints a shell completion script for bash, elvish, fish, powershell or zsh.