P PasteCode
Lista de verificación

Lista de verificación para revisar consultas SQL generadas por IA

Una lista de verificación humana para SQL escrita por agentes de codificación de IA: corrección, inyección, rendimiento y migraciones.

CursorClaude CodeCodex PostgreSQLTypeScript
.md .json Actualizado 8 jun 2026

La IA escribe SQL rápido, pero no siempre de forma segura. Ejecuta cada consulta generada por IA a través de esto antes de fusionar.

Corrección

[ ] Joins use the right keys (no accidental cross joins)
[ ] NULL handling is intentional (COALESCE / IS NULL, not = NULL)
[ ] Aggregates have correct GROUP BY columns
[ ] Pagination is stable (ORDER BY a unique column)

Seguridad

[ ] No string-concatenated SQL — parameterised queries only
[ ] User input never reaches identifiers (table/column names)
[ ] Row-level access is enforced (tenant_id / user_id filter present)

Rendimiento

[ ] Queries hit an index (check EXPLAIN for Seq Scan on large tables)
[ ] No SELECT * in hot paths
[ ] N+1 patterns batched or joined

Migraciones

[ ] Migration is reversible (or explicitly one-way and documented)
[ ] No blocking locks on large tables during deploy
[ ] Defaults/backfills won't rewrite the whole table synchronously

Prompt de corrección

Fix Prompt
Review this SQL against the checklist above. Parameterise any concatenated
input, add the missing tenant filter, and confirm the query uses an index
with EXPLAIN. Return the corrected query only.