query-validation

对SQL查询进行审查和验证,以确保正确性、性能和最佳实践。当审查查询以查找逻辑错误、优化查询性能、检查SQL反模式或验证SQL中的业务逻辑实现时使用。

📖 中文导读:对SQL查询进行审查和验证,以确保正确性、性能和最佳实践。当审查查询以查找逻辑错误、优化查询性能、检查SQL反模式或验证SQL中的业务逻辑实现时使用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: query-validation description: SQL query review and validation for correctness, performance, and best practices. Use when reviewing queries for logical errors, optimizing query performance, checking for SQL anti-patterns, or validating business logic implementation in SQL.

Query Validation

Quick Start

Review SQL queries for correctness, performance, and adherence to best practices.

Context Requirements

  1. SQL Query: The query to validate
  2. Database Type: PostgreSQL, MySQL, Snowflake, BigQuery, Redshift, etc.
  3. Schema Information: Relevant table structures
  4. Business Logic (optional): What the query should calculate
  5. Performance Context (optional): Expected row counts, current runtime

Context Gathering

For query input:

"Please provide:

  1. The SQL query to validate
  2. What database system you're using (PostgreSQL, Snowflake, etc.)
  3. Relevant table schemas (or I can help you extract them)"

For schema:

"To validate joins and column references, I need table schemas. You can provide:

Option 1 - Quick: Just the tables/columns used in the query

Option 2 - Comprehensive: