Short answer: make a folder .claude/skills/sql-check/ with one file, SKILL.md: a name and a description between --- lines, then your checklist. Run it with /sql-check and the file name, or just ask "check this query before I run it" and Claude loads it because the description matches. A good checklist covers joins that multiply rows, missing date filters, no row limit, NULL handling and writes (UPDATE, DELETE) that need a WHERE.
Most bad SQL is not exotic. It is a join on a non-unique key, a filter on the wrong date, or a DELETE without a WHERE. A checklist catches them, but only if someone runs it every time. A skill runs it every time.
What goes in the checklist?
| Check | What goes wrong | What the skill looks for |
|---|---|---|
| Join keys | Rows repeat and every total grows | Joins on columns that are not unique on one side |
| Dates | Last day lost, or the wrong period | BETWEEN on datetimes; filters on the wrong date column |
| Row limits | A query returns 40 million rows | No TOP or LIMIT on exploratory queries |
| NULLs | Rows vanish from counts and joins | = NULL instead of IS NULL; NOT IN with NULLs |
| Writes | Data changed for every row | UPDATE or DELETE without WHERE; no transaction |
What does the SKILL.md look like?
---
name: sql-check
description: Use before running or committing any SQL query, or when asked to review SQL.
---
Check the query against these points and report each as OK or PROBLEM with the line:
1. Join keys: is each join on a unique key on at least one side? If not, rows may repeat.
2. Dates: BETWEEN on a datetime column? Filter on the right date column?
3. Limits: an exploratory SELECT without TOP or LIMIT?
4. NULLs: "= NULL", or NOT IN on a column that can be NULL?
5. Writes: UPDATE or DELETE without WHERE, or outside a transaction?
Do not run the query. Suggest the fixed line for every PROBLEM."Do not run the query" keeps the check a check.
How do you use it?
- Before running:
/sql-check queries/monthly_revenue.sql. - Automatically: ask for a query and add "then check it"; the description makes Claude load the skill.
- For the team: commit the folder; everyone who opens the project gets the same check.
Where can you check this?
Where do you start?
For DAX instead of SQL, see a skill for your DAX conventions. For a reviewer that works in its own context, see a custom SQL reviewer agent.