← Back to list

rust-sqlx
by ohaddahan
⭐ 4🍴 1📅 Jan 21, 2026
SKILL.md
name: rust-sqlx description: | Rust SQLx patterns for PostgreSQL. Covers compile-time checked queries (sqlx::query!), runtime queries with FromRow, migrations with sqlx-cli, offline mode with sqlx prepare, and idiomatic Rust coding style for database access. Use when: writing Postgres queries in Rust, setting up database migrations, debugging sqlx compile errors, or optimizing database code structure. user-invocable: true allowed-tools: Read, Glob, Grep, Edit, Write, Bash(cargo:), Bash(sqlx:)
Rust SQLx Skill (PostgreSQL)
What this Skill is for
Use this Skill when:
- Writing database queries in Rust with sqlx
- Setting up or modifying PostgreSQL migrations
- Debugging compile-time query errors
- Structuring database access layers
- Using
sqlx preparefor offline/CI builds - Converting between compile-time and runtime queries
Stack decisions (opinionated)
-
Prefer compile-time queries (
query!,query_as!) when:- Query structure is known at compile time
- You want maximum type safety
- Working with fixed schemas
-
Use runtime queries (
query,query_as) when:- Building dynamic WHERE clauses
- Table/column names come from configuration
- Prototyping before committing to schema
-
Always use connection pools (
PgPool) in applications- Never pass raw connections around
- Configure pool size based on workload
-
Migrations via sqlx-cli
- Reversible migrations by default
- Keep migrations small and focused
- Never modify deployed migrations
Operating procedure
1. Classify the task
- New query (compile-time vs runtime)
- Schema change (migration)
- Connection/pool setup
- CI/offline mode setup
- Error handling patterns
2. Pick the right pattern
- Compile-time:
query!,query_as!,query_scalar! - Runtime:
query,query_aswithFromRow - Transactions:
pool.begin()+tx.commit() - Batch operations:
QueryBuilderfor bulk inserts
3. Follow struct conventions
- All fields public (per project rules)
- Derive
FromRowfor database structs - Use dedicated input structs for 3+ parameters
4. Run verification
cargo sqlx prepareafter query changescargo checkto verify compile-time queries- Test with actual database connection
Progressive disclosure (read when needed)
- Compile-time and runtime queries: queries.md
- Schema migrations: migrations.md
- Offline mode and sqlx prepare: prepare.md
- Coding patterns and style: patterns.md
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon