designing-postgres-schemas

designing-postgres-schemas is a skill for Claude Code from pumarogie/claude-postgres-skills. It costs 45 tokens per session (907 once invoked), scanned A, original, MIT.

A guide to designing PostgreSQL database structures, including tables, keys, data types, relationships, flexible fields, and data retention.

In plain words
What is it for?
Use it when creating schemas, choosing identifiers and time types, defining foreign keys, deciding between columns and JSONB, or planning indexes, partitioning, and retention.
Why use it?
It helps keep stored data correct, queries usable, and growing event or log tables manageable.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the database-skill plugin — 6 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/pumarogie/claude-postgres-skills/designing-postgres-schemas
Any agent
npx skills add pumarogie/claude-postgres-skills --skill designing-postgres-schemas
Clone the repo
git clone --depth 1 https://github.com/pumarogie/claude-postgres-skills

Made for: Claude Code.

Or install database-skill, the plugin that ships this one along with the rest of its 6 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for designing-postgres-schemas

README.md
[![agentmods](https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/designing-postgres-schemas.svg)](https://agentmods.dev/skills/pumarogie/claude-postgres-skills/designing-postgres-schemas)
Your own site
<a href="https://agentmods.dev/skills/pumarogie/claude-postgres-skills/designing-postgres-schemas"><img src="https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/designing-postgres-schemas.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 907 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.00907
Opus 5 $0.00023 $0.00453
Sonnet 5 $0.00009 $0.00181
Haiku 4.5 $0.00005 $0.00091

Measured 5d ago against content hash 518e5f42b568, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

designing-postgres-schemas scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/designing-postgres-schemas/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Designing Postgres Schemas

Overview

Design from invariants and real access paths. Put correctness in types, constraints, and keys; add indexes for actual reads and writes. Make growth and retention explicit before deployment.

Quick Reference

Decision Starting point Check before committing
Primary key bigint identity or uuid Generation location, exposure, index locality
Time instant timestamptz Display zone belongs at the application boundary
Local civil time timestamp plus explicit zone/rules Use only when the value is intentionally not an instant
Relationship Foreign key Index the referencing columns used for joins/deletes
Flexible attributes jsonb Promote constrained, filtered, or joined fields to columns
Unbounded events/logs Time-based retention plan Consider partitioning before the table becomes large

Use timestamptz for an instant. It normalizes an instant and displays it in the session time zone; it does not retain the input's zone name or original offset. If the originating IANA zone matters to product behavior, store it separately (for example, origin_tz text). Use timestamp only for an intentional wall-clock value; otherwise differently configured clients can silently interpret the same zone-less value as different instants.

Baseline pattern

CREATE TABLE tasks (
    id          bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    tenant_id   uuid NOT NULL,
    status      text NOT NULL CHECK (status IN ('pending', 'running', 'done')),
    payload     jsonb,
    created_at  timestamptz NOT NULL DEFAULT now(),
    updated_at  timestamptz NOT NULL DEFAULT now()
);

Give every table a stable key unless a documented reason forbids it. Use GENERATED BY DEFAULT only when callers must supply identity values.

Design from operations

For each table, write down:

  • uniqueness and validity rules to enforce;
  • hot filters, joins, ordering, and update paths;
  • row count, write rate, and retention;
  • deletion behavior and the maximum cascade fan-out;
  • which fields change often and will create dead tuples;
  • tenant or ownership boundaries.

Read the full file on GitHub · 73 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 73 lines · 45 tokens per session scan A 518e5f42b568

Subscribe to this mod's changes

designing-postgres-schemas is a skill published in the GitHub repository pumarogie/claude-postgres-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 45 tokens to every session and 907 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

database-optimizer

Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.

Jeffallan/claude-skills · 54 tokens

postgres-pro

Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.

Jeffallan/claude-skills · 41 tokens

postgres-database-migration

Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…

timescale/pg-aiguide · 220 tokens

design-postgis-tables

Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.

timescale/pg-aiguide · 31 tokens

migrate-postgres-tables-to-hypertables

Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. Trigger when user asks to: Migrate or convert PostgreSQL tables to hypertables Execute hypertable migration with minimal downtime Plan blue-green migration for large tables Validate…

timescale/pg-aiguide · 181 tokens

pgvector-semantic-search

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. Trigger when user asks to: Store or search vector embeddings in PostgreSQL Set up semantic search, similarity search, or nearest neighbor search Create HNSW or IVFFlat indexes for vectors…

timescale/pg-aiguide · 190 tokens