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.
npx skills add pumarogie/claude-postgres-skills --skill writing-safe-migrationsgit clone --depth 1 https://github.com/pumarogie/claude-postgres-skillsWrote 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.
[](https://agentmods.dev/skills/pumarogie/claude-postgres-skills/writing-safe-migrations)<a href="https://agentmods.dev/skills/pumarogie/claude-postgres-skills/writing-safe-migrations"><img src="https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/writing-safe-migrations.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00062 | $0.01571 |
| Opus 5 | $0.00031 | $0.00785 |
| Sonnet 5 | $0.00012 | $0.00314 |
| Haiku 4.5 | $0.00006 | $0.00157 |
Grade A, and why
writing-safe-migrations 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 8d 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.
How it starts
The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Writing Safe Migrations
Overview
Two questions before any migration runs against a live table:
- Does this rewrite the table? A rewrite holds
ACCESS EXCLUSIVEfor the whole rewrite — every read and write blocks. - Can it wait for its lock without taking the table down? A statement waiting for
ACCESS EXCLUSIVEqueues ahead of every query that arrives after it. One long-runningSELECTplus one unguardedALTER TABLEstalls the entire table, even for statements the migration itself would never have blocked.
Question 2 causes more outages than question 1, and lock_timeout is the whole fix.
When to Use
- Adding an index to an existing large table.
ALTER TABLE, adding or dropping columns, changing types, adding constraints.- Backfilling a column across many rows.
- Any migration on a table with meaningful traffic.
Always set a lock timeout
Never issue DDL against a live table without bounding the wait:
SET lock_timeout = '5s'; -- fail instead of building a lock queue
SET statement_timeout = '0'; -- but let a long index build finish
ALTER TABLE tasks ADD COLUMN priority int;
If the lock isn't acquired in 5s the statement errors — retry it later. That is the correct outcome: a failed migration is recoverable, a stalled table is an incident.
lock_timeout only bounds acquiring a lock, not holding one. It will not save you from a rewrite that takes ten minutes once it starts — check the lock table for that.
Find what's blocking you:
SELECT pid, pg_blocking_pids(pid), wait_event_type, left(query, 80) AS query
FROM pg_stat_activity
WHERE cardinality(pg_blocking_pids(pid)) > 0;
Quick Reference
| Operation | Danger | Safe way |
|---|---|---|
CREATE INDEX |
Blocks writes for the whole build | CREATE INDEX CONCURRENTLY, outside a transaction |
| Add check / FK constraint | Validation scan blocks writes | NOT VALID, then VALIDATE CONSTRAINT |
SET NOT NULL |
Full scan blocks reads and writes | Add an equivalent CHECK (col IS NOT NULL) NOT VALID, validate, then SET NOT NULL |
ALTER COLUMN TYPE |
Usually a full rewrite | New column + backfill + swap (expand-and-contract) |
Backfill in one UPDATE |
Long transaction, bloat, blocked autovacuum | Batch in separate transactions |
| Dropping columns | Hard to roll back | Keep migrations additive; expand-and-contract |
What ships with it
1 file 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.
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.
- 8d ago First seen · 126 lines · 62 tokens per session scan A 8379f711c69e
writing-safe-migrations is a skill published in the GitHub repository pumarogie/claude-postgres-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 62 tokens to every session and 1,571 once invoked, about $0.0003 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.
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.
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.
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…
setup-timescaledb-hypertables
Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. Trigger when user asks to: Create or design SQL schemas/tables AND…
design-postgis-tables
Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.
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…