Skip to main content

CLI reference

Experimental

The db-x CLI runs today, but DB-X is an early prototype — don't point it at a database you care about. The @db-x/* packages aren't on npm yet; build from source (see Install).

Commands

Shipped today:

db-x preview <file> Render JSX, diff against state, print the plan
db-x apply <file> Render, diff, execute changes, persist state
db-x destroy <file> Tear down everything in state (reverse order)
db-x describe <file> Emit the full schema + state as JSON
db-x refresh <file> Read live drift back into state
db-x state Print the contents of .dbx/state.json

On the roadmap, not yet implemented:

db-x preview --shadow <file> Run the DDL on an ephemeral copy, report locks/timings (v0.2)
db-x snapshot create [--label "..."] (v0.1)
db-x snapshot list
db-x history
db-x diff <revA> <revB>
db-x restore [--to <label|id|rev>]
db-x mcp <file> MCP server: describe / explain / graph / preview (v0.3)
db-x types <file> Emit TypeScript / Drizzle / sqlc types (v0.4)

Flags

FlagDescription
--yes, -ySkip confirmation prompts (for CI).
--jsonStructured stdout for preview, state, history.
--phase=<phase>Run only the named phase (setup / monitoring / backup / teardown).

Environment

VariableDescription
DATABASE_URLDefault connection string used by <DatabaseTarget> when no url prop is given.
DEBUG=db-xEnable debug logging.

Exit codes

CodeMeaning
0Success.
1Plan or apply failed.
2Bad arguments / unknown command.
130Cancelled (SIGINT).