postgresql

postgresql is a skill for Claude Code, Codex from iliaal/ai-skills. It costs 48 tokens per session (4,321 once invoked), scanned A, original, MIT.

A set of practical rules for designing, querying, optimizing, and administering PostgreSQL databases. PostgreSQL is a database system that supports structured data, advanced queries, and features such as JSON documents and row-level security.

In plain words
What is it for?
Use it when creating PostgreSQL tables and relationships, choosing data types, adding constraints and indexes, working with JSONB or partitions, or investigating slow queries with EXPLAIN ANALYZE.
Why use it?
It helps avoid common database design mistakes and provides guidance for making queries and indexes work well as data grows.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when creating PostgreSQL tables and relationships, choosing data types, adding constraints and indexes, working with JSONB or partitions, or investigating slow queries with EXPLAIN ANALYZE.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/iliaal/ai-skills/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/ai-skills --skill postgresql
Clone the repo
git clone --depth 1 https://github.com/iliaal/ai-skills

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 postgresql

README.md
[![agentmods](https://agentmods.dev/badge/skills/iliaal/ai-skills/postgresql.svg)](https://agentmods.dev/skills/iliaal/ai-skills/postgresql)
Your own site
<a href="https://agentmods.dev/skills/iliaal/ai-skills/postgresql"><img src="https://agentmods.dev/badge/skills/iliaal/ai-skills/postgresql.svg" alt="Measured on agentmods" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,321 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00048 $0.04321
Opus 5 $0.00024 $0.02160
Sonnet 5 $0.00010 $0.00864
Haiku 4.5 $0.00005 $0.00432

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

Security

Grade A, and why

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.

skills/postgresql/SKILL.md · 250 lines

How it starts

The opening of the file, as written. The whole thing — 250 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

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
  • 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.
  • Revoke default public schema access: REVOKE ALL ON SCHEMA public FROM public

Read the full file on GitHub · 250 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 Changed · +2 lines c619d44cdec8
  2. 8d ago First seen · 248 lines · 48 tokens per session scan A 28cc317b68f0

Subscribe to this mod's changes

postgresql is a skill published in the GitHub repository iliaal/ai-skills (41 stars, last pushed yesterday), licensed MIT. It adds 48 tokens to every session and 4,321 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-30.

Related

Other skills, from other repositories

postgresql-table-design

Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features.

chidekina/aria-superpowers · 31 tokens

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

cloud-sql-basics

This file generates or explains Cloud SQL resources. Use this file when the user asks to create a Cloud SQL instance or database for MySQL, PostgreSQL, or SQL Server. Cloud SQL manages third-party MySQL, PostgreSQL, and SQL Server instances as resources in Cloud SQL. For example, when Cloud SQL creates an open-source…

google/skills · 108 tokens

supabase

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies…

supabase/agent-skills · 185 tokens

supabase-postgres-best-practices

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the…

supabase/agent-skills · 182 tokens

sql-optimizer

Analyzes SQL queries for missing indexes, N+1 patterns, suboptimal joins, and full table scans. Interprets EXPLAIN, detects anti-patterns, rewrites queries. Triggers on: "optimize this query", "slow query", "add indexes", "explain plan", "N+1 query", "why is this query slow".

Mathews-Tom/armory · 78 tokens