sql-expert

Write optimized SQL queries and analyze EXPLAIN plans across major databases.

26|5|Updated Oct 26, 2025
One-click install
npx skills add https://github.com/AutumnsGrove/ClaudeSkills --skill sql-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-expert
Source: https://github.com/AutumnsGrove/ClaudeSkills/tree/main/sql-expert
Command: npx skills add https://github.com/AutumnsGrove/ClaudeSkills --skill sql-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires psycopg2-binary, mysql-connector-python, pyodbc, sqlalchemy, and includes scripts (resource) and examples (resource) and references (resource) components.

What problem does it solve?

Writing complex SQL, optimizing slow queries, designing robust schemas, and managing database changes can be time-consuming and error-prone. This Skill automates the heavy lifting, ensuring your database operations are efficient and reliable.

Core Features & Use Cases

  • Complex Query Generation: Automatically write advanced SQL queries with JOINs, CTEs, and window functions.
  • Performance Optimization: Analyze EXPLAIN plans and get recommendations for indexes and query rewrites.
  • Schema Design & Migrations: Design normalized database schemas and generate safe, zero-downtime migration scripts.
  • Use Case: You're tasked with optimizing a slow report query. Use this Skill to analyze the current query's EXPLAIN plan, identify bottlenecks, and suggest optimal indexes and a rewritten, faster query.

Quick Start

Example: Optimize a slow query

EXPLAIN ANALYZE SELECT users.name, COUNT(orders.id) as order_count FROM users LEFT JOIN orders ON users.id = orders.user_id GROUP BY users.id, users.name;

Frequently Asked Questions about sql-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow SQL queries?

Query optimization analyzes EXPLAIN plans to identify bottlenecks, recommends indexes, and rewrites queries for better performance. Run EXPLAIN ANALYZE on your slow query to see execution details, then apply index suggestions and restructure joins or subqueries to reduce cost.

Can I write complex SQL queries with JOINs and window functions?

Yes. Complex SQL queries combine JOINs, CTEs, and window functions to solve multi-table aggregations and ranking problems. Use parameterized queries to safely pass values and avoid SQL injection while maintaining readability.

How do I design a normalized database schema?

Schema design eliminates data redundancy by organizing tables into logical relationships, reducing anomalies and improving query efficiency. Define relationships between entities, apply normalization rules, and validate the structure before migration.

How do I safely migrate a database schema without downtime?

Safe migrations generate scripts with rollback capability, allowing schema changes on live databases without service interruption. Execute migrations in stages, test rollbacks first, and include indexes and constraints as part of the migration plan.

Does this work with PostgreSQL, MySQL, and SQL Server?

Yes. The Skill handles PostgreSQL, MySQL, SQLite, and SQL Server, adapting syntax and query optimization techniques to each database engine's EXPLAIN format and index capabilities.

What should I do if my SQL query returns errors or unexpected results?

SQL error debugging identifies syntax issues, constraint violations, and logic errors in queries. Check parameterization, verify table and column names, review JOIN conditions, and test with sample data to isolate the problem.