A Claude Code skill that checks SQL before you run it

Your first Claude Code skill can be the checklist you already run in your head before a query touches real data: joins, filters, limits, dates. The folder, the SKILL.md, and how to run it with one slash command.

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.

Nothing loads from YouTube until you press play. Then Google receives your IP address and may set its own storage. Narrated with an AI-generated voice. Privacy

What goes in the checklist?

CheckWhat goes wrongWhat the skill looks for
Join keysRows repeat and every total growsJoins on columns that are not unique on one side
DatesLast day lost, or the wrong periodBETWEEN on datetimes; filters on the wrong date column
Row limitsA query returns 40 million rowsNo TOP or LIMIT on exploratory queries
NULLsRows vanish from counts and joins= NULL instead of IS NULL; NOT IN with NULLs
WritesData changed for every rowUPDATE or DELETE without WHERE; no transaction
Five checks before a query runs

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.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.