
Postgres Patterns
Solid reference for the PostgreSQL patterns you'll actually need when building production apps. Covers the index cheat sheet everyone wishes they had bookmarked (composite vs GIN vs BRIN), common gotchas like RLS policy wrapping and cursor pagination over OFFSET, and those diagnostic queries for finding unindexed foreign keys or table bloat. The data type guide alone saves you from the classic varchar(255) and float-for-money mistakes. It's based on Supabase's internal patterns, so the recommendations come from teams running Postgres at scale. Activate this when writing migrations or debugging slow queries, then escalate to the database-reviewer agent if you need deeper analysis.
- skills.sh installs
- 7.1K
- GitHub stars
- 229.1K
- last updated
- Jul 14, 2026
Install
$ npx -y skills add affaan-m/everything-claude-code --skill postgres-patterns --agent claude-codeInstalls into .claude/skills of the current project.
Files
PostgreSQL Patterns
Quick reference for PostgreSQL best practices. For detailed guidance, use the database-reviewer agent.
When to Activate
- Writing SQL queries or migrations
- Designing database schemas
- Troubleshooting slow queries
- Implementing Row Level Security
- Setting up connection pooling
Quick Reference
Index Cheat Sheet
| Query Pattern | Index Type | Example |
|---|---|---|
WHERE col = value | B-tree (default) | CREATE INDEX idx ON t (col) |
WHERE col > value | B-tree | CREATE INDEX idx ON t (col) |
WHERE a = x AND b > y | Composite | CREATE INDEX idx ON t (a, b) |
WHERE jsonb @> '{}' | GIN | CREATE INDEX idx ON t USING gin (col) |
WHERE tsv @@ query | GIN | CREATE INDEX idx ON t USING gin (col) |
| Time-series ranges | BRIN | CREATE INDEX idx ON t USING brin (col) |
Data Type Quick Reference
| Use Case | Correct Type | Avoid |
|---|---|---|
| IDs | bigint | int, random UUID |
| Strings | text | varchar(255) |
| Timestamps | timestamptz | timestamp |
| Money | numeric(10,2) | float |
| Flags | boolean | varchar, int |
Common Patterns
Sponsors
Details
- Repository
- github.com/affaan-m/everything-claude-code
- Category
- Databases
More from affaan-m/everything-claude-code
All 256- Django Patterns7K
- Frontend Slides7K
- Python Patterns7K
- Api Design6.9K
- Tdd Workflow6.9K
- Docker Patterns6.8K
- Java Coding Standards6.6K
- Python Testing6.6K
- Video Editing6.6K
- Django Security6.5K
- Springboot Security6.4K
- Article Writing6.3K
- Prompt Optimizer6.3K
- Cpp Coding Standards6.2K
- Market Research6.2K
- Strategic Compact6.1K
- Android Clean Architecture6K
- Springboot Tdd6K
- Continuous Learning5.9K
- Database Migrations5.9K
- Django Tdd5.9K
- E2e Testing5.9K
- Liquid Glass Design5.9K
- Security Scan5.9K