Lista de Verificação para Revisar Consultas SQL Geradas por IA
Uma lista de verificação para revisão humana de SQL escrito por agentes de codificação de IA — corretude, injeção, desempenho e migrações.
CursorClaude CodeCodex PostgreSQLTypeScript
A IA escreve SQL rapidamente, mas nem sempre com segurança. Execute toda consulta gerada por IA por esta lista antes de mesclar.
Corretude
[ ] 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)Segurança
[ ] 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)Desempenho
[ ] Queries hit an index (check EXPLAIN for Seq Scan on large tables)[ ] No SELECT * in hot paths[ ] N+1 patterns batched or joinedMigrações
[ ] 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 synchronouslyPrompt de Correção
Review this SQL against the checklist above. Parameterise any concatenatedinput, add the missing tenant filter, and confirm the query uses an indexwith EXPLAIN. Return the corrected query only.