Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when adding, changing, testing, or reviewing Postgres persistence in Rust services that use sqlx, especially when designing migrations, query! or query_as! calls, PgPool injection, transactions, compile-time checked SQL, SQLx offline mode, repository boundaries, or database-backed integration tests.
.claude/skills/hashgraph-online-rust-sqlx-postgres-service/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 6% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 8% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 6% | 0% |
Use this skill to make Rust/Postgres changes schema-first, compile-checked, and testable. Prefer explicit migrations, injected pools, narrow repository functions, and transaction boundaries that match the business operation.
Cargo.toml, migrations/, .sqlx/, docker-compose.yml, CI, andexisting database helper modules before changing code.
repository code that depends on it.
sqlx::query! and query_as! for compile-time checked SQL. Usedynamic SQL only when the query shape truly changes at runtime.
PgPool, PgConnection, or Transaction explicitly. Do not create apool inside handlers or repository functions.
or persistence DTOs instead of leaking raw rows through the app.
together.
behavior when the change affects API semantics.
CI commands.
Read references/migration-safety.md before changing existing tables or data.
Default migration preferences:
not null, uniqueness, and foreign-key constraints only after existingdata satisfies them.
operations.
expectations in the migration review.
Read references/sqlx-patterns.md for SQLx macro, transaction, and offline mode details.
fetch_optional for lookup-by-key operations.execute for inserts/updates where row data is not needed.RETURNING when the caller needs generated IDs or timestamps.one row.
Run from the Rust project root when the standard SQLx workflow applies:
bashpath/to/rust-sqlx-postgres-service/scripts/sqlx-preflight.sh
The script is conservative: it checks formatting and tests, inspects SQLx migration state when the CLI and DATABASE_URL are available, verifies SQLx offline metadata with cargo sqlx prepare --check when .sqlx/ or DATABASE_URL is available, and only applies migrations when RUST_SQLX_PREFLIGHT_RUN_MIGRATIONS=1 is set.
If the repository has a different CI command, use that command and explain why.
references/sqlx-patterns.md: query!, query_as!, pools, transactions,feature flags, and offline mode.
references/migration-safety.md: safe migration sequencing and rolloutchecks.
Other measured skills in the registry, with their headline benchmark lift.