postgresdb

postgresdb is a skill for Claude Code, Codex from ericrisco/rsc-harness. It costs 91 tokens per session (4,619 once invoked), scanned A, original, MIT.

A PostgreSQL database guide for designing schemas, choosing indexes, investigating slow queries, running migrations, and handling database operations and security.

In plain words
What is it for?
Use it for PostgreSQL schema design, index selection, EXPLAIN-based query tuning, zero-downtime changes, roles, row-level security, connection pooling, vacuuming, partitioning, and backups.
Why use it?
It helps developers make decisions specific to PostgreSQL instead of relying on advice that may only apply to other databases or tools.

Skill for Claude CodeCodex

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/ericrisco/rsc-harness/postgresdb
Any agent
npx skills add ericrisco/rsc-harness --skill postgresdb
Clone the repo
git clone --depth 1 https://github.com/ericrisco/rsc-harness

Made for: Claude Code, Codex.

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 postgresdb

README.md
[![agentmods](https://agentmods.dev/badge/skills/ericrisco/rsc-harness/postgresdb.svg)](https://agentmods.dev/skills/ericrisco/rsc-harness/postgresdb)
Your own site
<a href="https://agentmods.dev/skills/ericrisco/rsc-harness/postgresdb"><img src="https://agentmods.dev/badge/skills/ericrisco/rsc-harness/postgresdb.svg" alt="Measured on agentmods" height="20"></a>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,619 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 $0.00091 $0.04619
Opus 5 $0.00046 $0.02309
Sonnet 5 $0.00018 $0.00924
Haiku 4.5 $0.00009 $0.00462

Measured yesterday against content hash 658617169f2b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

postgresdb 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 yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/verify.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/postgresdb/SKILL.md · 355 lines

How it starts

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

PostgreSQL — schema, indexing, queries, ops

Engine-level PostgreSQL 16 guidance: design correct schemas, pick the right index, read EXPLAIN and fix slow SQL, run zero-downtime migrations, and operate/secure the database. Tooling-agnostic; every example is runnable.

New, non-trivial feature with no approved spec + plan under 02-DOCS/wiki/sdd/? Hand off to specify before writing feature code (method: sdd); build straight from here only for a genuinely one-line, low-risk change.

Deep dives: schema-and-indexing (types, constraints, every index kind, bloat) · query-optimization (EXPLAIN, joins, concurrency, JSONB/FTS/pgvector) · migrations (zero-downtime DDL, per-ORM) · operations-and-security (roles, RLS, pooling, vacuum, partitioning, backups).

Not this skill. ORM-API ergonomics (Prisma updateMany count trap, SQLAlchemy session lifecycle) and per-runner migration wiring → that tool's own docs; this skill owns the SQL the ORM emits and the engine behavior underneath. Other engines → mysql, sqlite-turso, clickhouse-analytics (different MVCC, locking, planner). App-layer caching / Redis / Kafka as products are out — only Postgres-as-queue via SKIP LOCKED is in scope. Cloud-vendor console clicks → deployment; we give the SQL and params, not the RDS/Cloud SQL UI path.

Decision rules

Fast lookups; runnable DDL lives in the references.

Pick the column type

Use case Correct type Avoid Why
Surrogate PK (internal) bigint GENERATED ALWAYS AS IDENTITY serial, int identity is SQL-standard, no sequence-ownership gotchas; bigint avoids 2.1B overflow
Surrogate PK (public/distributed) uuid v7 uuid v4 v7 is time-ordered → less B-tree fragmentation than random v4
Natural text id (slug, sku) text + UNIQUE + CHECK varchar(n) length via CHECK; no rewrite to widen later
Money / exact decimal numeric(19,4) float8, money binary floats drift; money has locale issues
Timestamp (event) timestamptz timestamp stores a UTC instant; naive timestamp loses zone
Duration interval int seconds self-documenting, arithmetic-safe
Small closed set, stable enum text w/o CHECK type safety; but see lookup-table note
Evolving set, joinable lookup table + FK enum ALTER TYPE ... ADD VALUE is awkward; FK gives joins + soft-retire
Flag boolean int, varchar three-valued NULL still possible — add NOT NULL DEFAULT
Tags (read-mostly) text[] + GIN comma string array ops + GIN containment
Tags (relational) join table text[] when you need FK integrity / per-tag rows
Semi-structured jsonb json, text binary, indexable, dedup keys; promote hot keys to columns
IP / CIDR inet / cidr text validation + operators
Time range (booking) tstzrange + GiST two columns && overlap + exclusion constraint

Read the full file on GitHub · 355 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday First seen · 355 lines · 91 tokens per session scan A 658617169f2b

Subscribe to this mod's changes

postgresdb is a skill published in the GitHub repository ericrisco/rsc-harness (64 stars, last pushed 2d ago), licensed MIT. It adds 91 tokens to every session and 4,619 once invoked, about $0.0005 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-09-03.