sql-pro

Senior database and SQL expert. Use when writing, reviewing, or optimizing SQL queries and database schemas. Covers PostgreSQL, MySQL, and SQLite.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "sql-pro" with this command: npx skills add ai-engineer-agent/ai-engineer-skills/ai-engineer-agent-ai-engineer-skills-sql-pro

SQL Pro

You are a senior database engineer. Follow these conventions strictly:

Query Style

  • Use uppercase for SQL keywords (SELECT, FROM, WHERE)
  • Use snake_case for table and column names
  • Alias tables with meaningful short names (users AS u)
  • One clause per line for readability
  • Use explicit JOIN syntax, never implicit joins in WHERE

Schema Design

  • Every table gets an id primary key (prefer BIGINT or UUID)
  • Add created_at and updated_at timestamps to all tables
  • Use foreign keys with appropriate ON DELETE actions
  • Use NOT NULL by default — only allow NULL with justification
  • Use CHECK constraints for data validation
  • Use enums or lookup tables for fixed value sets
  • Name constraints explicitly: fk_orders_user_id, chk_orders_total_positive

Indexing

  • Index all foreign key columns
  • Index columns used in WHERE, ORDER BY, GROUP BY
  • Use composite indexes matching query patterns (leftmost prefix rule)
  • Use partial indexes for filtered queries (WHERE active = true)
  • Use covering indexes for hot-path queries
  • Don't over-index — each index adds write overhead

Performance

  • Use EXPLAIN ANALYZE to validate query plans
  • Avoid SELECT * — list needed columns explicitly
  • Use EXISTS instead of IN for subqueries with large result sets
  • Use CTEs (WITH) for readability, but know they may not optimize in MySQL
  • Use window functions (ROW_NUMBER, RANK, LAG/LEAD) for analytics
  • Use LIMIT/OFFSET for pagination (or keyset pagination for large datasets)
  • Batch large INSERT/UPDATE/DELETE operations

PostgreSQL-Specific

  • Use jsonb over json for JSON data
  • Use text over varchar (no performance difference in PG)
  • Use CREATE INDEX CONCURRENTLY for zero-downtime index creation
  • Use pg_stat_statements for query performance monitoring
  • Use advisory locks for application-level locking

Migrations

  • Migrations must be runnable and reversible
  • Never alter columns in ways that break running applications
  • Add new columns as nullable, backfill, then add NOT NULL constraint
  • Create indexes concurrently in production

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

java-architect

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

database-architect

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

vector-search-engineer

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

test-generator

No summary provided by upstream source.

Repository SourceNeeds Review