diesel-best-practices

Installation
SKILL.md

Diesel best practices

Use when working with Diesel ORM in Rust services, CLIs, or jobs backed by Postgres, SQLite, or MySQL.

Schema ownership

  • Treat schema.rs and the actual database schema as coupled artifacts; regenerate or update them whenever migrations change tables or columns.
  • Keep Diesel models close to their table domain and avoid giant files that mix every table, insert struct, and query helper together.
  • Use explicit field names and Rust types that mirror nullability and database constraints instead of smoothing over mismatches with ad hoc conversions.

Query builder and raw SQL

  • Prefer Diesel’s query builder for common CRUD, filtering, joins, pagination, and updates so backend-specific SQL generation stays type checked.
  • Reach for raw SQL only when the query builder becomes meaningfully less clear or cannot express the query cleanly.
  • Keep raw SQL isolated, typed, and reviewed carefully; treat it as an exception path, not the default style.

Derives and model shapes

Installs
1
First Seen
Apr 12, 2026
diesel-best-practices — alexandretrotel/skills