CockroachDB CLI
$ cockroach Official High RiskThe cockroach CLI serves both as the database binary and the operational client (cockroach sql, cockroach node status, cockroach cert). Supports --execute one-shot SQL queries, --format=json/tsv/csv, and TLS certificate flags.
brew install cockroachdb/tap/cockroach cockroach sql --execute and cockroach node status --format=json give direct distributed cluster telemetry and SQL access without an MCP wrapper.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --execute one-shot SQL, --format=json/csv/tsv, and COCKROACH_URL env auth.
- Supports
cockroach sql --execute --format=jsonandnode status --format=json
Requires TLS certs by default for secure clusters, though cockroach sql executes arbitrary DDL/DML if user privileges allow.
- Default TLS cert enforcement on secure clusters; no client-side
--readonlyflag
Heavy monolithic binary distributed via Homebrew/tarball for macOS and Linux; no native Windows binary.
- Large ~150MB+ binary limited to macOS and Linux
Combines distributed SQL client, node ops, cert generation, and in-memory single-node testing.
- All-in-one binary covers client SQL, node ops, and
start-single-node
Official cockroachdb/cockroach binary maintained by Cockroach Labs.
- Official
cockroachdb/cockroachrepository
Detailed command reference across SQL, cluster, and certificate subcommands.
- Official docs at cockroachlabs.com/docs/stable/cockroach-commands
Security, Auth & Guardrails
Connection URIs via COCKROACH_URL or --url; client TLS certs in ~/.cockroach-certs or --certs-dir.
Binary is free for self-hosted dev/testing under CockroachDB Software License; enterprise clusters require commercial licensing.
# CockroachDB CLI Agent Rules - Always pass `--execute "<sql>"` and `--format=json` to `cockroach sql` (never open interactive shell). - Prefer `SHOW` / `EXPLAIN` / `SELECT ... LIMIT` before mutating tables. - NEVER run `cockroach quit`, `DROP DATABASE`, or `node decommission` autonomously.
Agent-Ready Command Recipes
Safe Read-Only Queries
cockroach sql --url "$COCKROACH_URL" --format=json --execute "SHOW DATABASES;"
Executes a single SQL metadata statement non-interactively and formats rows as JSON.
cockroach node status --url "$COCKROACH_URL" --format=json
Reports live node liveness, ranges, and cluster health without mutating state.
Controlled Writes & Previews
cockroach start-single-node --insecure --store=type=mem,size=1GiB --background
Starts an ephemeral in-memory local CockroachDB node for integration testing.
Strengths for Agents
- +
--executeplus--format=jsonenables clean non-interactive SQL and cluster status queries. - +
start-single-node --store=type=memspins up a fast local cluster for CI tests. - + Postgres wire compatibility lets
psqlalso work alongsidecockroach.
Caveats & Pitfalls
- ! Binary footprint is large because client and server ship together.
- ! No native Windows build; Windows users rely on WSL or containers.