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.
SkillScore82Maintained
Automatic
◆Coding pack
Last verified 8/16/2026
What it changes
Passed 18 of 22 test cases with the skill, and 15 of 22 without it.
Without skill68%
With skill82%
Checks it passed that the model alone missed
The CI check references cargo sqlx prepare --check.
The foreign key constraint is added only after existing data is validated.
The verification instructions recommend running cargo sqlx prepare --check.
3 fixed15 passed either way4 still failing0 broke
Pass-rate lift
+14 pp
Tokens
+12%
Agent turns
0%
Response time
-15%
Model gemini-3.6-flashMeasured 8/16/2026v118 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 3
Prompt
I need to add a new `user_settings` feature to our Rust web service backed by PostgreSQL. Please generate the migration file to create the table and provide a SQLx repository module in Rust that allows retrieving a user's settings or returning None if not found, as well as saving updated settings. Make sure to pass database connections properly and include verification steps to validate offline query metadata.
What was checked, without and with the skill
Checked
Without skill
With skill
The verification instructions recommend running cargo sqlx prepare --check.
Missed
Passed
The lookup repository function uses fetch_optional.
Passed
Passed
The database pool or connection is passed explicitly as a parameter into repository functions.
Passed
Passed
case-01 · gemini-3.6-flash · 8/16/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md75 lines4 filesincludes scripts
Rust SQLx Postgres Service
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.
Core Workflow
Inspect Cargo.toml, migrations/, .sqlx/, docker-compose.yml, CI, and
existing database helper modules before changing code.
Design the schema change first. Create or update a migration before writing
repository code that depends on it.
Prefer sqlx::query! and query_as! for compile-time checked SQL. Use
dynamic SQL only when the query shape truly changes at runtime.
Inject PgPool, PgConnection, or Transaction explicitly. Do not create a
pool inside handlers or repository functions.
Keep repository functions small and named by behavior. Return domain types
or persistence DTOs instead of leaking raw rows through the app.
Use a transaction for multi-step operations that must commit or roll back
together.
Add or update integration tests that run migrations and exercise the public
behavior when the change affects API semantics.
Run the bundled preflight script or the repository's equivalent SQLx/Cargo
CI commands.
Migration Rules
Read references/migration-safety.md before changing existing tables or data.
Default migration preferences:
Use additive changes first: new nullable columns, new tables, new indexes.
Backfill separately from schema creation when a table may be large.
Add not null, uniqueness, and foreign-key constraints only after existing
data satisfies them.
Name constraints and indexes deliberately when they will appear in errors or
operations.
Keep down migrations if the project uses them; otherwise document rollback
expectations in the migration review.