Skip to content
davila7 avatar

Postgres Schema Design

Opinionated PostgreSQL table design reference covering data types, constraints, indexing, and gotchas for schema work.

CCM score
63 of 100
skills.sh installs
252
GitHub stars
34.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers core schema rules, PostgreSQL-specific gotchas, data type selection, table types, row-level security, and constraint design
  • Lists preferred and forbidden types, such as TIMESTAMPTZ over TIMESTAMP, TEXT over CHAR(n) and VARCHAR(n), and identity columns over SERIAL
  • Flags pitfalls like unindexed foreign keys, UNIQUE allowing multiple NULLs, and sequence gaps that are expected rather than bugs
  • Designed for developers writing or reviewing PostgreSQL DDL where type choice, normalization, and indexing decisions need to be checked

Install

$ npx -y skills add davila7/claude-code-templates --skill postgres-schema-design -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

PostgreSQL Table Design

Core Rules

  • Define a PRIMARY KEY for reference tables (users, orders, etc.). Not always needed for time-series/event/log data. When used, prefer BIGINT GENERATED ALWAYS AS IDENTITY; use UUID only when global uniqueness/opacity is needed.
  • Normalize first (to 3NF) to eliminate data redundancy and update anomalies; denormalize only for measured, high-ROI reads where join performance is proven problematic. Premature denormalization creates maintenance burden.
  • Add NOT NULL everywhere it’s semantically required; use DEFAULTs for common values.
  • Create indexes for access paths you actually query: PK/unique (auto), FK columns (manual!), frequent filters/sorts, and join keys.
  • Prefer TIMESTAMPTZ for event time; NUMERIC for money; TEXT for strings; BIGINT for integer values, DOUBLE PRECISION for floats (or NUMERIC for exact decimal arithmetic).

PostgreSQL “Gotchas”

Details

Repository
github.com/davila7/claude-code-templates
Category
Databases
First seen
Jun 3, 2026

Questions

What is the postgres-schema-design skill for?

postgres-schema-design is a PostgreSQL table design reference covering data types, indexing, constraints, performance patterns and advanced features. It guides an agent when it designs or reviews Postgres tables, so the schema follows its rules for keys, NULL handling and type choices.

How do I install postgres-schema-design?

Run npx -y skills add davila7/claude-code-templates --skill postgres-schema-design -y in a project to install it. After that, postgres-schema-design gives the agent its Postgres table design rules for that project.

Which data types does postgres-schema-design recommend?

postgres-schema-design prefers BIGINT GENERATED ALWAYS AS IDENTITY for keys, TIMESTAMPTZ for event times, NUMERIC for money and TEXT for strings. It also tells the agent to avoid types such as timestamp without time zone, varchar(n), money and serial.

Does postgres-schema-design need an API key or a database connection?

postgres-schema-design is a reference document that the agent reads while it works, so its own page lists no keys or accounts. The agent still needs a PostgreSQL database of its own to run the schemas it writes.

More from davila7/claude-code-templates

All 398

Similar to Postgres Schema Design

More Databases