postgres-best-practices
Skill36 starsChanged 6 months agoMITView on GitHub
Supabase PostgreSQL best practices library — 33 impact-rated rules (CRITICAL→LOW) covering connection pooling, RLS, locking, VACUUM, full-text search, and JSONB indexing. Use when writing, reviewing, or optimizing PostgreSQL queries, schema, or configuration.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
- jornalistainclusivo/jinc-skillstheir own version, first seen Apr 22, 2026
- neondatabase/postgres-skillstheir own version, first seen Feb 11, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- neondatabase/postgres-skills★ 46same name
- baekenough/oh-my-customcode★ 43same name
- jornalistainclusivo/jinc-skills★ 1same 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 repository157 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- a2ui-angularSkill
- accessibility-auditSkill
- adk-deploy-guideSkill
- adk-dev-guideSkill
- adk-eval-guideSkill
- adk-observability-guideSkill
- agentic-ai-coding-standardSkill
- agentic-ai-devSkill
- ai-auditSkill
- ai-chatSkill
- ai-decision-recordSkill
- ai-incident-responseSkill
- ai-launch-checkSkill
- ai-playbookSkill
- angular-best-practicesSkill
- angularSkill
- angular-spaSkill
- angular-ui-patternsSkill
- api-design-principlesSkill
- app-store-optimizationSkill
- architect-reviewSkill
- architecture-decision-recordsSkill
- architecture-designSkill
- asc-cli-usageSkill
- asc-crash-triageSkill
- asc-id-resolverSkill
- asc-release-flowSkill
- asc-signing-setupSkill
- asc-submission-healthSkill
- asc-testflight-orchestrationSkill
- browser-testingSkill
- changelog-generatorSkill
- claude-actions-auditorSkill
- clean-codeSkill
- codebase-onboardingSkill
- code-explainerSkill
- code-reviewerSkill
- code-simplifierSkill
- comment-analyzerSkill
- database-schema-designerSkill
- ddd-architectSkill
- decision-frameworksSkill
- dedup-code-agentSkill
- deployment-ci-cdSkill
- design-systemSkill
- dockerSkill
- documentation-generationSkill
- domain-finderSkill
- error-detectiveSkill
- eval-guideSkill
- feature-forgeSkill
- firebase-basicsSkill
- firebase-hosting-basicsSkill
- fixing-accessibilitySkill
- fixing-motion-performanceSkill
- flutter-animationsSkill
- flutter-genuiSkill
- flutter-mobileSkill
- flutter-security-expertSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
NEVER TUNE WHAT YOU HAVEN'T MEASURED — CHECK pg_stat_statements AND pg_stat_activity BEFORE CHANGING CONFIGURATION OR ADDING INDEXES
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Iron Law
NEVER TUNE WHAT YOU HAVEN'T MEASURED — CHECK pg_stat_statements AND pg_stat_activity BEFORE CHANGING CONFIGURATION OR ADDING INDEXES
When to Use This Skill
- Configuring connection pooling (PgBouncer, Prisma pool, asyncpg pool, R2DBC pool)
- Implementing Row Level Security (RLS) for multi-tenant data isolation
- Designing worker queues with
SKIP LOCKEDand advisory locks - Preventing deadlocks in concurrent write workloads
- Configuring VACUUM/ANALYZE and autovacuum tuning
- Adding full-text search with
tsvector/tsquery - Indexing JSONB columns (
jsonb_opsvsjsonb_path_ops) - Reviewing any PostgreSQL schema or query against the 8-category rule library
Do Not Use This Skill When
- You need query EXPLAIN analysis and index pattern SQL (use
sql-optimization-patterns) - You need schema migration design or ERDs (use
database-schema-designer) - You need cloud analytics or HTAP (use
sql-pro)
Rule Categories by Priority
| Priority | Category | Impact | Rules |
| 1 | Query Performance | CRITICAL | rules/query-*.md (5 rules) |
| 2 | Connection Management | CRITICAL | rules/conn-*.md (4 rules) |
| 3 | Security & RLS | CRITICAL | rules/security-*.md (3 rules) |
| 4 | Schema Design | HIGH | rules/schema-*.md (6 rules) |
| 5 | Concurrency & Locking | MEDIUM-HIGH | rules/lock-*.md (4 rules) |
| 6 | Data Access Patterns | MEDIUM | rules/data-*.md (4 rules) |
| 7 | Monitoring & Diagnostics | LOW-MEDIUM | rules/monitor-*.md (3 rules) |
| 8 | Advanced Features | LOW | rules/advanced-*.md (2 rules) |
Quick Rule Index
Connection Management (NEW — not in other skills)
rules/conn-pooling.md— PgBouncer setup, pool size formula(cores × 2) + spindles, transaction vs session moderules/conn-limits.md—max_connectionscalculation, prevent database OOM crashrules/conn-idle-timeout.md— Reclaim 30-50% idle connection slotsrules/conn-prepared-statements.md— Prepared statement conflicts in transaction-mode pooling
Concurrency & Locking (NEW — not in other skills)
rules/lock-skip-locked.md— Atomic claim-and-update queue pattern, 10x worker throughputrules/lock-deadlock-prevention.md— Consistent lock ordering, deadlock prevention patternsrules/lock-short-transactions.md— Minimize transaction duration, 3-5x throughputrules/lock-advisory.md— Application-level coordination without row-level locks
Security & RLS (NEW depth — not in other skills)
rules/security-rls-basics.md—ALTER TABLE ... ENABLE ROW LEVEL SECURITY+ policy patternsrules/security-rls-performance.md—SECURITY DEFINERfunctions, 5-10x faster RLS queriesrules/security-privileges.md— Principle of least privilege, specific GRANT patterns
Monitoring & Maintenance (NEW — not in other skills)
rules/monitor-vacuum-analyze.md— VACUUM/ANALYZE patterns, autovacuum tuningrules/monitor-pg-stat-statements.md— Enable and querypg_stat_statementsrules/monitor-explain-analyze.md— EXPLAIN ANALYZE usage guide
Advanced Features (NEW — not in other skills)
rules/advanced-full-text-search.md—tsvector,ts_rank, GIN full-text index, 100x vs LIKErules/advanced-jsonb-indexing.md— GIN index,jsonb_opsvsjsonb_path_opstrade-off
Query Performance (complementary to sql-optimization-patterns)
rules/query-missing-indexes.md— EXPLAIN Seq Scan detectionrules/query-index-types.md— B-tree/GIN/BRIN/Hash selectionrules/query-composite-indexes.md— Leftmost prefix rulerules/query-covering-indexes.md— INCLUDE columns for Index Only Scanrules/query-partial-indexes.md— Filtered index subsets
Schema Design (complementary to database-schema-designer)
rules/schema-primary-keys.md— IDENTITY vs UUID vs UUIDv7rules/schema-data-types.md— Forbidden types, correct alternativesrules/schema-foreign-key-indexes.md— Diagnostic SQL to find all missing FK indexesrules/schema-lowercase-identifiers.md— snake_case, no quoted identifiersrules/schema-partitioning.md— Range partitioning patternsrules/schema-foreign-key-indexes.md— FK index enforcement
Stack Integration
Python / FastAPI (asyncpg + SQLAlchemy)
- Connection pooling: asyncpg pool
min_size/max_sizeconfiguration (seerules/conn-pooling.md) - RLS: set
app.current_user_idsession variable before queries - SKIP LOCKED: use in background task workers
NestJS / Prisma
- Connection pooling:
DATABASE_URL=...?connection_limit=10&pool_timeout=20(seerules/conn-pooling.md) - Prepared statements: Prisma uses prepared statements — use session mode or
pgbouncer=trueparameter - SKIP LOCKED: use
prisma.$queryRawfor queue worker queries
Java / Spring Boot WebFlux (R2DBC)
- Connection pooling:
r2dbc.pool.max-size,r2dbc.pool.initial-size(seerules/conn-pooling.md) - RLS: use
ConnectionFactorywith per-request session variable injection
Related Skills
database-schema-designer— Schema design, Flyway migrations, normalizationsql-optimization-patterns— EXPLAIN analysis, N+1, cursor pagination, batch opspostgresql— PostgreSQL-specific types, gotchas, extensions, JSONB depthsql-pro— Cloud analytics, HTAP, BigQuery/Snowflakevector-database— pgvector HNSW/IVFFlat alignment
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

