Index of every page on this site: llms.txt
All skills
macro-inc avatar

/sqlx-query-validator

@3e0a52a
by Macromacro-inc/macro6.4k stars
606
Run it yourself

Inspect Rust changes for SQLx queries. Use after modifying Rust code that adds or changes SQLx queries to ensure compile-time SQLx macros are used, run `just prepare_db` for offline query cache, and review queries for security issues. Writing a query and measuring its plan is the query-writing skill; reviewing a diff's query cost is query-review.

Use this Skill: https://skilld.dev/gh/macro-inc/macro/sqlx-query-validator

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈93 tokens for metadata: the name and description. ≈946 when used: this file.

Description uses 4.6% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈371 characters, or 4.6%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

SQLx Query Validator

Use this skill after substantial Rust changes that add, remove, or modify SQLx queries.

This is a focused review pass, not something to run after every edit. Batch related Rust changes first, then validate the changed queries before handing the task back to the user.

Scope Changed Rust Code

  1. From the repository root, identify changed Rust files using the repository's VCS:

    • If a .jj directory exists at the repository root, use Jujutsu:

      jj diff --name-only
    • Otherwise, use Git:

      git diff --name-only
  2. Inspect changed .rs files for SQLx usage, including:

    • sqlx::query
    • sqlx::query_as
    • sqlx::query_scalar
    • sqlx::query_file
    • imported variants such as query(...), query_as(...), query_scalar(...), or query_file(...)
    • macro variants such as sqlx::query!, sqlx::query_as!, sqlx::query_scalar!, and sqlx::query_file!
  3. If no SQLx queries were changed, say so in the final response and do not run just prepare_db unless the user explicitly asked for it.

Require SQLx Macros

Prefer compile-time checked SQLx macros for changed queries:

  • sqlx::query!
  • sqlx::query_as!
  • sqlx::query_scalar!
  • sqlx::query_file!

Flag changed code that calls SQLx query functions directly, such as:

sqlx::query("SELECT ...")
sqlx::query_as::<_, MyType>("SELECT ...")
sqlx::query_scalar("SELECT ...")

Replace direct function calls with the equivalent macro whenever the SQL text is static enough for SQLx to check at compile time.

Only allow direct SQLx query functions when the SQL must be dynamically assembled and cannot reasonably be expressed with a macro. In that case:

  • Keep dynamic fragments constrained to trusted allowlists, not raw user input.
  • Bind all values with .bind(...); never interpolate user-controlled values into SQL strings.
  • Add or preserve a clear comment explaining why a macro cannot be used.

Refresh SQLx Offline Cache

When SQLx queries were changed, run this from the repository root:

just prepare_db

If it fails, inspect the error. Fix in-scope query/cache issues and rerun just prepare_db. If it still fails for environmental reasons, stop and report the failure clearly.

Performance

This skill does not check query cost. The author writes and measures each query with the query-writing skill before committing it, and the query-review skill checks it before the push (through the review skill). If a changed query has no measured plan yet, run query-writing on it now.

Security Review Checklist

For each changed query, inspect for security issues:

  • No string interpolation, format!, concatenation, or raw user input in SQL text.
  • User-controlled values must be passed as SQLx bind parameters.
  • Dynamic identifiers, order-by fields, directions, table names, and column names must come from trusted allowlists.
  • Avoid leaking sensitive data by selecting or returning columns that are not needed.
  • Verify tenant, organization, user, or access-control predicates are present where the surrounding domain requires them.
  • Be cautious with destructive statements (DELETE, UPDATE, INSERT ... ON CONFLICT) and ensure predicates are correctly scoped.

Final Response

Briefly summarize:

  • Which changed SQLx queries were reviewed.
  • Whether all changed queries use SQLx macros, or why any direct function call remains justified.
  • Whether just prepare_db passed, failed, or was skipped because no SQLx queries changed.
  • Any security concerns found and fixed, or that none were found.
  • Whether each changed query has a measured plan from query-writing.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts20d3 checks · Risk SAFE
  • Gen Agent Trust Hub20d

    This skill automates the review of SQLx database queries in Rust projects to ensure security and performance. It identifies changed files via Git or Jujutsu and runs a local 'just' command to refresh the query cache. It is generally safe but carries a low risk of indirect prompt injection from repository content.

  • Socket20d

    No alerts

  • Snyk20d

    Risk: LOW · No issues

Signed by skilld at 3e0a52a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
All 1 allowed tools
Bash Read Edit Glob Grep

README badge

README badge for macro-inc/macro/sqlx-query-validator