Skip to content

CLI

Scripts and Agents

When stdout is not a terminal the CLI prints JSON and never prompts. Two things follow.

Approvals need --yes. Environment roles apply exactly as in the editor. A statement the role marks “ask” is refused with exit code 4 unless you pass --yes; a statement the role denies is refused either way. A DELETE or UPDATE without a WHERE clause follows the role’s missing-WHERE rule.

Agents see real data. AI data masking in DBCode applies to results that go to a model through DBCode’s own AI features and MCP server. A coding agent that runs dbcode query is a terminal user like any other, the same as if it ran psql. Point agents at DBCode’s MCP server when you want masking and AI roles to apply.

The CLI runs on your own machine: it reads the connections and stored passwords from your DBCode install, so it lives alongside the editor. Useful patterns:

Terminal window
# a quick check from your terminal
n=$(dbcode query -c prod "select count(*) as n from orders where status = 'stuck'" | jq '.[0].n')
[ "$n" -eq 0 ] && echo "all clear" || echo "$n stuck orders"
# one row per line for streaming tools
dbcode query -c prod --format jsonl "select * from events" | head -100