DB

Database (PostgreSQL) SQL best practices for clean, performant, and maintainable queries. Use when writing or reviewing SQL, schema changes, or database-related guidance. Use when this capability is needed.

tomevault-io Updated

File contents

Database Stack Skill

Default guidance

Use the PostgreSQL rule file in this folder as the authoritative reference.

Workflow (use this order)

  1. Confirm schema context and target tables/columns.
  2. Draft query with explicit columns and clear aliases.
  3. Prefer CTEs for readability and reuse.
  4. Avoid NOT IN; use NOT EXISTS or LEFT JOIN ... IS NULL.
  5. Run explain analyze and address sequential scans.
  6. Add or adjust indexes if query plan needs them.

Review Checklist

  • Naming uses snake_case; SQL keywords are lowercase.
  • Explicit joins used; no implicit joins.
  • select * avoided; columns are explicit.
  • NOT IN avoided with NULL-safe alternatives.
  • Query plan checked with explain analyze.

Local Resources

  • postgresql.mdc for naming, formatting, query patterns, and performance guidance.

Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/heyayushh--stacc--databases commit e017464a1e

Frequently asked questions

npx skillmds@latest add tomevault-io/db-4