agentleFS
bt2gobt2go/claude-skills/skills/sql-review/SKILL.md

sql-review

Skill0 starsChanged 3 months agoMITView on GitHub

Use when the user writes a query, a migration, or asks why a database call is slow or wrong.

10 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check the query for wrong results first, slow results second.

    line 8
  2. Distinctive:

    Check the joins: an unintended fan out from a one to many join silently multiplies rows and totals.

    line 13
  3. Very specific:

    Check NULL handling: NOT IN with a NULL member returns nothing, and <> never matches NULL.

    line 14
  4. Distinctive:

    Check aggregates against GROUP BY.

    line 15
  5. Very specific:

    Check filters applied in WHERE that should be in the ON clause of an outer join, which quietly makes it an inner join.

    line 16
  6. Distinctive:

    Check for missing LIMIT on anything user facing, and for unbounded date ranges.

    line 17
  7. Distinctive:

    Never suggest an index without naming the column order and the query it serves.

    line 23
  8. Distinctive:

    Never approve a destructive migration without a stated rollback.

    line 24

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SQL review

Check the query for wrong results first, slow results second.

Procedure

  1. State what the query is supposed to return in one sentence.
  2. Check the joins: an unintended fan out from a one to many join silently multiplies rows and totals.
  3. Check NULL handling: NOT IN with a NULL member returns nothing, and <> never matches NULL.
  4. Check aggregates against GROUP BY. Every non aggregated selected column must be grouped.
  5. Check filters applied in WHERE that should be in the ON clause of an outer join, which quietly makes it an inner join.
  6. Check for missing LIMIT on anything user facing, and for unbounded date ranges.
  7. Now look at performance: run EXPLAIN or EXPLAIN ANALYZE and look for sequential scans on large tables, and for functions wrapped around indexed columns.
  8. For migrations, check whether the statement takes a blocking lock, and whether it is reversible.

Rules

  • Never suggest an index without naming the column order and the query it serves.
  • Never approve a destructive migration without a stated rollback.
  • Assume production data volume, not the seed dataset.

Output format

Intent: ...
Correctness findings: <bullets, each with the wrong result it produces>
Performance findings: <bullets, each with the EXPLAIN evidence>
Suggested query: <fenced sql>

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.