postgresql-expert-best-practices-code-review — Claude Code skill
A rule set for PostgreSQL schemas, migrations and indexes. Your agent reads it while writing or reviewing SQL.
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a claude-codeWhat postgresql-expert-best-practices-code-review does
The skill ships as ten rule files under rules/. Each one explains why the rule matters, its impact level, a migration example that goes wrong, and a corrected version. Priorities are grouped: index management first, then constraint safety, schema design, and naming standards.
Several rules target the ways migrations hurt a live database. Indexes should be built with CONCURRENTLY so writes keep flowing. Foreign keys get added unvalidated and checked in a separate step. A NOT NULL change comes after a check constraint. For JSON columns, pick JSONB. Uniqueness is split into a concurrent index plus a constraint.
Structure conventions are covered too: every table carries id, created_at and updated_at, a non-unique index stays within three columns, indexes follow idx_tablename_columnname, columns use snake_case. Nothing here executes on its own. It is reference material the agent consults before emitting SQL. Left to itself, a model will happily run CREATE INDEX without CONCURRENTLY on a busy table, so read the generated migration before it reaches production.
What it helps with
- build an index on a large table without blocking writes
- attach a foreign key without a long lock
- switch a column to NOT NULL with no downtime
- pick JSONB over JSON for fields you query
- keep index and column names consistent
Example prompts for the agent
- Write a migration adding a
statuscolumn toorders, following the skill's rules - Review this migration and flag where it breaks PostgreSQL best practices
- Design a
paymentstable using the skill's guidelines
How to install postgresql-expert-best-practices-code-review
1Skills CLI (Vercel)
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a claude-code2Manually: put the files in place
~/.claude/skills/postgresql-expert-best-practices-code-review/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/postgresql-expert-best-practices-code-review/
1Skills CLI (Vercel)
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a codex2Manually: put the files in place
.agents/skills/postgresql-expert-best-practices-code-review/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a cursor2Manually: put the files in place
.cursor/skills/postgresql-expert-best-practices-code-review/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wispbit-ai/skills postgresql-expert-best-practices-code-review2Manually: put the files in place
.github/skills/postgresql-expert-best-practices-code-review/SKILL.md1Skills CLI (Vercel)
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a gemini-cli2Platform CLI
gemini skills install https://github.com/wispbit-ai/skills --path skills/postgresql-expert-best-practices-code-reviewManually: put the files in place
.devin/skills/postgresql-expert-best-practices-code-review/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about postgresql-expert-best-practices-code-review
How do I install postgresql-expert-best-practices-code-review in Claude Code?
Run npx skills add wispbit-ai/skills --skill postgresql-expert-best-practices-code-review -a claude-code. The skill file lands at ~/.claude/skills/postgresql-expert-best-practices-code-review/SKILL.md.
What does this skill do?
It hands the agent a set of PostgreSQL guidelines covering schema design, migrations and indexes. The agent pulls them in whenever it writes or edits SQL.
Which platforms support it?
Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each has its own install command.
Source text
SKILL.md · MIT
--- name: postgresql-expert-best-practices-code-review description: PostgreSQL database design, migration, and performance optimization best practices. This skill should be used when writing, reviewing, or refactoring database schemas, migrations, or query patterns. Triggers on tasks involving PostgreSQL databases, schema design, migration optimization, or data modeling. license: MIT metadata: author: wispbit version: "1.0.0" --- # PostgreSQL Expert Best Practices Simple, pragmatic, opinionated. Only what matters for writing production-grade PostgreSQL queries. ## When to Apply Reference these guidelines when: - Writing database migrations or schema changes - Creating or modifying PostgreSQL tables and columns - Adding indexes, constraints, or foreign keys - Reviewing database schema for performance issues - Refactoring existing database structures - Optimizing query performance or database design ## Rule Categories by Priority | Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Index Management | CRITICAL-HIGH | `only-concurrent-indexes`, `add-index-for-foreign-key` | | 2 | Constraint Safety | HIGH | `unique-constraint`, `split-foreign-key`, `set-column-not-null` | | 3 | Schema Design | MEDIUM | `only-jsonb`, `always-include-columns`, `limit-non-unique-index` | | 4 | Naming Standards | LOW | `index-naming-standards`, `column-naming-standards` | ## Quick Reference - `only-concurrent-indexes` - Always use CONCURRENTLY to prevent blocking writes during index creation - `add-index-for-foreign-key` - Create indexes for foreign keys to improve query performance - `unique-constraint` - Split unique constraint creation into concurrent index + constraint steps - `split-foreign-key` - Add foreign keys without validation first, then validate separately - `set-column-not-null` - Use check constraints before setting NOT NULL to avoid table locks - `only-jsonb` - Use JSONB instead of JSON for better performance and indexing capabilities - `always-include-columns` - Include id, created_at, and updated_at in all tables for auditability - `limit-non-unique-index` - Limit non-unique indexes to maximum three columns for efficiency - `index-naming-standards` - Use consistent index naming: idx_tablename_columnname - `column-naming-standards` - Maintain consistent snake_case naming and use id suffix for foreign keys ## How to Use Read individual rule files for detailed explanations and code examples: ``` rules/only-concurrent-indexes.md rules/add-index-for-foreign-key.md rules/unique-constraint.md rules/split-foreign-key.md rules/set-column-not-null.md rules/only-jsonb.md rules/always-include-columns.md rules/limit-non-unique-index.md rules/index-naming-standards.md rules/column-naming-standards.md ``` Each rule file contains: - Brief explanation of why it matters - Impact level and description - Incorrect migration example with explanation - Correct migration example with best practices - Additional context and references
© wispbit · MIT · wispbit-ai/skills