Skip to content

CLI Reference

OptionShortEnvDefaultDescription
--version-vShow version and exit
--config <PATH>DBWARD_CONFIGConfig file path (standalone mode)
--merge-globalfalseMerge global config when —config is set
--database <NAME>DBWARD_DATABASETarget database
-e, --environment <ENV>-eDBWARD_ENVTarget environment
--format <FMT>humanOutput format: human, json, quiet
--allow-insecureDBWARD_ALLOW_INSECUREfalseAllow HTTP connections to non-local servers. Suppresses transport security warnings. Does not bypass OIDC+HTTP rejection.
--yes-yDBWARD_YESfalseSkip interactive confirmation prompts. Env accepts 1, true, or yes.

Execute a SQL query through the approval workflow.

Terminal window
dbward execute "SELECT * FROM users LIMIT 10"
dbward execute -e production --database app "DELETE FROM sessions WHERE expired = true"
dbward execute --emergency --reason "outage fix" "UPDATE config SET v = 'x'"
OptionDefaultDescription
<SQL> (positional)Required. SQL statement
--emergencyfalseBreak-glass bypass (requires —reason)
--allow-ddlfalseAllow DDL in emergency mode (requires —emergency)
--reason <TEXT>Reason for this request
--output <PATH>Save result to file
--no-result-storefalseDo not store query result on server. Request metadata and SQL text are always retained for audit.
--result-format <FMT>tableDisplay format: table, json, csv, vertical
--timeout <SECS>Max wait time in seconds
--idempotency-key <KEY>Deduplication key
--share-with <SELECTOR>Share result (repeatable, e.g. group:team)
--ticket <ID>Metadata: ticket identifier
--repo <URL>Metadata: repository URL

Manage requests.

Terminal window
dbward request list
dbward request list --status pending --pending-for-me
OptionDefaultDescription
--limit <N>Max results
--status <STATUS>Filter by status
--pending-for-mefalseOnly show requests I can approve
--user <ID>Filter by requester
Terminal window
dbward request show <ID>
Terminal window
dbward request approve <ID>
dbward request approve <ID> --comment "Verified"
OptionDescription
--comment <TEXT>Approval comment
Terminal window
dbward request reject <ID> --reason "Add WHERE clause"
OptionDescription
--reason <TEXT>Rejection reason (alias: --comment)
Terminal window
dbward request cancel <ID>
OptionDescription
--reason <TEXT>Cancellation reason

Wait for execution and display result.

Terminal window
dbward request resume <ID>
dbward request resume <ID> --reason "operator dispatch" --result-format json
OptionDefaultDescription
--reason <TEXT>Reason for resuming (required when resuming another user’s request)
--output <PATH>Save result to file
--result-format <FMT>tableDisplay format: table, json, csv, vertical

Retrieve execution result for a request.

Terminal window
dbward request result <ID>
dbward request result <ID> --execution <EXECUTION_ID>
dbward request result <ID> --output ./result.json
dbward request result <ID> --result-format csv
dbward request result <ID> --list
dbward request result <ID> --list --limit 10
OptionDefaultDescription
--execution <ID>latestRetrieve a specific execution’s result. Default: latest completed or failed execution
--output <PATH>Save result to a specific file (JSON)
--result-format <FMT>tableDisplay format: table, json, csv, vertical
--listList execution history for this request
--limit <N>20Max results (with --list)

--list cannot be combined with --execution, --output, or --result-format.

List shared results across requests.

Terminal window
dbward request results
dbward request results --limit 20
OptionDefaultDescription
--limit <N>50Max results

Database migrations.

Create a new migration file (local only).

Terminal window
dbward migrate create add_users_table

Show applied and pending migrations.

Terminal window
dbward migrate status

Apply pending migrations.

Terminal window
dbward migrate up
dbward migrate up --count 1
OptionDefaultDescription
--count <N>allMax migrations to apply
--ticket <ID>Metadata
--repo <URL>Metadata
--idempotency-key <KEY>Deduplication key
--share-with <SELECTOR>Share result

Rollback migrations.

Terminal window
dbward migrate down
dbward migrate down --count 2
OptionDefaultDescription
--count <N>1Migrations to rollback
--ticket <ID>Metadata
--repo <URL>Metadata
--idempotency-key <KEY>Deduplication key

Repair schema_migrations metadata. This modifies only the version tracking table, not the actual database schema. Verify DB state manually before use.

Terminal window
dbward migrate repair --emergency --action mark-applied --version 20240601_add_index --reason "partial migration recovery"
dbward migrate repair --emergency --action remove --version 20240601_add_index --reason "rolled back manually"
OptionDefaultDescription
--action <ACTION>(required)mark-applied or remove
--version <VERSION>(required)Migration version to repair
--emergency(required)Safety flag (break-glass permission required)
--reason <TEXT>(required)Reason for the repair (recorded in audit log)
--ticket <ID>Metadata
--repo <URL>Metadata

Analyze a SQL statement without creating a request. Returns risk, findings, and fix suggestions.

Terminal window
dbward preflight "SELECT * FROM users WHERE id = 1"
dbward preflight --database app -e production "UPDATE users SET active = false WHERE last_login < '2025-01-01'"
dbward preflight --no-explain "DROP TABLE sessions"
OptionDefaultDescription
<SQL> (positional)Required. SQL statement to analyze
--no-explainfalseSkip EXPLAIN (static analysis only)
--explain-timeout <MS>5000Max EXPLAIN wait in milliseconds
--database <NAME>Target database (overrides global)
-e, --environment <ENV>Target environment (overrides global)

Exit code 0 = requestable/warning, 1 = blocked. Use --format json for structured output.


Search and verify audit logs.

Terminal window
dbward audit
dbward audit --user alice --since 2026-05-01 --result-format json
dbward audit --verify
OptionDefaultDescription
--limit <N>Max results
--user <ID>Filter by actor
--operation <OP>Filter by operation
--status <STATUS>Filter by status
--event-type <TYPE>Filter by event type
--category <CAT>Filter by category
--outcome <OUTCOME>Filter by outcome
--since <DATETIME>Events after this time
--until <DATETIME>Events before this time
--verifyfalseVerify hash chain integrity
--result-format <FMT>tableResult format: table, json, csv

Manage API tokens.

Terminal window
dbward token create # Create token for yourself
dbward token create --scope-roles requester # With specific ceiling
dbward token create --subject agent-1 --subject-type agent --no-scope-ceiling # Agent token
OptionDefaultDescription
--subject <ID>selfSubject ID. Defaults to your own identity when omitted. Required for agent tokens.
--scope-roles <ROLES>Comma-separated roles for scope ceiling. Optional. When omitted, defaults to the user’s resolved roles (auto-ceiling). Conflicts with --no-scope-ceiling.
--subject-type <TYPE>useruser or agent
--name <NAME>Token display name
--no-scope-ceilingfalseRemove scope ceiling (agent tokens only). Token inherits all bound roles. Conflicts with --scope-roles.
--expires <DURATION>Expiry: 90d, 24h, 30m, ISO date, or datetime

Notes:

  • Creating tokens for other users is not allowed. Use dbward user reissue-initial-token instead.
  • Agent token creation requires token.create_agent permission.
Terminal window
dbward token list
dbward token list --subject alice --status active
OptionDescription
--subject <ID>Filter by subject
--status <STATUS>active or revoked
--type <TYPE>user or agent
Terminal window
dbward token revoke <ID>

Show a token’s current effective permissions. Token owners can inspect their own tokens; otherwise requires token.list permission.

Terminal window
dbward token inspect <ID>

Manage users.

Register a new user.

Terminal window
dbward user add alice --role requester
dbward user add bob --role dba --group backend-team
OptionDescription
<ID> (positional)Required. User identifier
--role <ROLE>Role to assign (repeatable)
--group <GROUP>Group to add user to (repeatable)

On success, prints the initial API token to stdout. Store it securely — it cannot be retrieved later.

Update an existing user.

Terminal window
dbward user update alice --role admin
dbward user update alice --slack-user-id U02CR3TMKKJ
dbward user update alice --add-group dba-team --rm-group backend-team
dbward user update alice --add-role dba --rm-role approver
OptionDescription
<ID> (positional)Required. User identifier
--role <ROLE>Set roles (replaces existing, repeatable)
--add-role <ROLE>Add a role (repeatable)
--rm-role <ROLE>Remove a role (repeatable)
--slack-user-id <ID>Link Slack account for approval notifications
--add-group <GROUP>Add to group (repeatable)
--rm-group <GROUP>Remove from group (repeatable)

Show user details including roles, groups, and status.

Terminal window
dbward user show alice

List all users.

Terminal window
dbward user list

Suspend a user (revokes tokens, cancels pending requests).

Terminal window
dbward user suspend alice
OptionDescription
<ID> (positional)Required. User identifier

Reactivate a suspended user.

Terminal window
dbward user activate alice

Remove a user (soft-delete: revokes tokens, removes group memberships, retains record for audit).

Terminal window
dbward user rm alice

Reissue a user’s initial token. Revokes the existing initial token and creates a new one. If Slack is configured and the user has a linked Slack ID, the token is delivered via DM.

Permission: token.reissue

Terminal window
dbward user reissue-initial-token alice

Manage groups.

List all groups.

Terminal window
dbward group list

Show group details including members and assigned roles.

Terminal window
dbward group show backend-team

OIDC authentication.

Terminal window
dbward login # Browser-based login
dbward login --device # Device flow (headless/SSH)
dbward logout # Revoke tokens + delete credentials
dbward whoami # Show current identity
OptionDescription
--deviceUse device code flow (login only)

whoami shows Subject, Roles, and Groups when connected to the server. Falls back to local OIDC credentials if the server is unreachable.


List registered databases.

Terminal window
dbward databases
dbward databases --format json

Show agent status (admin only).

Terminal window
dbward agents
dbward agents --format json

Show effective policy for a database/environment combination.

Terminal window
dbward policy resolve app production
dbward policy resolve app production --operation execute_dml
OptionDescription
<DATABASE> (positional)Required. Database name
<ENVIRONMENT> (positional)Required. Environment name
--operation <OP>Specific operation to resolve

Diagnose configuration and connectivity. In CLI mode (no flags), checks: config parse, environment variables, server URL scheme, server reachability, version compatibility, auth configuration, token validity (API token auth only; OIDC is skipped), database registration, and workflow existence. With --server or --agent, performs static config validation only (no connectivity checks).

Terminal window
dbward doctor
dbward doctor --agent agent.toml # validate agent config (static checks only)
dbward doctor --server server.toml # validate server config (static checks only)
OptionDefaultDescription
--agent <PATH>Validate agent config file (static checks, no connectivity)
--server <PATH>Validate server config file (static checks, no connectivity)
--timeout <SECS>5Network timeout per check

Connectivity checks: dbward doctor --server/--agent performs static validation only. Use dbward-server validate --config ... --preflight or dbward-agent validate --config ... --preflight to also check external connectivity.


Initialize configuration files.

Terminal window
dbward init
dbward init --preset small-team --output-dir ./config
OptionDefaultDescription
--preset <NAME>Config template (e.g. small-team)
--output-dir <PATH>.Output directory
--non-interactivefalseSkip prompts
--forcefalseOverwrite existing files
--dry-runfalsePrint to stdout only

Start local development server + agent (single process).

Terminal window
dbward dev --database-url "postgres://localhost/myapp"
OptionDefaultDescription
--database-url <URL>Required. Database connection URL
--port <PORT>3000Server port

The server and agent are separate binaries with their own CLIs.

Terminal window
# Start the server
dbward-server start --config server.toml --listen 0.0.0.0:3000
# Validate configuration before starting
dbward-server validate --config server.toml
dbward-server validate --config server.toml --preflight # also check OIDC/Slack connectivity
# Reload configuration (sends SIGHUP without restarting)
dbward-server reload --config server.toml
dbward-server reload --pid 12345

dbward-server start options:

OptionDefaultDescription
--config <PATH>dbward-server.tomlServer config file
--listen <ADDR>127.0.0.1:3000Listen address
--force-bootstrapfalseRevoke existing bootstrap tokens and regenerate

dbward-server validate options:

OptionDefaultDescription
--config <PATH>dbward-server.tomlServer config file to validate
--preflightfalseAlso check external connectivity (OIDC issuer, Slack API)

Exit codes: 0 = valid (may have warnings), 1 = invalid config or preflight failure

dbward-server reload options:

OptionDefaultDescription
--config <PATH>dbward-server.tomlServer config file (to locate PID file)
--pid <PID>PID of the server process (overrides PID file lookup)
Terminal window
# Start the agent
dbward-agent start --config agent.toml
# Validate configuration before starting
dbward-agent validate --config agent.toml
dbward-agent validate --config agent.toml --preflight # also check server reachability and token

dbward-agent start options:

OptionDefaultDescription
--config <PATH>dbward-agent.tomlAgent config file

dbward-agent validate options:

OptionDefaultDescription
--config <PATH>dbward-agent.tomlAgent config file to validate
--preflightfalseAlso check server reachability and agent token validity

Exit codes: 0 = valid (may have warnings), 1 = invalid config or preflight failure


Start MCP stdio server (for AI IDE integration).

Terminal window
dbward mcp

No additional options. See MCP Reference.


Generate a Slack App Manifest and creation URL. Creates an app with all required scopes, Interactivity URL, and Slash Commands pre-configured.

Terminal window
dbward slack init --server-url https://dbward.example.com
dbward slack init --server-url https://dbward.example.com --open
dbward slack init --server-url https://dbward.example.com --manifest-only
OptionDefaultDescription
--server-url <URL>Required.Public URL of the dbward server
--app-name <NAME>dbwardSlack app display name
--openfalseOpen browser to Slack app creation page
--manifest-onlyfalseOutput manifest YAML only (no instructions)

Update dbward to the latest version.

Terminal window
dbward --version # check current version
dbward self-update # download and install latest

CodeMeaning
0Success
1Error (connection, validation, execution failure)
2Pending / issues found (approval pending, doctor failure, usage error)
124Timeout (agent did not respond within --timeout)
130Interrupted (Ctrl-C / SIGINT)

The --format option controls the overall output contract for all commands.

ModestdoutstderrUse case
human (default)Data (tables, key-value, raw values)Status messages, warnings, hints, errorsInteractive terminal use
jsonJSON envelope (always valid JSON, one line)Error message onlyScripts, CI/CD, jq piping
quietJSON envelope (same as json)Nothing (0 bytes)Full automation, log-free pipelines

All commands produce this structure on stdout when --format json or --format quiet is used:

Success:

{"ok": true, "data": { ... }}

Error:

{"ok": false, "data": null, "error": {"code": "auth_error", "message": "token expired"}}

Data with issues (e.g., doctor with failures):

{"ok": false, "data": {"checks": [...]}, "error": {"code": "doctor_issues_found", "message": "1 check(s) failed"}}

In human mode, stdout contains only data that can be piped (table output, token values, CSV). All auxiliary information (status messages, warnings, progress) goes to stderr. This means commands like dbward token create | pbcopy work reliably.

These are independent options:

  • --format (global) controls the CLI output contract (envelope structure, stream routing)
  • --result-format (execute/request result/audit only) controls how query results are rendered within the human-mode data area

When --format json is active, --result-format is silently ignored — the full result data is always in the JSON envelope’s data field.