ia-postgresql

ia-postgresql is a skill for Claude Code from iliaal/whetstone. It costs 49 tokens per session (5,945 once invoked), scanned A, original, MIT.

A guide to designing, tuning, and administering PostgreSQL databases. PostgreSQL is a relational database system that stores structured data and supports advanced queries.

In plain words
What is it for?
Use it for schemas, indexes, query optimization, JSONB data, table partitioning, row-level security, common table expressions, window functions, and EXPLAIN ANALYZE.
Why use it?
It helps prevent poor table designs and slow queries, while making database behavior easier to inspect and maintain.

Skill for Claude Code

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

Part of the whetstone plugin — 32 skills, 22 commands, 19 agents, 1 hook, 1 MCP server shipped together

Good fit Use it for schemas, indexes, query optimization, JSONB data, table partitioning, row-level security, common table expressions, window functions, and EXPLAIN ANALYZE.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/iliaal/whetstone/ia-postgresql
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.

Any agent
npx skills add iliaal/whetstone --skill ia-postgresql
Clone the repo
git clone --depth 1 https://github.com/iliaal/whetstone

Made for: Claude Code.

Or install whetstone, the plugin that ships this one along with the rest of its 32 skills, 22 commands, 19 agents, 1 hook, 1 MCP server.

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 ia-postgresql

README.md
[![agentmods](https://agentmods.dev/badge/skills/iliaal/whetstone/ia-postgresql.svg)](https://agentmods.dev/skills/iliaal/whetstone/ia-postgresql)
Your own site
<a href="https://agentmods.dev/skills/iliaal/whetstone/ia-postgresql"><img src="https://agentmods.dev/badge/skills/iliaal/whetstone/ia-postgresql.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,945 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00049 $0.05945
Opus 5 $0.00024 $0.02972
Sonnet 5 $0.00010 $0.01189
Haiku 4.5 $0.00005 $0.00594

Measured today against content hash 598a833bebfc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

ia-postgresql 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 today.

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.

plugins/whetstone/skills/ia-postgresql/SKILL.md · 267 lines

How it starts

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

PostgreSQL

Data Type Defaults

Need Use Avoid
Primary key BIGINT GENERATED ALWAYS AS IDENTITY SERIAL, BIGSERIAL
Timestamps TIMESTAMPTZ TIMESTAMP (loses timezone)
Text TEXT VARCHAR(n) unless constraint needed
Money NUMERIC(precision, scale) MONEY, FLOAT
Boolean BOOLEAN with NOT NULL DEFAULT nullable booleans
JSON JSONB JSON (no indexing), text JSON
UUID gen_random_uuid() (PG13+) uuid-ossp extension
IP addresses INET / CIDR text
Ranges TSTZRANGE, INT4RANGE, etc. pair of columns
Raw bytes (verbatim payload) BYTEA JSONB, TEXT -- both re-encode

A spec that says "log the raw response" is asking for byte fidelity, and no text type provides it. JSONB reparses: it drops insignificant whitespace, sorts object keys, keeps only the last of duplicate keys, and rewrites numbers out of exponent notation (1e0 -> 1; trailing zeros in 1.00 do survive, so "all numeric forms collapse" overstates it). A non-JSON body cannot be stored at all and usually lands as NULL. TEXT rejects a NUL byte and any sequence invalid in the database encoding, so a binary or mis-encoded body errors instead of storing. Persist the bytes in BYTEA with the content type beside them, and add a parsed JSONB column separately when queries need one -- reading the column type as proof the body is kept is the review error.

Schema Rules

  • Every FK column gets an index (PG does NOT auto-create these)
  • NOT NULL on every column unless NULL has business meaning
  • CHECK constraints for domain rules at DB level
  • EXCLUDE constraints for range overlaps: EXCLUDE USING gist (room WITH =, during WITH &&)
  • Default created_at TIMESTAMPTZ NOT NULL DEFAULT now()
  • Separate updated_at with trigger, never trust app layer alone. Gate it with WHEN (OLD.* IS DISTINCT FROM NEW.*) so a no-op write neither fires the function nor bumps the timestamp -- on BEFORE UPDATE the row image is built before the trigger runs, so the comparison sees the caller's row, not the one the trigger is about to stamp.
  • Use BIGINT PKs -- cheaper JOINs than UUID, better index locality
  • Safe migrations: CREATE INDEX CONCURRENTLY, add columns with a non-volatile DEFAULT (instant add). Never ALTER TYPE on large tables in-place.
  • A DEFAULT whose expression is VOLATILE rewrites the entire table under ACCESS EXCLUSIVE; only IMMUTABLE/STABLE defaults get the metadata-only fast path. Check before shipping the migration: SELECT provolatile FROM pg_proc WHERE proname = 'gen_random_uuid'; -- v is volatile, s/i are not. So DEFAULT 7 and DEFAULT now() are instant, DEFAULT gen_random_uuid() is a full rewrite; add the column nullable, backfill in batches, then set the default.
  • NULLS NOT DISTINCT on unique indexes (PG15+) -- treats NULLs as equal for uniqueness
  • A UNIQUE constraint proves at most one row per key, never exactly one. The lower bound has to come from elsewhere -- a NOT NULL FK from the covered side, a CHECK, or a seeding invariant -- so any docblock, MR description, or review conclusion of the form "the index is unique, therefore every X has exactly one Y" is unsound until that other source is named. The tell is the word exactly, or a downstream promise phrased as a universal. One query settles it: enumerate the domain and count the members with zero rows.
  • Under NULLS NOT DISTINCT, a pre-flight duplicate check written with SQL = misses NULL/NULL collisions -- the index rejects the second row, but NULL = NULL evaluates to NULL (not true), so a self-join or WHERE a.col = b.col probe silently skips exactly the pairs the index will reject. Write the probe with IS NOT DISTINCT FROM so NULL/NULL compares as equal.
  • ORDER BY col DESC puts NULLs FIRST (ASC puts them last), so a "keep the newest row" dedup written ORDER BY updated_at DESC picks the row whose timestamp is NULL. ORM timestamps() helpers typically create created_at/updated_at as nullable, so the exposure is routine rather than exotic. Pin the order (ORDER BY updated_at DESC NULLS LAST, id DESC) or make the column NOT NULL. MySQL's DESC default is the opposite (NULLS LAST), so a query ported between the two silently changes which row survives.
  • Revoke default public schema access: REVOKE ALL ON SCHEMA public FROM public
  • Derive every attribute at its own grain. A property of the parent -- a session, a day, an order -- computed from one child row lands on every child and is legitimately partial for most of them, so the aggregate disagrees with itself depending on which child is read. Put parent-scoped facts in a table keyed at the parent grain, populate them from the child the parent designates, and prefer a boundary observation (the last event's timestamp) over a count threshold.

Read the full file on GitHub · 267 lines

Files

What ships with it

5 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. today First seen · 267 lines · 49 tokens per session scan A 598a833bebfc

Subscribe to this mod's changes

ia-postgresql is a skill published in the GitHub repository iliaal/whetstone (33 stars, last pushed yesterday), licensed MIT. It adds 49 tokens to every session and 5,945 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-09-07.