sqlx-code-review
БесплатноБез исполняемых скриптовНе проверенReviews sqlx database code for compile-time query checking, connection pool management, migration patterns, and PostgreSQL-specific usage. Use when reviewing…
от existential-birds★ 92 звезды на GitHubОб этом скилле
sqlx Code Review
Review Workflow
- Check Cargo.toml — Note sqlx version (
0.8vs0.9+), features (runtime-tokio,tls-rustls/tls-native-tls,postgres/mysql/sqlite,uuid,chrono,json,migrate), and Rust edition (2024 changes RPIT lifetime capture and reserves lowercasegen) - Check query patterns — Compile-time checked (
query!,query_as!) vs runtime (query,query_as) - Check pool configuration — Connection limits, timeouts, idle settings
- Check migrations — File naming, reversibility, data migration safety
- Check type mappings — Rust types align with SQL column types
Gates (evidence before severity)
Complete in order; do not assign Critical / Major until the gate for that claim is passed.
- Scope — Identify the crate under review (
Cargo.tomlpath) and the.rsfiles (or directory) you opened. Pass: At least one concrete path you inspected is named. - sqlx / compile claims — Before asserting issues about
query!/query_as!, offline mode,.sqlx/,sqlx.toml(0.9+),DATABASE_URL, or Cargo features: open the relevantCargo.tomland, if applicable,sqlx.tomlor documented env. Pass: The finding cites a line or you state that those files were absent / out of scope. - Finding anchors — Each reported issue includes
[FILE:LINE]per Output Format. Pass: No Critical or Major without a line reference. - Protocol — Load and complete the review-verification-protocol skill after gates 1–3 and before final severity labels. Pass: Protocol steps satisfied for each retained finding.
Output Format
Report findings as:
[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.
Quick Reference
| Issue Type | Reference |
|---|---|
| Query macros, bind parameters, result mapping | references/queries.md |
| Migrations, pool config, transaction patterns | references/migrations.md |
Review Checklist
Query Patterns
- Compile-time checked queries (
query!,query_as!) used where possible - Offline mode configured properly (
.sqlx/+SQLX_OFFLINE=trueinsqlx 0.8+, orsqlx.tomlinsqlx 0.9+) orDATABASE_URLset for compile-time checking - No string interpolation in queries (SQL injection risk) — use bind parameters (
$1,$2) -
query_as!maps to named structs, not anonymous records, for public APIs -
.fetch_one(),.fetch_optional(),.fetch_all()chosen appropriately -
.fetch()(streaming) used for large result sets
Connection Pool
-
PgPoolshared viaArcor 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
- Async pool singletons use framework state (
State<PgPool>) ortokio::sync::OnceCell::get_or_try_init(neverLazyLock+Handle::current().block_on)
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::Typederives match database column types - Enum representations consistent between Rust, serde, and SQL
-
Uuid,DateTime<Utc>,Decimaltypes used (not strings for structured data) -
Option<T>used for nullable columns -
serde_json::Valueused for JSONB columns - No struct fields or identifiers named lowercase
gen— reserved keyword in edition 2024 (user#genwith#[sqlx(rename = "gen")]or choose a different name)
Edition 2024 Compatibility
- Functions returning
-> impl Streamor-> impl Futureaccount for RPIT lifetime capture changes (all in-scope lifetimes captured by default; use+ use<'a>when excluding unrelated lifetimes) - Async repository/store traits use native
async fnin traits where applicable (no#[async_trait]needed since Rust 1.75 unlessdyn Traitis required; notesqlx::FromRowandsqlx::Typeare synchronous traits) - 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)
Migrations
- Migration files follow naming convention (
YYYYMMDDHHMMSS_description.sql) - Destructive migrations (DROP, ALTER DROP COLUMN) are reversible or have data backup plan
- No data-dependent schema changes in same migration as data changes
-
sqlx::migrate!()called at application startup
Severity Calibration
Critical
- String interpolation in SQL queries (SQL injection)
- Missing transaction for mult
Установить sqlx-code-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sqlx-code-review?
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?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sqlx-code-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic