sql-query-review — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited sql-query-review (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Use when reviewing or improving a SQL query from its text alone — no query profile or runtime stats required. Triggers:
.sql fileRouting to related skills:
warehouse-query-optimizationsql-correctness-reviewmodular-sql-ctesA full review often chains all three: correctness first, then this skill, then runtime profiling if still slow.
| Input | Why it matters |
|---|---|
| Query text | The thing being reviewed |
| Intent (one sentence) | "What question does this answer?" — catches queries that are fast but wrong |
| Expected output grain | One row per what? Needed to judge joins and aggregates |
| Approx table sizes | A SELECT * on 1K rows is fine; on 1B rows it's a finding |
| Run frequency | One-off ad-hoc vs hourly pipeline changes the bar |
If table sizes / frequency are unknown, review anyway and mark size-dependent findings as conditional.
sql-correctness-review before continuing.reference.md):SELECT * feeding downstream steps that use few columnswhere date(event_at) = ...) — kills partition pruningOR in join conditions (forces nested-loop-like plans)varchar = number)DISTINCT used as a band-aid for fanout (treat as a correctness smell too)UNION where UNION ALL is intended (UNION adds an expensive implicit dedup)count(distinct ...) repeated many times over the same scanGROUP BY would doRANGE BETWEEN where ROWS BETWEEN sufficesNOT IN (subquery) — both a NULL trap and often slower than NOT EXISTSORDER BY in subqueries/CTEs (wasted sort — only the final result needs order) python scripts/antipattern_scan.py my_query.sqlIt catches the mechanical patterns (SELECT *, NOT IN, UNION vs UNION ALL, function-wrapped filters, OR-joins). Treat its output as leads, not verdicts — confirm each in context.
DISTINCT that was masking fanout), flag it as a correctness finding instead of silently changing behavior. -- Row count match
select (select count(*) from old_result) as old_n,
(select count(*) from new_result) as new_n;
-- Full-row equivalence (empty result = identical)
(select * from old_result minus select * from new_result)
union all
(select * from new_result minus select * from old_result);# SQL Review: <one-line description of the query>
## Intent & grain
- **Intent:** <what question the query answers>
- **Output grain:** <one row per ...>
## Findings
| # | Severity | Location | Finding | Fix |
|---|---|---|---|---|
| 1 | Blocker | line 14 join | `orders` joined on `user_id` only — N:M fanout, then DISTINCT masks it | Join on (user_id, order_date); remove DISTINCT |
| 2 | Major | line 3 where | `date(event_at) = current_date - 1` defeats pruning | `event_at >= ... and event_at < ...` |
| 3 | Minor | line 1 | SELECT * but only 4 columns used downstream | Project explicitly |
## Optimized query
\`\`\`sql
-- [rewritten SQL]
\`\`\`
## Key changes
1. <change + why>
2. <change + why>
## Verification plan
\`\`\`sql
-- [equivalence queries]
\`\`\`
## Expected impact
- <e.g., "scan drops from full table to 1 day of partitions; DISTINCT removed after fixing fanout">
- <or "no runtime stats available — re-profile after deploying; see warehouse-query-optimization">DISTINCT "for performance" when it's masking a fanout changes results. Always trace why the dedup exists before touching it.reference.md.scripts/antipattern_scan.py — regex-based static scanner for mechanical anti-patterns. Fast first pass; not a substitute for reading the query.python scripts/antipattern_scan.py path/to/query.sql
# or pipe:
cat query.sql | python scripts/antipattern_scan.py -sql-correctness-review — deep logic check (dupes, fanout, joins, NULLs, CASE)warehouse-query-optimization — runtime-profile-driven tuning when stats are availablemodular-sql-ctes — structural refactor into staged CTEsdata-quality-audit — when the problem is the table, not the query~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.