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
| Flag | Description |
|---|---|
--yes, -y | Skip confirmation prompts (for CI). |
--json | Structured stdout for preview, state, history. |
--phase=<phase> | Run only the named phase (setup / monitoring / backup / teardown). |
Environment
| Variable | Description |
|---|---|
DATABASE_URL | Default connection string used by <DatabaseTarget> when no url prop is given. |
DEBUG=db-x | Enable debug logging. |
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | Plan or apply failed. |
| 2 | Bad arguments / unknown command. |
| 130 | Cancelled (SIGINT). |