postgres-query

Query PostgreSQL databases with read-only defaults and EXPLAIN ANALYZE support.

7.2k|732|Updated Oct 11, 2022
One-click install
npx skills add https://github.com/civitai/civitai --skill postgres-query-civitai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-query
Source: https://github.com/civitai/civitai/tree/main/.claude/skills/postgres-query
Command: npx skills add https://github.com/civitai/civitai --skill postgres-query-civitai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pg.

What problem does it solve?

Ad-hoc PostgreSQL querying for testing, debugging, and performance analysis without risking unintended writes.

Core Features & Use Cases

  • Read-only by default against a replica to prevent write operations
  • EXPLAIN ANALYZE support for performance insight
  • Flexible query input via direct SQL or --file queries with optional JSON output
  • Optional --writable mode for approved write operations with explicit user permission
  • Safe defaults and timeouts to guard long-running queries

Quick Start

Run a simple ad-hoc query against the read-only replica to verify connectivity and basic results.

Frequently Asked Questions about postgres-query

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

FAQPage Schema
How do I safely run ad-hoc PostgreSQL queries for debugging without accidental writes?

Ad-hoc PostgreSQL querying is executed safely against a read-only replica by default to prevent unintended writes during testing and debugging. The Skill uses environment configuration via DATABASE_REPLICA_URL and supports timeouts to guard long-running queries.

Can I use EXPLAIN ANALYZE to check query performance with this setup?

EXPLAIN ANALYZE is fully supported for PostgreSQL performance analysis. You can run performance insight queries directly via SQL or file-based input, with optional JSON output to format the execution plan results.

How do I execute PostgreSQL queries from a file and output JSON?

PostgreSQL queries can be executed from files using the --file flag, with optional JSON output formatting. This flexible input method runs against the read-only replica using the DATABASE_REPLICA_URL connection string.

Is it possible to perform write operations in a guarded PostgreSQL querying mode?

Write operations are supported through an optional --writable mode that requires explicit user permission and a DATABASE_URL environment configuration. This guarded mode ensures approved writes only occur in supported scenarios.

What environment variables are needed to configure read-only PostgreSQL querying?

Read-only PostgreSQL querying requires the DATABASE_REPLICA_URL environment variable for connection strings and optional .env files for timeouts. To enable writable mode, the DATABASE_URL environment variable must also be configured.

How do I prevent long-running PostgreSQL queries from timing out during analysis?

Safe defaults and timeouts are configured to guard against long-running PostgreSQL queries during performance analysis. These protective measures are set via optional .env files alongside the required connection string configurations.