Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

sqlx-cli

$ sqlx Official Med Risk
LaunchBadge · Database & Data · MIT OR Apache-2.0 · macos / linux / windows

sqlx-cli (sqlx / cargo sqlx) manages databases (sqlx database create/setup), timestamped or reversible SQL migrations (sqlx migrate run/info/revert), and sqlx prepare to cache query metadata in .sqlx/ so Rust projects compile offline with SQLX_OFFLINE=true.

FCRS-1.0 Score
80 /100
Good
Medium Confidence
Zero-Friction Install
brew install sqlx-cli
CLI vs MCP Decision CLI Only

sqlx inspects local Rust crates (cargo sqlx prepare) and ./migrations directories directly; MCP cannot replace Cargo build-time metadata generation.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 18 / 25

Fully non-interactive with DATABASE_URL/.env support and prepare --check verification mode, though output is plain text rather than --json.

  • Non-interactive migrate and prepare --check commands; no --json flag
Trust & Safety 20 / 25

Verifies migration SHA-384 checksums, supports prepare --check dry verification and migrate run --dry-run (where supported), though database drop/reset are destructive.

  • Checksum validation and --check verification; database drop requires -y or confirmation
Setup & Portability 13 / 15

Installable via brew install sqlx-cli and cargo install sqlx-cli across macOS, Linux, and Windows (Cargo build allows feature trimming).

  • Available via Homebrew and cargo install sqlx-cli
Utility & Efficiency 14 / 15

Indispensable for Rust SQLx projects, combining DB lifecycle, migrations, and offline compile-time SQL verification.

  • Unifies database, migrate, and offline prepare workflows
Maintenance & Lineage 8 / 10

Official launchbadge/sqlx crate dual-licensed under MIT OR Apache-2.0.

  • Official launchbadge/sqlx repository
Docs & Verifiability 7 / 10

Clear CLI README in launchbadge/sqlx/sqlx-cli and Clap --help.

  • Official README and --help output

Security, Auth & Guardrails

Auth Modes
Env API Key Config File
Credential Storage

Reads DATABASE_URL from the environment or a local .env file (or --database-url <URL>).

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

100% free under dual MIT / Apache-2.0 license.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# sqlx-cli Agent Rules
- Always run `sqlx migrate info` before `sqlx migrate run` or `sqlx migrate revert`.
- Use `cargo sqlx prepare --check --workspace` in CI/verification loops before regenerating `.sqlx/`.
- NEVER run `sqlx database drop` or `sqlx database reset` without explicit user confirmation.

Agent-Ready Command Recipes

Safe Read-Only Queries

Inspect applied and pending SQLx migrations
sqlx migrate info

Lists every migration in ./migrations along with its applied or pending state against DATABASE_URL.

Check whether offline .sqlx/ query cache is up to date
cargo sqlx prepare --check --workspace

Verifies in CI/agent checks that .sqlx/ query metadata matches current Rust SQL macros without modifying files.

Controlled Writes & Previews

Run pending database migrations
sqlx migrate run

Applies all pending SQL migrations against DATABASE_URL and records checksums in _sqlx_migrations.

Strengths for Agents

  • + cargo sqlx prepare --check verifies offline .sqlx/ query metadata cleanly in CI.
  • + Automatic .env DATABASE_URL loading and SHA-384 migration checksum tracking.

Caveats & Pitfalls

  • ! Lacks a --json output flag for sqlx migrate info.
  • ! cargo install sqlx-cli compiles Rust crates from source unless installed via Homebrew/binstall.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI