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

Diesel CLI

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

Diesel CLI (diesel) manages database setup, versioned up.sql/down.sql migrations, and compile-time Rust table! macro codegen via diesel print-schema. Supports DATABASE_URL env configuration and non-interactive CI migration workflows.

FCRS-1.0 Score
78 /100
Good
Medium Confidence
Zero-Friction Install
brew install diesel
CLI vs MCP Decision CLI Preferred vs MCP

diesel print-schema directly writes Rust table! macros into src/schema.rs for cargo check loops, which an MCP server cannot replace.

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 17 / 25

Commands like diesel migration list and diesel print-schema run headlessly with clear exit codes, though stdout is plain text without --json.

  • Non-interactive migration list, migration run, and print-schema commands
  • No native --json output mode
Trust & Safety 20 / 25

Explicit up.sql/down.sql files are easy to audit before running, while diesel database reset drops and recreates the target database.

  • Plain SQL migration files inspectable prior to execution
  • diesel database reset is destructive on target DB
Setup & Portability 12 / 15

Available via brew install diesel and cargo install diesel_cli, though Cargo builds require native libpq, sqlite, or mysqlclient headers unless --features is scoped.

  • Homebrew binary formula and cargo install diesel_cli across macOS, Linux, and Windows
Utility & Efficiency 13 / 15

Tightly integrates database migrations with compile-time checked src/schema.rs codegen for Rust codebases.

  • Automates table! macro generation via diesel print-schema
Maintenance & Lineage 8 / 10

Official diesel-rs/diesel project with long-term Rust ecosystem stewardship under MIT/Apache-2.0.

  • Official diesel-rs/diesel repository
Docs & Verifiability 8 / 10

Well-documented getting-started guides, diesel.toml reference, and structured --help output.

  • Official guides at diesel.rs and subcommand --help

Security, Auth & Guardrails

Auth Modes
Env API Key Config File
Credential Storage

Reads DATABASE_URL from the process environment, .env, or --database-url flag; schema generation options live in diesel.toml.

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

Dual-licensed MIT/Apache-2.0 open-source CLI; free to use locally and in CI.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Diesel CLI Agent Rules
- Run `diesel migration list` before applying migrations and check both `up.sql` and `down.sql`.
- Never run `diesel database reset` or `diesel migration redo` against shared or production `DATABASE_URL` targets.

Agent-Ready Command Recipes

Safe Read-Only Queries

List applied and pending migrations
diesel migration list

Shows each migration directory entry with [X] for applied and [ ] for pending status.

Print Rust schema definitions to stdout
diesel print-schema --only-tables users,orders

Introspects the connected database and outputs table! macros without modifying local files unless redirected.

Controlled Writes & Previews

Run pending migrations on target database
diesel migration run --locked-schema

Applies pending up.sql migrations non-interactively while failing if src/schema.rs would drift unexpectedly.

Strengths for Agents

  • + Generates compile-time checked Rust src/schema.rs directly from live DB state.
  • + Plain SQL up.sql and down.sql files keep every schema change human- and agent-reviewable.
  • + Reads DATABASE_URL from env or .env for frictionless local and CI runs.

Caveats & Pitfalls

  • ! No --json output flag on diesel migration list or status checks.
  • ! cargo install diesel_cli fails without C client libraries (libpq/mysqlclient) unless --no-default-features is passed.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI