postgres-best-practices
Installation
SKILL.md
PostgreSQL Best Practices (psycopg, no ORM)
Core rules for every piece of database code in this project:
- No ORM — use psycopg directly.
- Inline SQL — trivial queries of 4 lines or fewer may be written inline in Python. Anything with JOINs, subqueries, CTEs, aggregations, or multiple conditions must live in its own
.sqlfile. - Named parameters — always
%(name)sstyle, never positional%s. - SQL formatting — all
.sqlfiles are formatted with shandy-sqlfmt. - Dynamic SQL — check
pyproject.tomlfor the Python version; use psycopg t-string templates on 3.14+, otherwisepsycopg.sql. See references/dynamic-sql.md. - Result mapping — every query result maps to a Pydantic model defined in a
{topic}_models.pyfile.