/ai-stuff:postgres-autovacuumfrom ai-stuff
Diagnose and tune PostgreSQL vacuum and autovacuum: dead tuples that won't go away, table and index bloat, autovacuum that can't keep up, per-table settings, insert-only tables, transaction ID and multixact wraparound warnings, long transactions or replication slots holding back cleanup, and online bloat removal (REINDEX CONCURRENTLY, pg_repack, pg_squeeze, REPACK). Use when a Postgres table or index keeps growing, vacuum is slow or blocked, XID age alerts fire, or you are setting autovacuum parameters.
Ships in ai-stuff. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A playbook distilled from Scaling Postgres. Evidence, numbers and version
history are in reference.md. To design tables that bloat less
in the first place, use postgres-schema-design.
Is something holding the xmin horizon? If it is, no tuning helps. A VACUUM VERBOSE line like "dead but not yet removable" means exactly this.
-- oldest open transactions
SELECT pid, state, now() - xact_start AS age, query
FROM pg_stat_activity WHERE xact_start IS NOT NULL ORDER BY xact_start LIMIT 10;
-- replication slots (inactive ones pin xmin and WAL)
SELECT slot_name, active, xmin, catalog_xmin FROM pg_replication_slots;
-- forgotten two-phase transactions
SELECT gid, prepared FROM pg_prepared_xacts;
Also check standbys running with hot_standby_feedback = on and long
queries.
Is autovacuum reaching the table? Compare n_dead_tup,
last_autovacuum, and autovacuum_count in pg_stat_user_tables. Watch
running work in pg_stat_progress_vacuum.
Is it keeping up once it runs? The usual bottleneck is the shared cost
budget, not the worker count. Raise autovacuum_vacuum_cost_limit first.
How close is wraparound?
SELECT datname, age(datfrozenxid), mxid_age(datminmxid) FROM pg_database ORDER BY 2 DESC;
SELECT c.oid::regclass, age(c.relfrozenxid)
FROM pg_class c WHERE c.relkind IN ('r','m','t') ORDER BY 2 DESC LIMIT 20;
How much bloat is there really? Estimates are rough. Use pgstattuple
for tables and pgstatindex (avg_leaf_density) for indexes before acting.
autovacuum_vacuum_cost_limit (into the thousands on fast storage)
before adding workers. Workers share the budget.autovacuum_vacuum_scale_factor from 20% to
about 1–2%, per table with ALTER TABLE ... SET (...).autovacuum_analyze_scale_factor.autovacuum_vacuum_insert_threshold /
insert_scale_factor. They keep the visibility map fresh for index-only
scans, and freeze tables early.maintenance_work_mem / autovacuum_work_mem so it
needs fewer index passes. PG17 removed the old 1 GB effective cap.ANALYZE parent
yourself after loads and after upgrades.idle_in_transaction_session_timeout, and transaction_timeout (PG17).max_slot_wal_keep_size for slots.| Target | Tool | Notes |
|---|---|---|
| Index | REINDEX CONCURRENTLY | Default fix. Vacuum never shrinks indexes. |
| Table, online | pg_repack, pg_squeeze | Needs about 2x space, takes brief exclusive locks, try on small tables first. |
| Table, online (PG19) | REPACK ... CONCURRENTLY | One final lock attempt, one at a time, the slot holds back vacuum. |
| Table, whole cluster | Logical-replication cutover | Rebuilds everything compactly. |
| Table, offline | VACUUM FULL / CLUSTER | ACCESS EXCLUSIVE for the whole run. Only in a maintenance window. |
VACUUM (FREEZE, VERBOSE) on the oldest tables,
starting with the oldest relfrozenxid.vacuum_truncate = off on
affected tables.hot_standby_feedback = on stops those cancellations but moves bloat back
onto the primary.What SKILL.md sets; muted values are Claude Code's defaults
25 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./dispatching-parallel-agentsUse ONLY when the developer has explicitly told you to dispatch subagents — never infer or self-authorize it. Splits 2+ independent tasks across isolated subagents, assigns them cheap models, and polls at a per-harness cadence that preserves prompt cache (Claude Code vs Codex/opencode)./frontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults./grillingGrill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases./handoffCompact the current conversation into a handoff document for another agent to pick up.Other plugins' skills for the same job
npx claudepluginhub pauldotsh/ai-stuff --plugin ai-stuff