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. - Result mapping — every query result maps to a Pydantic model defined in a
{topic}_models.pyfile.
Project layout
app/
├── db/
│ ├── connection.py # pool factory + get_pg_connection()
Related skills
More from bmsuisse/skills
autoresearch
>
15codeunit-analyzer
>
14deslop
>
14coding-guidelines-python
>
13init-app-stack
Use this skill whenever the user wants to bootstrap, scaffold, or initialize a new full-stack app with a Vite + React + TanStack + shadcn/ui frontend and a FastAPI + Postgres backend. Triggers on requests like "create a new app", "set up a project", "scaffold a full-stack app", "init a new project", or anything involving starting a fresh React/FastAPI application from scratch.
12databricks-sql-autotuner
>
12