CLI Reference
CLI Reference
Section titled “CLI Reference”Global Options
Section titled “Global Options”| Option | Short | Env | Default | Description |
|---|---|---|---|---|
--version | -v | Show version and exit | ||
--config <PATH> | DBWARD_CONFIG | Config file path (standalone mode) | ||
--merge-global | false | Merge global config when —config is set | ||
--database <NAME> | DBWARD_DATABASE | Target database | ||
-e, --environment <ENV> | -e | DBWARD_ENV | Target environment | |
--format <FMT> | human | Output format: human, json, quiet | ||
--allow-insecure | DBWARD_ALLOW_INSECURE | false | Allow HTTP connections to non-local servers. Suppresses transport security warnings. Does not bypass OIDC+HTTP rejection. | |
--yes | -y | DBWARD_YES | false | Skip interactive confirmation prompts. Env accepts 1, true, or yes. |
dbward execute
Section titled “dbward execute”Execute a SQL query through the approval workflow.
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'"| Option | Default | Description |
|---|---|---|
<SQL> (positional) | — | Required. SQL statement |
--emergency | false | Break-glass bypass (requires —reason) |
--allow-ddl | false | Allow DDL in emergency mode (requires —emergency) |
--reason <TEXT> | Reason for this request | |
--output <PATH> | Save result to file | |
--no-result-store | false | Do not store query result on server. Request metadata and SQL text are always retained for audit. |
--result-format <FMT> | table | Display 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 |
dbward request
Section titled “dbward request”Manage requests.
dbward request list
Section titled “dbward request list”dbward request listdbward request list --status pending --pending-for-me| Option | Default | Description |
|---|---|---|
--limit <N> | Max results | |
--status <STATUS> | Filter by status | |
--pending-for-me | false | Only show requests I can approve |
--user <ID> | Filter by requester |
dbward request show
Section titled “dbward request show”dbward request show <ID>dbward request approve
Section titled “dbward request approve”dbward request approve <ID>dbward request approve <ID> --comment "Verified"| Option | Description |
|---|---|
--comment <TEXT> | Approval comment |
dbward request reject
Section titled “dbward request reject”dbward request reject <ID> --reason "Add WHERE clause"| Option | Description |
|---|---|
--reason <TEXT> | Rejection reason (alias: --comment) |
dbward request cancel
Section titled “dbward request cancel”dbward request cancel <ID>| Option | Description |
|---|---|
--reason <TEXT> | Cancellation reason |
dbward request resume
Section titled “dbward request resume”Wait for execution and display result.
dbward request resume <ID>dbward request resume <ID> --reason "operator dispatch" --result-format json| Option | Default | Description |
|---|---|---|
--reason <TEXT> | Reason for resuming (required when resuming another user’s request) | |
--output <PATH> | Save result to file | |
--result-format <FMT> | table | Display format: table, json, csv, vertical |
dbward request result
Section titled “dbward request result”Retrieve execution result for a request.
dbward request result <ID>dbward request result <ID> --execution <EXECUTION_ID>dbward request result <ID> --output ./result.jsondbward request result <ID> --result-format csvdbward request result <ID> --listdbward request result <ID> --list --limit 10| Option | Default | Description |
|---|---|---|
--execution <ID> | latest | Retrieve a specific execution’s result. Default: latest completed or failed execution |
--output <PATH> | Save result to a specific file (JSON) | |
--result-format <FMT> | table | Display format: table, json, csv, vertical |
--list | List execution history for this request | |
--limit <N> | 20 | Max results (with --list) |
--list cannot be combined with --execution, --output, or --result-format.
dbward request results
Section titled “dbward request results”List shared results across requests.
dbward request resultsdbward request results --limit 20| Option | Default | Description |
|---|---|---|
--limit <N> | 50 | Max results |
dbward migrate
Section titled “dbward migrate”Database migrations.
dbward migrate create
Section titled “dbward migrate create”Create a new migration file (local only).
dbward migrate create add_users_tabledbward migrate status
Section titled “dbward migrate status”Show applied and pending migrations.
dbward migrate statusdbward migrate up
Section titled “dbward migrate up”Apply pending migrations.
dbward migrate updbward migrate up --count 1| Option | Default | Description |
|---|---|---|
--count <N> | all | Max migrations to apply |
--ticket <ID> | Metadata | |
--repo <URL> | Metadata | |
--idempotency-key <KEY> | Deduplication key | |
--share-with <SELECTOR> | Share result |
dbward migrate down
Section titled “dbward migrate down”Rollback migrations.
dbward migrate downdbward migrate down --count 2| Option | Default | Description |
|---|---|---|
--count <N> | 1 | Migrations to rollback |
--ticket <ID> | Metadata | |
--repo <URL> | Metadata | |
--idempotency-key <KEY> | Deduplication key |
dbward migrate repair
Section titled “dbward migrate repair”Repair schema_migrations metadata. This modifies only the version tracking table, not the actual database schema. Verify DB state manually before use.
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"| Option | Default | Description |
|---|---|---|
--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 |
dbward preflight
Section titled “dbward preflight”Analyze a SQL statement without creating a request. Returns risk, findings, and fix suggestions.
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"| Option | Default | Description |
|---|---|---|
<SQL> (positional) | — | Required. SQL statement to analyze |
--no-explain | false | Skip EXPLAIN (static analysis only) |
--explain-timeout <MS> | 5000 | Max 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.
dbward audit
Section titled “dbward audit”Search and verify audit logs.
dbward auditdbward audit --user alice --since 2026-05-01 --result-format jsondbward audit --verify| Option | Default | Description |
|---|---|---|
--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 | |
--verify | false | Verify hash chain integrity |
--result-format <FMT> | table | Result format: table, json, csv |
dbward token
Section titled “dbward token”Manage API tokens.
dbward token create
Section titled “dbward token create”dbward token create # Create token for yourselfdbward token create --scope-roles requester # With specific ceilingdbward token create --subject agent-1 --subject-type agent --no-scope-ceiling # Agent token| Option | Default | Description |
|---|---|---|
--subject <ID> | self | Subject 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> | user | user or agent |
--name <NAME> | Token display name | |
--no-scope-ceiling | false | Remove 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-tokeninstead. - Agent token creation requires
token.create_agentpermission.
dbward token list
Section titled “dbward token list”dbward token listdbward token list --subject alice --status active| Option | Description |
|---|---|
--subject <ID> | Filter by subject |
--status <STATUS> | active or revoked |
--type <TYPE> | user or agent |
dbward token revoke
Section titled “dbward token revoke”dbward token revoke <ID>dbward token inspect
Section titled “dbward token inspect”Show a token’s current effective permissions. Token owners can inspect their own tokens; otherwise requires token.list permission.
dbward token inspect <ID>dbward user
Section titled “dbward user”Manage users.
dbward user add
Section titled “dbward user add”Register a new user.
dbward user add alice --role requesterdbward user add bob --role dba --group backend-team| Option | Description |
|---|---|
<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.
dbward user update
Section titled “dbward user update”Update an existing user.
dbward user update alice --role admindbward user update alice --slack-user-id U02CR3TMKKJdbward user update alice --add-group dba-team --rm-group backend-teamdbward user update alice --add-role dba --rm-role approver| Option | Description |
|---|---|
<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) |
dbward user show
Section titled “dbward user show”Show user details including roles, groups, and status.
dbward user show alicedbward user list
Section titled “dbward user list”List all users.
dbward user listdbward user suspend
Section titled “dbward user suspend”Suspend a user (revokes tokens, cancels pending requests).
dbward user suspend alice| Option | Description |
|---|---|
<ID> (positional) | Required. User identifier |
dbward user activate
Section titled “dbward user activate”Reactivate a suspended user.
dbward user activate alicedbward user rm
Section titled “dbward user rm”Remove a user (soft-delete: revokes tokens, removes group memberships, retains record for audit).
dbward user rm alicedbward user reissue-initial-token
Section titled “dbward user reissue-initial-token”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
dbward user reissue-initial-token alicedbward group
Section titled “dbward group”Manage groups.
dbward group list
Section titled “dbward group list”List all groups.
dbward group listdbward group show
Section titled “dbward group show”Show group details including members and assigned roles.
dbward group show backend-teamdbward login / logout / whoami
Section titled “dbward login / logout / whoami”OIDC authentication.
dbward login # Browser-based logindbward login --device # Device flow (headless/SSH)dbward logout # Revoke tokens + delete credentialsdbward whoami # Show current identity| Option | Description |
|---|---|
--device | Use 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.
dbward databases
Section titled “dbward databases”List registered databases.
dbward databasesdbward databases --format jsondbward agents
Section titled “dbward agents”Show agent status (admin only).
dbward agentsdbward agents --format jsondbward policy resolve
Section titled “dbward policy resolve”Show effective policy for a database/environment combination.
dbward policy resolve app productiondbward policy resolve app production --operation execute_dml| Option | Description |
|---|---|
<DATABASE> (positional) | Required. Database name |
<ENVIRONMENT> (positional) | Required. Environment name |
--operation <OP> | Specific operation to resolve |
dbward doctor
Section titled “dbward doctor”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).
dbward doctordbward doctor --agent agent.toml # validate agent config (static checks only)dbward doctor --server server.toml # validate server config (static checks only)| Option | Default | Description |
|---|---|---|
--agent <PATH> | Validate agent config file (static checks, no connectivity) | |
--server <PATH> | Validate server config file (static checks, no connectivity) | |
--timeout <SECS> | 5 | Network timeout per check |
Connectivity checks:
dbward doctor --server/--agentperforms static validation only. Usedbward-server validate --config ... --preflightordbward-agent validate --config ... --preflightto also check external connectivity.
dbward init
Section titled “dbward init”Initialize configuration files.
dbward initdbward init --preset small-team --output-dir ./config| Option | Default | Description |
|---|---|---|
--preset <NAME> | Config template (e.g. small-team) | |
--output-dir <PATH> | . | Output directory |
--non-interactive | false | Skip prompts |
--force | false | Overwrite existing files |
--dry-run | false | Print to stdout only |
dbward dev
Section titled “dbward dev”Start local development server + agent (single process).
dbward dev --database-url "postgres://localhost/myapp"| Option | Default | Description |
|---|---|---|
--database-url <URL> | — | Required. Database connection URL |
--port <PORT> | 3000 | Server port |
Server and Agent binaries
Section titled “Server and Agent binaries”The server and agent are separate binaries with their own CLIs.
dbward-server
Section titled “dbward-server”# Start the serverdbward-server start --config server.toml --listen 0.0.0.0:3000
# Validate configuration before startingdbward-server validate --config server.tomldbward-server validate --config server.toml --preflight # also check OIDC/Slack connectivity
# Reload configuration (sends SIGHUP without restarting)dbward-server reload --config server.tomldbward-server reload --pid 12345dbward-server start options:
| Option | Default | Description |
|---|---|---|
--config <PATH> | dbward-server.toml | Server config file |
--listen <ADDR> | 127.0.0.1:3000 | Listen address |
--force-bootstrap | false | Revoke existing bootstrap tokens and regenerate |
dbward-server validate options:
| Option | Default | Description |
|---|---|---|
--config <PATH> | dbward-server.toml | Server config file to validate |
--preflight | false | Also check external connectivity (OIDC issuer, Slack API) |
Exit codes: 0 = valid (may have warnings), 1 = invalid config or preflight failure
dbward-server reload options:
| Option | Default | Description |
|---|---|---|
--config <PATH> | dbward-server.toml | Server config file (to locate PID file) |
--pid <PID> | PID of the server process (overrides PID file lookup) |
dbward-agent
Section titled “dbward-agent”# Start the agentdbward-agent start --config agent.toml
# Validate configuration before startingdbward-agent validate --config agent.tomldbward-agent validate --config agent.toml --preflight # also check server reachability and tokendbward-agent start options:
| Option | Default | Description |
|---|---|---|
--config <PATH> | dbward-agent.toml | Agent config file |
dbward-agent validate options:
| Option | Default | Description |
|---|---|---|
--config <PATH> | dbward-agent.toml | Agent config file to validate |
--preflight | false | Also check server reachability and agent token validity |
Exit codes: 0 = valid (may have warnings), 1 = invalid config or preflight failure
dbward mcp
Section titled “dbward mcp”Start MCP stdio server (for AI IDE integration).
dbward mcpNo additional options. See MCP Reference.
dbward slack
Section titled “dbward slack”dbward slack init
Section titled “dbward slack init”Generate a Slack App Manifest and creation URL. Creates an app with all required scopes, Interactivity URL, and Slash Commands pre-configured.
dbward slack init --server-url https://dbward.example.comdbward slack init --server-url https://dbward.example.com --opendbward slack init --server-url https://dbward.example.com --manifest-only| Option | Default | Description |
|---|---|---|
--server-url <URL> | Required. | Public URL of the dbward server |
--app-name <NAME> | dbward | Slack app display name |
--open | false | Open browser to Slack app creation page |
--manifest-only | false | Output manifest YAML only (no instructions) |
dbward self-update
Section titled “dbward self-update”Update dbward to the latest version.
dbward --version # check current versiondbward self-update # download and install latestExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (connection, validation, execution failure) |
| 2 | Pending / issues found (approval pending, doctor failure, usage error) |
| 124 | Timeout (agent did not respond within --timeout) |
| 130 | Interrupted (Ctrl-C / SIGINT) |
Output Modes
Section titled “Output Modes”The --format option controls the overall output contract for all commands.
| Mode | stdout | stderr | Use case |
|---|---|---|---|
human (default) | Data (tables, key-value, raw values) | Status messages, warnings, hints, errors | Interactive terminal use |
json | JSON envelope (always valid JSON, one line) | Error message only | Scripts, CI/CD, jq piping |
quiet | JSON envelope (same as json) | Nothing (0 bytes) | Full automation, log-free pipelines |
JSON envelope structure
Section titled “JSON envelope structure”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"}}stdout/stderr separation
Section titled “stdout/stderr separation”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.
--format vs --result-format
Section titled “--format vs --result-format”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.