Capstone — the SQL correctness checklist
Close the series by turning nine lessons into one standing checklist: a grain statement for every SELECT, a cardinality justification for every join, NULL-safe anti-joins, explicit casts, lint in CI, and one decision rule for slow queries. Each line cites the lesson that earned it, and the checklist ends where the review agent ends — with findings that cite severity, location, rule, and fix.
At a glance
| When | A new query, model, or PR needs one pass that covers the whole series; A quarterly review needs one page that covers the whole python-sql series |
|---|---|
| Where | SQL |
| Why | Nine lessons become production-ready when each rule on this checklist is a standing check with an owner, not a memory. |
Learning objectives
- Assemble the series' rules into one checklist you can run on any query
- Turn each checklist line into a standing check with an owner
- Emit findings with severity, location, rule, and fix
What you need
- The series lessons 1-9 completed
- [object Object]
- [object Object]
Steps
- Line one, from lesson 1 — ask the first question: what is the grain of this result? If the author can't answer, stop. (from skill-sql-review )
- Line two, from lesson 3 — every join states its cardinality (1:1, N:1, N:N) and justifies it. (from skill-sql-review )
- Line three, from lessons 3 and 4 — prove a join cannot fan out before writing it. (from skill-sql-review )
- Line four, from lesson 8 — NOT IN where the subquery can return NULL is banned; use NOT EXISTS. (from skill-sql-review )
- Line five, from lesson 8 — comparisons across types must be explicit casts, not implicit. (from skill-sql-review )
- Line six, from lesson 5 — integrate SQLFluff into CI/CD pipelines so the structure rules hold without review time. (from rule-pack-sqlfluff-core )
- Line seven, from lesson 6 — for the slow query, decide between an index, a rewrite, or a stats refresh. (from skill-sql-query-plan )
- The standing output — a findings list (severity, location, rule, fix) and a grain statement for each SELECT. (from agent-sql-reviewer )
Check yourself
- You can run the whole checklist on a query you have never seen and produce findings with severity, location, rule, and fix.
- Each checklist line names the lesson and the rule that backs it.
- The checklist is wired into CI — lint and review rules run without a human remembering them.
Worked example
The standing review output — from agent-sql-reviewer
Findings list (severity, location, rule, fix)
Grain statement for each SELECT
Install the review skill the checklist runs on — from skill-sql-review
npx de-agent-platform add sql-review
Sourced from
Security scan
Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.
Common gotchas
- A checklist that lives in a doc rots — wire the lint and review rules into CI instead.
- Stop at the first violation; five findings at once hide which fix worked.
- The checklist checks correctness first — the plan reading comes after the query is right.
Production considerations
- Assign an owner to each line — an unowned check is a wish.
- Keep the 12-case evaluation fixture in CI so the review rules stay honest.
Diagram
capstone checklist
|
|- grain statement --> every SELECT (lesson 1)
|
|- join cardinality + no fan-out --> every join (lessons 3-4)
|
|- NOT EXISTS + explicit casts --> every predicate (lesson 8)
|
|- sqlfluff in CI --> structure (lesson 5)
|
|- one fix per slow query --> index, rewrite, or stats refresh (lesson 6)
|
|- findings --> severity, location, rule, fix
Registry stats
| Verification | community · Oct 23, 2026 |
|---|---|
| Completeness | 81 |
| Trust multiplier | ×1.25 |
| Composite | 34.15 · adequate |
| Freshness | 1 days since last source check |
| Difficulty | intermediate |
| Version | 0.1.0 |
| License | CC-BY-4.0 |
| Security flags | none |
Did this solve your problem?
Capstone — the SQL correctness checklist