sql-query-review
Skill0 starsChanged 5 months agoApache-2.0View on GitHub
Review and improve SQL queries for correctness, performance,
1 other project uses a version of this.
Adopted by
Most recently taken up by
- vermapragya/analytics-skilltheir own version, first seen Jun 6, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- vermapragya/analytics-skill★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository128 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibility-implementationSkill
- accessibility-reviewSkill
- api-changelogSkill
- api-designSkill
- auth-designSkill
- caching-strategiesSkill
- chaos-experiment-designSkill
- ci-cd-pipelinesSkill
- cli-designSkill
- cloudformation-reviewSkill
- codebase-orientationSkill
- code-commentsSkill
- code-reviewSkill
- commit-messagesSkill
- container-reviewSkill
- database-indexingSkill
- database-migrationsSkill
- debuggingSkill
- dependency-upgradesSkill
- design-system-contributionSkill
- design-tokensSkill
- desktop-releaseSkill
- error-handlingSkill
- feature-flagsSkill
- finops-reviewSkill
- frontend-performanceSkill
- git-conflict-resolutionSkill
- graphql-schema-designSkill
- helm-chart-scaffoldingSkill
- i18n-reviewSkill
- kubernetes-reviewSkill
- load-test-planningSkill
- logging-observabilitySkill
- message-queue-designSkill
- migration-playbooksSkill
- mobile-releaseSkill
- multi-region-active-activeSkill
- observability-alertsSkill
- openapi-spec-designSkill
- partner-api-integrationSkill
- performance-reviewSkill
- pr-descriptionsSkill
- prompt-injection-hardeningSkill
- pulumi-reviewSkill
- rate-limitingSkill
- refactor-planningSkill
- secrets-managementSkill
- security-reviewSkill
- terraform-reviewSkill
- test-generationSkill
- threat-modelingSkill
- webhook-designSkill
- websocket-designSkill
- ab-test-analysisSkill
- anomaly-detectionSkill
- cost-anomaly-investigationSkill
- csv-analysisSkill
- data-cleaningSkill
- data-contract-designSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Treat SQL as production code: correctness and safety first, then performance, then style.
- Distinctive: line 25
Check correctness: join type, filter placement, NULL semantics, aggregation grain, DISTINCT papering over fan-out.
- Distinctive: line 27
Check safety: injection (string-built SQL), over-fetch of sensitive columns, missing tenant/user predicates, destructive statements without …
- Distinctive: line 29
Check performance: selective filters, sargability, index use, N+1 patterns, SELECT *, unnecessary sorts, large OFFSET pagination.
- Very specific: line 43
EXISTS vs IN: prefer EXISTS for correlated semi-joins.
- Very specific: line 48
Prefer sargable predicates: created_at >= $1 over DATE(created_at) = … when an index exists on created_at.
- Very specific: line 55
If EXPLAIN/EXPLAIN ANALYZE is provided, cite the expensive node.
- Distinctive: line 60
Never concatenate untrusted input into SQL.
- Distinctive: line 93
Always state the dialect assumption.
- Distinctive: line 94
Do not invent table statistics, index definitions, or runtimes.
- Distinctive: line 97
Prefer readable SQL (CTEs for steps) over clever one-liners when teaching.
- Distinctive: line 98
If the query is already solid, say so and only suggest optional polish.
- Very specific: line 105
Warehouse SQL (BigQuery/Snowflake/Redshift): call out slot/cost and partition pruning instead of classic B-tree index talk when relevant.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL Query Review
Treat SQL as production code: correctness and safety first, then performance, then style. Prefer rewrites the reader can paste and run.
Workflow
- Restate what the query is trying to return (grain: one row per what?).
- Check correctness: join type, filter placement, NULL semantics, aggregation grain, DISTINCT papering over fan-out.
- Check safety: injection (string-built SQL), over-fetch of sensitive columns, missing tenant/user predicates, destructive statements without predicates.
- Check performance: selective filters, sargability, index use, N+1 patterns, SELECT *, unnecessary sorts, large OFFSET pagination.
- Deliver a rewritten query (or incremental patches) with assumptions labeled.
Correctness checklist
- Grain: joins that multiply rows before
SUM/COUNTwithout care. - NULLs:
= NULLis always unknown; useIS NULL. Outer joins + filters inWHEREthat accidentally turn them into inner joins. - Filters: predicates on the wrong side of a
LEFT JOIN; time zones and inclusive/exclusive date ranges. - Aggregates: columns in
SELECT/ORDER BYnot inGROUP BY(dialect dependent);COUNT(*)vsCOUNT(col). - Window functions:
PARTITION BY/ORDER BYmatch the business question. - EXISTS vs IN: prefer
EXISTSfor correlated semi-joins; bewareNOT INwith NULLs.
Performance checklist
- Prefer sargable predicates:
created_at >= $1overDATE(created_at) = …when an index exists oncreated_at. - Select only needed columns; avoid
SELECT *in application paths. - Pagination: keyset/cursor (
WHERE (created_at, id) < ($1, $2)) over largeOFFSET. - Watch non-selective leading wildcards (
LIKE '%foo'), functions on indexed columns, and implicit casts that block indexes. - If
EXPLAIN/EXPLAIN ANALYZEis provided, cite the expensive node; if not, propose what to measure instead of inventing timings.
Safety checklist
- Never concatenate untrusted input into SQL. Use bind parameters.
- Multi-tenant apps: every query that returns user data must constrain tenant (or equivalent) unless it is an explicitly audited admin path.
UPDATE/DELETEwithout a restrictiveWHERE(or with a join that can expand) is a blocking finding.- Limit bulk exports; avoid returning password hashes or secrets.
Output format
## SQL review
**Intent (grain):** one row per …
**Dialect assumed:** PostgreSQL | MySQL | SQLite | … (state if inferred)
### Findings
1. [blocking|important|nit] — issue and consequence
2. …
### Recommended query
```sql
-- rewritten SQLIndexes / plan notes
What index or EXPLAIN step would confirm the fix.
Test cases
2–4 inputs/edge rows that would prove correctness (NULL, empty join, duplicate parents).
## Rules
1. Always state the dialect assumption; syntax and NULL behavior differ.
2. Do not invent table statistics, index definitions, or runtimes. If schema
is missing, list what you need or give conditional advice.
3. Preserve the original business intent unless you explain a necessary change.
4. Prefer readable SQL (CTEs for steps) over clever one-liners when teaching.
5. If the query is already solid, say so and only suggest optional polish.
## Edge cases
- **ORM / query builder only**: reverse-engineer the SQL intent, show the SQL
you think it emits, and suggest either raw SQL or ORM API that parameterizes.
- **Migration / DDL mixed in**: separate data-fix from schema change advice.
- **Warehouse SQL (BigQuery/Snowflake/Redshift)**: call out slot/cost and
partition pruning instead of classic B-tree index talk when relevant.
- **User wants "just make it faster"**: refuse to sacrifice correctness;
measure first if no plan or volume info is given.Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

