managing-postgres-connections

managing-postgres-connections is a skill for Claude Code, Codex from pumarogie/claude-postgres-skills. It costs 48 tokens per session (955 once invoked), scanned A, original, MIT.

A guide to managing connections between applications and a PostgreSQL database, including connection pools and PgBouncer, a service that shares database connections.

In plain words
What is it for?
Use it when adding application instances, investigating connection spikes, sizing pgxpool or PgBouncer, or choosing between transaction, session, and statement pooling.
Why use it?
It helps prevent too many application connections from exhausting PostgreSQL's capacity and causing failures.

Skill for Claude CodeCodex

Part of the database-skill plugin — 6 skills shipped together

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.

agentmods
npx agentmods add skills/pumarogie/claude-postgres-skills/managing-postgres-connections
Any agent
npx skills add pumarogie/claude-postgres-skills --skill managing-postgres-connections
Clone the repo
git clone --depth 1 https://github.com/pumarogie/claude-postgres-skills

Made for: Claude Code, Codex.

Or install database-skill, the plugin that ships this one along with the rest of its 6 skills.

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 managing-postgres-connections

README.md
[![agentmods](https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/managing-postgres-connections.svg)](https://agentmods.dev/skills/pumarogie/claude-postgres-skills/managing-postgres-connections)
Your own site
<a href="https://agentmods.dev/skills/pumarogie/claude-postgres-skills/managing-postgres-connections"><img src="https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/managing-postgres-connections.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 955 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00048 $0.00955
Opus 5 $0.00024 $0.00477
Sonnet 5 $0.00010 $0.00191
Haiku 4.5 $0.00005 $0.00096

Measured 4d ago against content hash 2e3e0d4fe138, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

managing-postgres-connections 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 4d 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.

skills/managing-postgres-connections/SKILL.md · 74 lines

How it starts

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

Managing Postgres Connections

Overview

A Postgres connection is a server process with memory and scheduling cost. Bound concurrency across all application instances and preserve an operational reserve. Raising max_connections does not create capacity.

Choose the pooling layer

Prefer PgBouncer when many processes share a database: it enforces one server budget. Use an in-process pool such as Go's pgxpool when necessary, but multiply its maximum by every replica and process.

Use this mode decision for PgBouncer:

Mode Use Required warning
Transaction (default) Stateless web/request workloads A later transaction may use another backend; session state is not preserved
Session Compatible fallback for session-dependent code Idle clients retain server connections, so multiplexing is less efficient
Statement Rare, independent autocommit statements only Cannot run multi-statement transactions; unsuitable for most apps

Transaction pooling breaks assumptions about session-level prepared statements, session-level advisory locks, LISTEN/NOTIFY, session variables, cursors held across transactions, and temporary tables. Use transaction-level locks, SET LOCAL, and transaction-scoped cursors where possible; otherwise use a dedicated session-pooled or direct connection.

For pgx, never assume its implicit prepared-statement cache is compatible with transaction pooling. Either configure and test PgBouncer protocol-level prepared-statement tracking, or disable implicit preparation with a compatible mode such as default_query_exec_mode=exec. Read reference/pgbouncer-pooling-modes.md for the detailed compatibility choices.

Size from the database inward

Always bound the total pool; never maximize it to eliminate waiting. Budget server connections from CPU, memory, storage, and measured concurrency, reserve administration capacity, then divide the remainder among workloads. For ordinary OLTP, start testing near twice the database vCPU count and increase only when measurements show useful I/O wait. Load testing decides the final number.

Read the full file on GitHub · 74 lines

Files

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.

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. 4d ago First seen · 74 lines · 48 tokens per session scan A 2e3e0d4fe138

Subscribe to this mod's changes

managing-postgres-connections is a skill published in the GitHub repository pumarogie/claude-postgres-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 48 tokens to every session and 955 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-31.

Related

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.

Jeffallan/claude-skills · 54 tokens

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.

Jeffallan/claude-skills · 41 tokens

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…

timescale/pg-aiguide · 220 tokens

design-postgis-tables

Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.

timescale/pg-aiguide · 31 tokens

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…

timescale/pg-aiguide · 181 tokens

pgvector-semantic-search

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. Trigger when user asks to: Store or search vector embeddings in PostgreSQL Set up semantic search, similarity search, or nearest neighbor search Create HNSW or IVFFlat indexes for vectors…

timescale/pg-aiguide · 190 tokens