PostgreSQL Table Design Guide
A reference skill that enforces PostgreSQL best practices for schema, data types, indexes, constraints, and partitioning.
Dev & CodingIntermediate★ 1,814⑂ 104AI score 9/10Last updated: Jun 26, 2026
What it does
- Enforces data type rules when creating or altering tables: TEXT over VARCHAR(n), TIMESTAMPTZ over TIMESTAMP, NUMERIC for money,
BIGINT GENERATED ALWAYS AS IDENTITYinstead ofserial. - Guides index strategy (B-tree, GIN, GiST, BRIN, partial, expression, covering) and constraints (PK, FK with explicit index, UNIQUE NULLS NOT DISTINCT, CHECK, EXCLUDE).
- Flags PostgreSQL-specific gotchas: FK columns are not auto-indexed, sequence gaps are normal, MVCC dead tuples, identifier lowercasing, heap (non-clustered) storage.
- Covers workload-specific design (update-heavy, insert-heavy, upsert), declarative partitioning, safe schema evolution/DDL, JSONB indexing patterns, and useful extensions (pg_trgm, pgvector, PostGIS, TimescaleDB).
Who it's for
- Backend and data engineers working on PostgreSQL schemas and migrations
- Teams standardizing schema reviews or ORM migration output
- Anyone designing time-series/log tables that need partitioning and index tuning
Examples
- "Design users and orders tables" → DDL with IDENTITY PK, status CHECK constraint, and explicit FK indexes.
- "My JSONB query is slow" → advice on GIN
jsonb_path_opsvs. a generated column with a B-tree index. - "How should I shard a 100M-row log table?" → RANGE partitioning by time, BRIN index, retention strategy.
· · · Install guide · · ·
Try it now, no install
Paste this into Claude to use the skill without installing anything.
Read the instructions in this file and follow them to help me: https://raw.githubusercontent.com/timescale/pg-aiguide/HEAD/skills/design-postgres-tables/SKILL.md What I want: (describe your task here)
If Claude can't open the link, open it yourself and paste the contents instead.
↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/design-postgres-tables folder from the GitHub repo timescale/pg-aiguide into my ~/.claude/skills/design-postgres-tables/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/timescale/pg-aiguide.git /tmp/pg-aiguide && mkdir -p ~/.claude/skills && cp -r /tmp/pg-aiguide/skills/design-postgres-tables ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal.
- Create the skills directory:
mkdir -p ~/.claude/skills - Clone the repo:
git clone https://github.com/timescale/pg-aiguide.git /tmp/pg-aiguide - Copy just this skill:
cp -r /tmp/pg-aiguide/skills/design-postgres-tables ~/.claude/skills/ - Restart Claude Code and ask something like "design PostgreSQL tables for an orders system" to trigger it.
- (Optional) For project-only use, copy the folder into
.claude/skills/inside your repository instead.
View source on GitHub ↗License: Apache-2.0