database-postgresql

Inspect PostgreSQL schemas, run read-only queries, and diagnose locks and replication health.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill database-postgresql-erwinv2k-tkg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-postgresql
Source: https://github.com/erwinv2k-TKG/AgentesVSC/tree/main/packs/incidentfox/sre-agent/.claude/skills/database-postgresql
Command: npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill database-postgresql-erwinv2k-tkg

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires psycopg2, and includes scripts (resource) components.

What problem does it solve? Investigating PostgreSQL issues during an incident requires knowing the right catalog queries for locks, replication lag, table sizes, and long-running queries. This Skill packages those diagnostic queries into ready-to-run scripts so you can inspect a database quickly without writing SQL from scratch. ## Core Features & Use Cases - Schema-First Exploration: List tables, describe columns with primary and foreign keys, and inspect indexes before running queries. - Safe Read-Only Queries: Execute SELECT, SHOW, EXPLAIN, and WITH statements with automatic row limits; DML/DDL and multi-statement queries are blocked. - Health Diagnostics: Detect lock contention and blocking queries, monitor replication lag on primaries and standbys, find long-running queries, and analyze table and index sizes. - Use Case: During an incident where the application is timing out, run get_locks.py to find blocking relationships, then get_long_running_queries.py to identify the offending query, all with credentials injected transparently by the proxy layer. ## Quick Start Ask the agent to list the tables in the PostgreSQL database and check for any blocking locks or long-running queries.

Frequently Asked Questions about database-postgresql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find blocking queries in PostgreSQL?

Run the get_locks.py script to query pg_locks joined with pg_stat_activity. It returns current locks, waiting locks, and blocking relationships showing which PID blocks which query, along with wait events and durations.

How to check PostgreSQL replication lag from a script?

Use get_replication_status.py, which detects whether the server is a primary or standby. On primaries it reports per-replica lag in bytes from pg_stat_replication; on standbys it reports lag in seconds, with a health classification.

Can I run UPDATE or DELETE statements with this tool?

No. The execute_query.py script only allows SELECT, SHOW, EXPLAIN, DESCRIBE, and WITH statements. It also blocks multi-statement queries and enforces a read-only transaction for defense in depth.

Why is POSTGRES_PASSWORD not visible in environment variables?

Credentials are injected transparently by a proxy layer at connection time, so the password never appears in the environment. You only need to set non-secret variables like POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DATABASE, and POSTGRES_SCHEMA.

How do I find the largest tables in a PostgreSQL schema?

Run get_table_sizes.py to list tables sorted by total relation size, including table bytes, index bytes, pretty-printed sizes, and estimated row counts. You can filter by schema or a specific table name.