# postgresql

Guides table schema design for PostgreSQL, emphasizing strict data types, indexing for foreign keys, and engine-specific storage nuances.

- skill · `type=skill` · Claude Code · 312 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/database/postgresql
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/postgresql

## What it does

This skill guides PostgreSQL schema modeling from first principles. It enforces third normal form before any read-oriented denormalization. For primary keys, it favors `BIGINT GENERATED ALWAYS AS IDENTITY`. It points users toward `NUMERIC` for currency, `TIMESTAMPTZ` for timestamps, and standard `TEXT` with length constraints instead of `VARCHAR(n)`.

It highlights practical engine traps. PostgreSQL skips automatic index creation on foreign key columns, so you must add them manually. The guide details how `UNIQUE` treats `NULL` values, covers gaps in sequence counters, and explains heap storage behavior where row order mirrors insertion time. It also covers structured types like `JSONB`, arrays, ranges, and `pgvector` embeddings.

This skill does not apply to non-Postgres engines or query tuning that avoids schema modifications. Destructive production DDL requires verified rollbacks and staging migrations first.

## Requirements
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill database/postgresql
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill postgresql -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/postgresql/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/postgresql/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/postgresql/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/postgresql/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates postgresql
```

2. **Manually: put the files in place**
- File: `.github/skills/postgresql/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/database/postgresql
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/postgresql/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/database/postgresql

## When to use it
- model normalized PostgreSQL schemas up to 3NF
- place manual indexes on foreign key columns
- select strict data types like `timestamptz` and `numeric`
- define storage and GIN indexes for `jsonb` and arrays

## Example prompts
- Design an e-commerce schema in PostgreSQL with orders, items, and customers
- Review this migration script and verify whether my foreign key columns need indexes
- Recommend the right Postgres data types and constraints for handling date ranges

## Similar
- [xlsx](https://affpapa.org/en/nevibecode/skills/xlsx.md) — skill · 187223 installs
- [google-agents-cli-observability](https://affpapa.org/en/nevibecode/skills/google-agents-cli-observability.md) — skill · 511300 installs
- [caveman-evidence-review](https://affpapa.org/en/nevibecode/skills/caveman-evidence-review.md) — skill · 104500 installs
- [migration](https://affpapa.org/en/nevibecode/skills/migration.md) — skill · 103900 installs
- [performance-optimization](https://affpapa.org/en/nevibecode/skills/performance-optimization.md) — skill · 65200 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/supabase.md) — skill · 8 installs

## Other versions with the same name
- [postgresql · bagelhole](https://affpapa.org/en/nevibecode/skills/devops-skills-postgresql.md) — 419 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 804 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
