
Design postgres tables
Guides an agent through PostgreSQL table design, types, constraints and indexing
Design postgres tables is an open-source agent skill for databases. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.
- Scripts
- None
- Platforms
- Claude Code, Codex, Cursor
- GitHub stars
- 1.9K
- Last commit
- License
- Apache-2.0
- Listing updated
Similar skills
About Design postgres tables
This skill gives the agent a reference-style playbook for designing PostgreSQL tables. It covers choosing column types, primary and foreign keys, NOT NULL and CHECK constraints, unique rules, and which index type fits a given access pattern, including B-tree, GIN, GiST and BRIN. It also includes guidance for JSONB columns, partitioning, row-level security, and tables that are update-heavy, insert-heavy or upsert-driven.
The skill is instructional only. It contains no scripts, so the agent works from the rules and SQL examples in the document, such as a users, orders and profiles schema. It flags common PostgreSQL pitfalls, for example that foreign key columns are not indexed automatically, that identifiers fold to lowercase, and that sequence gaps are normal.
The guidance targets PostgreSQL and mentions version-specific features such as NULLS NOT DISTINCT and uuidv7 for PG18+, so the agent should check the target server version. Extensions like TimescaleDB, PostGIS, pgvector and pgcrypto are referenced where relevant.
When your agent uses it
Use this skill for general PostgreSQL table design. **Trigger when user asks to:** - Design PostgreSQL tables, schemas, or data models when creating new tables and when modifying existing ones. - Choose data types, constraints, or indexes for PostgreSQL - Create user tables, order tables, reference tables, or JSONB schemas - Understand PostgreSQL best practices for normalization, constraints, or indexing - Design update-heavy, upsert-heavy, or OLTP-style tables **Keywords:** PostgreSQL schema, table design, data types, PRIMARY KEY, FOREIGN KEY, indexes, B-tree, GIN, JSONB, constraints, normalization, identity columns, partitioning, row-level security Comprehensive reference covering data types, indexing strategies, constraints, JSONB patterns, partitioning, and PostgreSQL-specific best practices.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 1 file (16 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the pg plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguideOr copy only this skill to ~/.claude/skills/design-postgres-tables:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/design-postgres-tables &&
cp -R "$tmp/skills/design-postgres-tables" ~/.claude/skills/design-postgres-tables &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/design-postgres-tables inside it instead.
Copy the skill folder to ~/.agents/skills/design-postgres-tables to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/design-postgres-tables &&
cp -R "$tmp/skills/design-postgres-tables" ~/.agents/skills/design-postgres-tables &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/design-postgres-tables inside it instead.
Copy the skill folder to ~/.cursor/skills/design-postgres-tables to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/design-postgres-tables &&
cp -R "$tmp/skills/design-postgres-tables" ~/.cursor/skills/design-postgres-tables &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/design-postgres-tables inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/design-postgres-tablesOr copy the folder to ~/.gemini/skills/design-postgres-tables yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/design-postgres-tables:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/design-postgres-tables &&
cp -R "$tmp/skills/design-postgres-tables" ~/.copilot/skills/design-postgres-tables &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/design-postgres-tables inside it instead.
Get the folder:
git clone --depth 1 https://github.com/timescale/pg-aiguide.gitThen copy pg-aiguide/skills/design-postgres-tables into your agent's skills folder as design-postgres-tables. Agents that support SKILL.md read one folder per skill.
What it does
- Column type selection
- Recommends PostgreSQL data types for IDs, money, timestamps, text, floats and booleans, and lists types to avoid.
- Constraint guidance
- Explains primary keys, foreign key actions, unique handling of NULLs, CHECK and exclusion constraints.
- Index strategy
- Covers composite, partial, covering, expression and GIN, GiST and BRIN indexes for real query paths.
- JSONB modeling
- Describes when to use JSONB, GIN and jsonb_path_ops indexing, and extracting hot fields into generated columns.
- Partitioning options
- Outlines range, list and hash partitioning and the limits on unique constraints and foreign keys.
- Write-heavy table patterns
- Gives advice for update-heavy, insert-heavy and upsert-friendly tables, including fillfactor and HOT updates.
- Safe schema changes
- Notes on transactional DDL, concurrent index builds and avoiding table rewrites when adding columns.
Good for
- Design a schema for a new orders and customers database
- Choose data types and constraints for a money or timestamp column
- Add indexes for foreign keys and frequent filters on an existing table
- Model optional attributes with a JSONB column and a GIN index
- Plan partitioning for a very large time-series table
- Tune a high-update table to reduce bloat
Design postgres tables FAQ
Does Design postgres tables run any scripts or change my database?
No. The skill ships only a SKILL.md with guidance and SQL examples and no scripts, so it informs the agent's table design rather than executing anything.
Which PostgreSQL versions does Design postgres tables assume?
It mentions features from PG15 and PG18, such as NULLS NOT DISTINCT and uuidv7 for PG18+ and gen_random_uuid for older versions, so the agent must pick the right options for the server version in use.
When does the skill apply?
It applies when a user asks to design or modify PostgreSQL tables, schemas or data models, choose types, constraints or indexes, or design JSONB or OLTP-style tables.
How do I install Design postgres tables in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/design-postgres-tables to use it in all your projects, or to .claude/skills/design-postgres-tables in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.
Does Design postgres tables run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Design postgres tables?
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.
What are the best alternatives to Design postgres tables?
The closest alternatives to Design postgres tables are Postgres, Design postgis tables, PostgreSQL optimization, Postgres database migration and Database migrations.
Where this comes from
- Description: from the skill's own SKILL.md.
More from timescale/pg-aiguide

Guides an agent in designing PostGIS spatial tables, types, SRIDs and indexes
- Open source
- 1.9K GitHub stars
- Databases

Scores existing PostgreSQL tables to find which should become TimescaleDB hypertables
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through converting PostgreSQL tables into TimescaleDB hypertables safely
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through pgvector setup, HNSW indexing and tuning for semantic search
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through PostgreSQL schema design, indexing, search, TimescaleDB
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through planning, testing and running PostgreSQL schema migrations safely
- Open source
- 1.9K GitHub stars
- Databases


