verify-sql
Validates SQL statements before execution using comprehensive dry-run checks to catch syntax errors, schema mismatches, constraint violations (CHECK, NOT NULL, UNIQUE), foreign key violations, data type mismatches, and runtime errors without modifying the database. CRITICAL - Use this skill BEFORE executing any INSERT/UPDATE/DELETE statements. Use when you need to: (1) Verify SQL will execute successfully before running it, (2) Check foreign key references exist to prevent FK violations, (3) Validate constraint values match CHECK/enum requirements, (4) Test stored procedure calls with parameter validation, or (5) Eliminate trial-and-error debugging loops by catching errors before execution
SKILL.md
| Name | verify-sql |
| Description | Validates SQL statements before execution using comprehensive dry-run checks to catch syntax errors, schema mismatches, constraint violations (CHECK, NOT NULL, UNIQUE), foreign key violations, data type mismatches, and runtime errors without modifying the database. CRITICAL - Use this skill BEFORE executing any INSERT/UPDATE/DELETE statements. Use when you need to: (1) Verify SQL will execute successfully before running it, (2) Check foreign key references exist to prevent FK violations, (3) Validate constraint values match CHECK/enum requirements, (4) Test stored procedure calls with parameter validation, or (5) Eliminate trial-and-error debugging loops by catching errors before execution |
name: verify-sql description: Validates SQL statements before execution using comprehensive dry-run checks to catch syntax errors, schema mismatches, constraint violations (CHECK, NOT NULL, UNIQUE), foreign key violations, data type mismatches, and runtime errors without modifying the database. CRITICAL - Use this skill BEFORE executing any INSERT/UPDATE/DELETE statements. Use when you need to: (1) Verify SQL will execute successfully before running it, (2) Check foreign key references exist to prevent FK violations, (3) Validate constraint values match CHECK/enum requirements, (4) Test stored procedure calls with parameter validation, or (5) Eliminate trial-and-error debugging loops by catching errors before execution
Verify SQL Skill
Purpose
Catch SQL errors BEFORE execution by running comprehensive validation checks:
- Syntax errors (typos, invalid SQL)
- Schema errors (non-existent tables/columns)
- Constraint violations (CHECK, NOT NULL, UNIQUE)
- Foreign Key violations (references to non-existent records) ⭐
- Data type mismatches
- Dry-run execution (test without committing)
Usage
/verify-sql "<SQL statement>"
Examples:
/verify-sql "INSERT INTO zamm.workout_main (athlete_id, workout_date, status)
VALUES ('550e8400-e29b-41d4-a716-446655440000', '2026-01-11', 'draft')"
/verify-sql "UPDATE zamm.stg_imports SET athlete_id = 'abc-123' WHERE import_id = '...'"
/verify-sql "DELETE FROM zamm.workout_main WHERE workout_id = '...'"
Why This Skill Matters
Catches SQL errors BEFORE execution, eliminating trial-and-error debugging loops. See BENEFITS.md for detailed impact analysis.
Core Workflow
Step 1: Parse SQL Statement
Extract and validate the SQL statement from user input.
Step 2: Run Validation Checks
Execute validation steps in sequence:
- Syntax Validation - Check SQL syntax with EXPLAIN
- Schema Validation - Verify tables and columns exist
- Constraint Pre-Check - Validate values against CHECK/UNIQUE/NOT NULL
- Foreign Key Verification - Check referenced records exist ⭐
- Dry-Run Execution - Test in transaction with ROLLBACK
Step 3: Report Results
Present comprehensive validation report with pass/fail status and actionable fixes.
Validation Steps
See detailed documentation in references:
- SYNTAX_VALIDATION.md - Syntax checking
- SCHEMA_VALIDATION.md - Table/column verification
- CONSTRAINT_VALIDATION.md - Constraint checks
- FK_VALIDATION.md - Foreign key verification
- DRY_RUN.md - Transaction testing
Error Categories
Five main error types caught by validation:
- Syntax Errors - Invalid SQL syntax (missing keywords, typos)
- Schema Errors - Non-existent tables or columns
- Constraint Violations - Values violating CHECK, UNIQUE, NOT NULL
- Foreign Key Violations ⭐ - Referenced records don't exist
- Runtime Errors - Logic errors (division by zero, type issues)
See ERROR_CATEGORIES.md for detailed examples and fixes.
Advanced Features
See detailed documentation:
- MULTI_STATEMENT.md - Transaction validation
- STORED_PROCEDURES.md - Function call validation
- EXAMPLES.md - Complete validation examples
Integration with Other Skills
Recommended workflow:
/inspect-table <table>- See schema and constraints- Write SQL based on constraints
/verify-sql "<SQL>"- Validate before execution- Execute SQL (via MCP or psql)
Performance & Limitations
Strengths:
- Fast validation (~10-50ms)
- Catches 95%+ of runtime SQL errors
- No database modifications
Limitations:
- Cannot catch business logic errors
- Cannot detect race conditions
- Cannot predict trigger behavior
See LIMITATIONS.md for details.
Success Criteria
All validation checks pass:
- ✅ Syntax valid
- ✅ Schema verified
- ✅ Constraints satisfied
- ✅ Foreign keys exist
- ✅ Dry-run successful
Related Skills
/inspect-table- View table structure before writing SQL/sync-docs- Update schema documentation/add-entity- Add missing catalog entries
Version: 1.0.0 Last Updated: 2026-01-13 Impact: Eliminates 95%+ of SQL execution errors