postgres-best-practices
Skill1 starsChanged 13 days agoMITView on GitHub
Production PostgreSQL engineering for high-concurrency applications. Enforces optimal B-tree and GIN indexing, sub-10ms query execution plans, connection pooling (PgBouncer/Supavisor), and deadlock-free transaction isolation.
We split this skill into the rules it gives an agent
7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
B-tree Indexes: Always index foreign keys (REFERENCES) to avoid full table scans during cascading deletes and JOIN operations.
- Distinctive: line 16
EXPLAIN (ANALYZE, BUFFERS): Verify query plans before shipping.
- Very specific: line 17
Partial Indexes: Use WHERE active = true or WHERE status = 'pending' for skewed distributions to keep index size minimal and cache-resident.
- Distinctive: line 20
Lock Escalation Defense: Avoid long-running transactions.
- Very specific: line 21
Safe Migrations: Add columns with default values as DEFAULT ...
- Very specific: line 22
Deadlock Prevention: Always acquire locks on rows in deterministic primary-key order (SELECT ...
- Distinctive: line 25
Use connection poolers (PgBouncer in transaction mode or Supavisor) to support thousands of concurrent client connections without memory …
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PostgreSQL Production Best Practices (Supabase & Neon Standards)
Engineering guidelines for robust, high-performance PostgreSQL databases.
1. Indexing & Query Execution Plans
- B-tree Indexes: Always index foreign keys (
REFERENCES) to avoid full table scans during cascading deletes and JOIN operations. - Composite Indexes: Order composite index columns by equality filters first, then range/sorting operators (
WHERE tenant_id = ? AND created_at > ?->INDEX (tenant_id, created_at)). - EXPLAIN (ANALYZE, BUFFERS): Verify query plans before shipping. Eliminate sequential scans on tables with >1,000 rows.
- Partial Indexes: Use
WHERE active = trueorWHERE status = 'pending'for skewed distributions to keep index size minimal and cache-resident.
2. Concurrency & Transaction Isolation
- Lock Escalation Defense: Avoid long-running transactions. Never hold database locks while performing external network requests (HTTP, email, Stripe calls).
- Safe Migrations: Add columns with default values as
DEFAULT ...(instant in Postgres 11+). Create indexes concurrently withCREATE INDEX CONCURRENTLYto avoid table lockouts. - Deadlock Prevention: Always acquire locks on rows in deterministic primary-key order (
SELECT ... FOR UPDATE ORDER BY id).
3. Connection Pooling & Resource Scaling
- Use connection poolers (PgBouncer in transaction mode or Supavisor) to support thousands of concurrent client connections without memory exhaustion.
- Enforce strict query timeouts:
statement_timeout = '5s'to prevent rogue runaway queries from starving connection pools.
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- neondatabase/postgres-skills★ 46same name
- baekenough/oh-my-customcode★ 42same name
- kumaran-is/claude-code-onboarding★ 35same name
- bcastelino/agent-skills-kit★ 2same name
- Ghosteken/agent-harness★ 2same name
- allanninal/claude-code-skills★ 1same name
- jornalistainclusivo/jinc-skills★ 1same name
- mahik504/orchestra-workflow★ 1same name
- storlay/crypto-alert-api★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- antigravity-agent/AGENTS.mdAGENTS.md
- claude-code-agent/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- ci/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/01-craftsman.mdcCursor rule
- .cursor/rules/02-architecture-standards.mdcCursor rule
- .cursor/rules/03-security-directives.mdcCursor rule
- .cursor/rules/04-testing-tdd.mdcCursor rule
- .cursor/rules/05-design-standards.mdcCursor rule
- adversarial-code-reviewSkill
- agi-god-modeSkill
- audit-context-buildingSkill
- brainstormingSkill
- craftsman-evaluatorSkill
- creative-pipeline-conductorSkill
- data-science-masterSkill
- differential-reviewSkill
- flaw-remediatorSkill
- game-developerSkill
- hacker-modeSkill
- hallwright-memorySkill
- next-best-practicesSkill
- omni-executorSkill
- persona-activatorSkill
- prompt-firstSkill
- reverse-engineer-anythingSkill
- spatial-3d-physicsSkill
- subagent-driven-developmentSkill
- super-web-devSkill
- swarm-intelligenceSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- threejs-masterySkill
- writing-plansSkill
- zero-drift-sentinelSkill
- hwmemSkill
- prompt-firstSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

