querying-local-postgres
Installation
SKILL.md
Querying local Postgres (READ-ONLY) — PostHog repo
User's query: $ARGUMENTS
Scope: This repo uses PostgreSQL for app metadata (teams, projects, flags, Django models, etc.). Analytics event data lives in ClickHouse, not Postgres — use HogQL / ClickHouse tools for events-style questions unless the user explicitly wants Postgres.
When to use
- User asks to query the database, inspect tables, or run SQL against Postgres
- Debugging: Row-level checks (e.g. why a team/project/flag row looks wrong), migrations, constraints, duplicate keys
- Performance:
EXPLAIN/EXPLAIN (ANALYZE, …)on read-onlySELECTagainst Django or app tables
Instructions
- Strictly forbid mutations — See "Mutations strictly forbidden" below. If the user asks for any write or mutation, refuse and explain the skill is read-only.
- Translate the user's question into one or more read-only SQL statements.
- Show the SQL in a code block before running.
- Run using the command pattern below (always with
PGOPTIONS='-c default_transaction_read_only=on'to force a read-only connection). - Show results and give a brief interpretation (especially when used for debugging or plan review).