---
name: "sqlx-rust-async-compile-time-checked"
description: "Execute raw SQL queries in Rust with compile-time SQL syntax and type checking via query! macro."
metadata:
  author: "LaunchBadge"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "query! macro sqlx rust"
  - "cargo sqlx prepare offline"
  - "sqlx connection pool pgpool"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# SQLx Pure Rust Async SQL with Compile-Time Verification

Configures SQLx: query! and query_as! macros connecting to DATABASE_URL during cargo build, offline query caching (sqlx-data.json with cargo sqlx prepare), connection pools (PgPool), and streaming query results.

## When to Invoke
Invoke this skill whenever you need to:
- query! macro sqlx rust
- cargo sqlx prepare offline
- sqlx connection pool pgpool

## Execution SOP & Rules
1. Initialize pool: let pool = PgPoolOptions::new().max_connections(5).connect(&database_url).await?;
2. Execute verified query: let users = sqlx::query_as!(User, 'SELECT id, name, email FROM users WHERE id = $1', id).fetch_one(&pool).await?;
3. Export offline cache: cargo sqlx prepare -- --all-targets for CI verification.
4. Stream large result sets: let mut rows = sqlx::query('SELECT * FROM large_table').fetch(&pool);

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
