Reviews sqlx database code for compile-time query checking, connection pool management, migration patterns, and PostgreSQL-specific usage. Use when reviewing Rust code that uses sqlx, database queries, connection pools, or migrations. Covers offline mode, type mapping, and transaction patterns.
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Reviews sqlx database code for compile-time query checking, connection pool management, migration patterns, and PostgreSQL-specific usage. Use when reviewing Rust code that uses sqlx, database queries, connection pools, or migrations. Covers offline mode, type mapping, and transaction patterns.
sqlx Code Review
Review Workflow
Check Cargo.toml — Note sqlx features (runtime-tokio, tls-rustls/tls-native-tls, postgres/mysql/sqlite, uuid, chrono, json, migrate) and Rust edition (2024 changes RPIT lifetime capture and removes need for async-trait)
PgPool shared via Arc or framework state (not created per-request)
Pool size configured for the deployment (not left at defaults in production)
Connection acquisition timeout set
Idle connection cleanup configured
Edition 2024: Pool initialization uses std::sync::LazyLock (not once_cell::sync::Lazy or lazy_static!) for static pool singletons
Transactions
pool.begin() used for multi-statement operations
Transaction committed explicitly (not relying on implicit rollback on drop)
Errors within transactions trigger rollback before propagation
Nested transactions use savepoints (tx.begin()) if needed
Type Mapping
sqlx::Type derives match database column types
Enum representations consistent between Rust, serde, and SQL
Uuid, DateTime<Utc>, Decimal types used (not strings for structured data)
Option<T> used for nullable columns
serde_json::Value used for JSONB columns
No enum variants or struct fields named gen — reserved keyword in edition 2024 (use r#gen with #[sqlx(rename = "gen")] or choose a different name)
Edition 2024 Compatibility
Functions returning -> impl Stream or -> impl Future account for RPIT lifetime capture changes (all in-scope lifetimes captured by default; use + use<'a> for precise control)
Custom FromRow or Type trait impls use native async fn in traits where applicable (no #[async_trait] needed, stable since Rust 1.75)
Prefer #[expect(unused)] over #[allow(unused)] for compile-time query fields only used in some code paths (self-cleaning lint suppression, stable since 1.81)
Static pool initialization uses std::sync::LazyLock (not once_cell or lazy_static!)