database-cli
Safe database investigation for agents
A CLI-first database Skill that lets agents investigate real data inside guardrails.
- Active
- 2026
- Python · CLI · Codex Skill · Database
Why
Production debugging keeps coming back to the database: which table holds this, which column changed, what does this order actually look like in QA?
Agents are good at that loop. Handing one a general-purpose database client is the wrong trade, though. database-cli gives the agent one narrow, auditable way in.
Problem
Agents guess at schema instead of reading it, and write SQL against tables that don't exist.
A general SQL client lets every statement through, writes and DDL included.
Connection details end up in command lines and chat history.
Each environment is set up differently, so humans and agents don't share one entry point.
System
The CLI is the product. Everything else is a thin layer on top of it.
Skill · SKILL.md
The operating procedure: confirm the environment, read the real schema, run bounded read-only queries, and change data only with explicit approval.
Optional MCP adapter
scripts/database-mcpexposes the same capabilities over stdio MCP and delegates every call to the CLI.CLI · scripts/db-query
The single execution entry. It validates SQL, enforces read-only defaults and row limits, and searches metadata.
sq backend
Queries run through
sq, with environments described in a localconnections.local.jsonthat never enters the repository.
Implementation
Setup status an agent can act on
--setup-statusreturns JSON withready, problems andnext_actions— without connecting to any database — so an agent can repair its own setup first.Object search
Find schemas, tables, columns, indexes and procedures by pattern at
names,summaryorfulldetail, instead of hand-writing information_schema SQL.Connections with intent
Environments carry a display name, project, description and aliases, so the agent can choose a connection by what the user means.
One-step install
scripts/installchecks forsq, collects connection details and writes the local config in a single command.
Decisions
- D1
One execution path
The MCP adapter is not allowed its own query logic. Safety rules live in the CLI, so no client can route around them.
- D2
Write access comes from config, not a flag
--allow-writeonly works on environments marked"writable": true; ad-hoc connections need an extra--writable. A protected database cannot be re-entered as a temporary connection to escape its config. - D3
Count before changing
Approved UPDATE and DELETE statements count affected rows first and are refused above
max_write_rows(1000 by default), so aWHERE 1=1cannot slip through. - D4
Some SQL is never allowed
DDL, privileges, transactions, procedures, locks and exports stay blocked even when writes are approved.
- D5
Not a platform
No workbench, permission service or multi-tenant server. It stays a Skill that humans and agents install and can audit.
Result
- scripts/db-query
- Read-only · bounded rows
- Codex Skill · MCP
It is the database entry point of my own agent setup: schema lookups, cross-environment checks and repair SQL all go through the same guarded CLI.