sql-analyst

Write clean SQL queries and normalized schemas for PostgreSQL, MySQL, BigQuery, and SQLite.

3|2|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/grasberg/sofia --skill sql-analyst-grasberg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-analyst
Source: https://github.com/grasberg/sofia/tree/main/workspace/skills/sql-analyst
Command: npx skills add https://github.com/grasberg/sofia --skill sql-analyst-grasberg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SQL experts who craft readable, maintainable queries using CTEs, descriptive names, and minimal nesting to simplify data work and improve performance.

Core Features & Use Cases

  • Query writing & readability: produce clean, well-commented SQL using CTEs over complex subqueries.
  • Schema design: design normalized (3NF) schemas with clear entity relationships, constraints, and indexing guidance.
  • Performance optimization: analyze execution plans, optimize joins, and recommend indexing strategies.
  • Dialect versatility: supports PostgreSQL, MySQL, BigQuery, and SQLite with dialect-aware queries.
  • Migrations & validation: handle reversible DDL changes and data transformations with validation steps.
  • Anti-pattern detection: flag N+1 queries, SELECT * usage, and unsafe patterns.
  • Guided testing: provide testing and validation guidance to ensure reliable results.

Quick Start

Ask SQL-Analyst to design a normalized schema and produce a clean, optimized SQL query for PostgreSQL.

Frequently Asked Questions about sql-analyst

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

FAQPage Schema
How do I write clean and maintainable SQL queries using CTEs?

Clean SQL queries use Common Table Expressions (CTEs) to replace complex subqueries, reducing nesting and improving readability. This approach simplifies data work by breaking down logic into descriptive, well-commented steps that are easier to maintain and optimize.

What is the best way to design a normalized SQL schema with clear constraints?

Normalized SQL schema design organizes data into third normal form (3NF) with clear entity relationships and constraints. This reduces data redundancy and complexity while providing indexing guidance to improve overall query performance.

Does this SQL optimization approach work with PostgreSQL, MySQL, BigQuery, and SQLite?

Yes, this approach supports PostgreSQL, MySQL, BigQuery, and SQLite. It generates dialect-aware SQL queries, ensuring syntax complies with specific database requirements while maintaining clean formatting and safe defaults across platforms.

How do I detect and fix SQL anti-patterns like N+1 queries and SELECT *?

SQL anti-pattern detection identifies issues like N+1 queries and SELECT * usage by flagging unsafe patterns. It recommends safe defaults and optimized joins, analyzing execution plans to guide indexing strategies and resolve performance bottlenecks.

Can I handle reversible database migrations and DDL changes safely?

Yes, you can handle reversible DDL changes and data transformations safely. The process includes validation steps and inline documentation to ensure reliable database migrations, preventing data loss during schema modifications.

How do I optimize SQL joins and execution plans for better performance?

SQL performance optimization analyzes execution plans to identify bottlenecks and optimize joins. It recommends specific indexing strategies and flags unsafe patterns, ensuring queries run efficiently across supported database dialects.