postgres-query-expert
SKILL.md
PostgreSQL Query Expert
This skill is a definitive reference for PostgreSQL 16, covering query construction, optimization, schema management, and system introspection.
Instructions
1. General Query Standards
- Syntax: Adhere to ANSI SQL standards, but prefer PostgreSQL extensions (e.g.,
DISTINCT ON,RETURNING,LATERAL,FILTERclauses) when they provide cleaner logic or better performance. - Identifiers: Use
snake_casefor all identifiers. Only quote identifiers ("MyTable") if absolutely necessary; prefer lowercase unquoted names. - Safety:
- Parameterization: Always use parameters (
$1,$2, …) for literal values. Never inject user input directly. - Timeouts: For exploratory queries on large databases, prepend
SET LOCAL statement_timeout = '30s';. - Transactions: Use explicit
BEGINandCOMMITblocks for multi-step operations.
- Parameterization: Always use parameters (