Agent Skill
2/7/2026

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

Z
zohar
0GitHub Stars
1Views
npx skills add zohar-ui/ParserZamaActive

SKILL.md

Nameverify-sql
DescriptionValidates 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:

  1. Syntax Validation - Check SQL syntax with EXPLAIN
  2. Schema Validation - Verify tables and columns exist
  3. Constraint Pre-Check - Validate values against CHECK/UNIQUE/NOT NULL
  4. Foreign Key Verification - Check referenced records exist ⭐
  5. 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:

Error Categories

Five main error types caught by validation:

  1. Syntax Errors - Invalid SQL syntax (missing keywords, typos)
  2. Schema Errors - Non-existent tables or columns
  3. Constraint Violations - Values violating CHECK, UNIQUE, NOT NULL
  4. Foreign Key Violations ⭐ - Referenced records don't exist
  5. Runtime Errors - Logic errors (division by zero, type issues)

See ERROR_CATEGORIES.md for detailed examples and fixes.

Advanced Features

See detailed documentation:

Integration with Other Skills

Recommended workflow:

  1. /inspect-table <table> - See schema and constraints
  2. Write SQL based on constraints
  3. /verify-sql "<SQL>" - Validate before execution
  4. 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

Skills Info
Original Name:verify-sqlAuthor:zohar