/ct:postgresfrom ct
Provides deep PostgreSQL operational guidance for MVCC, autovacuum, WAL/checkpoints, replication, PgBouncer, deadlock diagnosis, and pg_stat_statements triage. Loads when tuning or diagnosing incidents, not for query writing.
Ships in ct. 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.
None: SKILL.md is the whole skill.
Concise operational pointers for deep Postgres troubleshooting and tuning.
Assumes you already know SQL, basic indexing, and how to read an EXPLAIN ANALYZE. This skill covers the operational layer — the parts models tend to gloss over: MVCC internals, vacuum behavior, WAL, replication, pooling.
Load when the question is about:
Do NOT load for: writing SELECTs, schema design, index-type choice, typical EXPLAIN ANALYZE review, JOIN optimization — those don't need this skill.
pg_stat_user_tables.n_dead_tup and last_autovacuum. Long transactions hold the cleanup horizon — find via SELECT * FROM pg_stat_activity WHERE backend_xmin IS NOT NULL and consider idle_in_transaction_session_timeout.threshold = autovacuum_vacuum_threshold + autovacuum_vacuum_scale_factor × reltuples. Default scale_factor = 0.2 is too lazy for big tables — set per-table: ALTER TABLE x SET (autovacuum_vacuum_scale_factor = 0.02, autovacuum_vacuum_threshold = 10000).age(datfrozenxid) vs autovacuum_freeze_max_age (default 200M). Near vacuum_failsafe_age (1.6B) Postgres enters single-user mode. SELECT datname, age(datfrozenxid) FROM pg_database ORDER BY 2 DESC.max_wal_size high enough that time-based checkpoints (checkpoint_timeout) fire before size-based ones. Observe via log_checkpoints = on.SELECT slot_name, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained FROM pg_replication_slots ORDER BY 3 DESC. Drop abandoned slots.full_page_writes: do not disable unless the filesystem guarantees atomic writes at page size. Risk is torn pages on crash.archive_command failures silently fill pg_wal. Monitor with pg_stat_archiver and the last_failed_wal / last_failed_time columns.pg_stat_replication.{write_lag, flush_lag, replay_lag}. Which lag is growing tells you where (network → write_lag; disk-sync → flush_lag; replay apply → replay_lag). All three equal → network bandwidth.pg_replication_slots.confirmed_flush_lsn and pg_stat_subscription. If the consumer stops, the slot retains WAL until disk fills — monitor retained size and set an upper-bound alert.synchronous_commit = on + synchronous_standby_names. A standby going offline with on blocks writes. If availability > durability, use remote_write or local.pg_promote(); stop writes on the old primary before repointing traffic, or you'll split-brain.server_reset_query = DISCARD ALL or PgBouncer 1.21+ with max_prepared_statements > 0SET LOCAL persisting across transactionsLISTEN/NOTIFYdefault_pool_size ≈ cores × 2 + effective_spindles per (db, user). Larger pools cause tail-latency spikes, not throughput gains.max_client_conn: bounded by OS file descriptors — raise ulimit -n and pgbouncer.ini together. 10k+ client connections is normal.query_timeout, query_wait_timeout. Use to avoid a single slow query pinning a backend.log_lock_waits = on, deadlock_timeout = '1s'. Deadlock reports include both query texts and the lock cycle.ORDER BY id before SELECT FOR UPDATE).SELECT * FROM pg_stat_activity WHERE wait_event_type = 'Lock' joined with pg_locks on pid.pg_stat_statements is the single most useful extension for diagnosis.
Enable with shared_preload_libraries = 'pg_stat_statements', pg_stat_statements.track = 'all', restart required.
Top time-consumers:
SELECT query, calls, total_exec_time::int AS total_ms,
mean_exec_time::int AS mean_ms, rows
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 20;
Cache hit ratio (target ≥ 0.99 for OLTP):
SELECT sum(blks_hit)::float / nullif(sum(blks_hit + blks_read), 0)
FROM pg_stat_database;
Buffer cache sampling:
CREATE EXTENSION pg_buffercache;
SELECT c.relname, count(*) AS buffers
FROM pg_buffercache b JOIN pg_class c ON b.relfilenode = pg_relation_filenode(c.oid)
GROUP BY 1 ORDER BY 2 DESC LIMIT 10;
shared_buffers: 25 % of RAM; diminishing returns beyond ~8-16 GB. OS page cache handles the rest.work_mem: per-operation, not per-query. Worst case: max_connections × per-query-operators × work_mem. Too high → OOM.effective_cache_size: 50-75 % of RAM. Planner hint only, not allocated.maintenance_work_mem: 256 MB - 1 GB for index build / vacuum speed.pg_class.reltoastrelid and pg_relation_size(reltoastrelid).UPDATEs to reserve HOT-update slots and reduce index churn.Official Postgres docs (postgresql.org/docs/current):
PgBouncer: pgbouncer.org/config.html
Community operational deep-dives (reliable authors):
Before recommending a non-trivial operational change (vacuum cost params, WAL params, replication config):
Tuning without measurement is worse than defaults.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
postgresql-operations, vacuum, wal, replication, connection-pooling, deadlock
38 skills in this plugin
/argocdDeep ArgoCD operational intuition — sync waves and hook lifecycle, ApplicationSet generators, Sync vs Health, drift root causes, sync options, AppProject constraints, rollback, multi-cluster. Load for sync ordering, hook design, drift diagnosis, generator selection, rollback planning, or multi-cluster registration. Skip for "what is GitOps", install walkthroughs, or basic Application YAML. Triggers on: "sync wave", "presync hook", "syncfail", "applicationset generator", "matrix generator", "hpa replicas drift", "ignoreDifferences", "ServerSideApply", "Replace=true", "self-heal", "app-of-apps cascade".
/audit-skillsAudit installed skills for redundancy with built-in model knowledge. Use when asked to "audit skills", "review my skills", "check skill redundancy", "which skills are useful", "clean up skills", or "are my skills teaching you anything new"./bash-hardeningDeep bash correctness — `set -euo pipefail` traps, IFS/word-splitting, trap inheritance, process substitution, array gotchas, version-gated features, ShellCheck "looks right but isn't" patterns. Load when writing or hardening non-trivial bash scripts (installers, CI, unattended ops). Skip for basic if/while/for, one-shot interactive commands, or zsh/fish/POSIX-sh work. Triggers on: "set -e not triggering", "pipefail", "trap ERR", "PIPESTATUS", "macOS bash 3.2", "shellcheck SC2086", "harden bash script", "robust bash".
/bugmagnetDiscover edge cases and test coverage gaps through systematic analysis. Use when analysing TEST coverage, hunting for edge cases, or when code-reviewer identifies test gaps. Triggers on "find holes in my tests", "what could go wrong", "is this well tested", "what edge cases am I missing". When to pick bugmagnet vs alternatives: - find-bugs → branch-diff bug scan (uses git diff, scoped to recent changes) - security-review → OWASP-categorised vulnerability audit - code-review → PR-style review with comment threads - ct:bugmagnet → test-gap edge-case discovery (THIS one) If the question is "are my TESTS missing cases?", use bugmagnet. Otherwise pick one of the three above.
/ci-failure-triageDiagnose a failing GitHub Actions run. Fetch the failing job's step logs, correlate with recent commits, and produce a ranked top-3 root-cause hypothesis plus a minimal fix proposal. Use when the user says "CI is failing", "why did the build break", "triage this GHA failure", "workflow failed", "what broke CI", or pastes a `gh run` URL / run ID. Read-only — does NOT apply fixes, restart the run, or tail logs. For workflow-file security audits use gha-security-review; for local test failures use fix-loop.
/c-languageDeep C operational intuition — undefined behavior, sanitizers (ASan/UBSan/TSan/MSan), hardening flags, atomics/memory ordering, fuzzing, ABI quirks. Load when diagnosing UB, configuring sanitizers or hardened builds, investigating data races, or debugging alignment/atomics. Skip for ordinary C coding, malloc/free, or syntax help. Triggers on: "undefined behavior", "strict aliasing", "AddressSanitizer", "UBSan", "Valgrind", "use-after-free", "_FORTIFY_SOURCE", "memory_order", "libFuzzer", "ABI".
npx claudepluginhub pvillega/claude-templates --plugin ctOther plugins' skills for the same job