Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

querying-local-postgres

Skill by PostHog

Runs read-only SQL against the local PostgreSQL app database in the PostHog repo, including EXPLAIN and EXPLAIN ANALYZE on SELECT. Built for developers who inspect tables, debug rows, or review query plans. Mutations are refused.

  • Score 84
  • 41k stars
  • NOASSERTION
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install querying-local-postgres

Built from the published package, never by AI.

git clone --depth 1 https://github.com/PostHog/posthog /tmp/posthog && mkdir -p ~/.claude/skills && cp -r /tmp/posthog/.agents/skills/querying-local-postgres ~/.claude/skills/querying-local-postgres

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install querying-local-postgres in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

The querying-local-postgres skill lets an AI assistant run read-only SQL against the local PostgreSQL app database in the PostHog repository. It uses psql and forces each connection to read-only with PGOPTIONS, so Postgres rejects writes. The assistant shows the SQL before running it, then reports the results and a short interpretation. By default it uses a local URL for user posthog on localhost port 5432, or the DATABASE_URL variable if one is set.

The skill covers EXPLAIN and EXPLAIN ANALYZE on SELECT statements for performance review. It refuses mutations such as INSERT, UPDATE, DELETE, and DDL. Analytics event data lives in ClickHouse rather than Postgres, so the skill points those questions to other tools. It is aimed at developers who debug app metadata such as teams, projects, flags, and Django models in a local PostHog setup.

Written from the project's SKILL.md and checked against it.

What it can do

  • Read-only SQL queriesRuns SELECT and WITH ... SELECT statements on the local app database over a read-only connection.
  • Query plan reviewRuns EXPLAIN and EXPLAIN ANALYZE on read-only SELECT statements to review performance.
  • Table inspectionLists and inspects PostHog tables, such as posthog_team, with psql.
  • Row-level debuggingChecks whether rows exist and how joins behave, for example for teams, projects, or flags.
  • Mutation refusalRefuses INSERT, UPDATE, DELETE, DDL and other write requests and explains the skill is read-only.

What you need

  • psql client
  • Local PostgreSQL running, such as through Docker Compose
  • PostHog repository checkout
  • Node.js and npx for the dotenv option

Try asking

  • Show the first 100 rows of posthog_team with psql
  • Explain the query plan for this slow SELECT on posthog_person
  • Check whether a feature flag row links to the right team

Good to know

  • Read-only only. Writes, schema changes and grants are refused.
  • EXPLAIN ANALYZE actually runs the SELECT, which can be slow on large scans.
  • Analytics events live in ClickHouse, not Postgres.
  • Queries should run from the PostHog repo root.

Security check

B
  • Allowed to use Bash without limitsIn SKILL.md

Checked automatically: .agents/skills/querying-local-postgres/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: Bash

  • SKILL.md10 KB

Alternatives to querying-local-postgres

All alternatives →
hugging-face-datasetssickn33
94

Creates, configures and manages datasets on the Hugging Face Hub, including SQL-based querying and transformation. Built for people who edit dataset content and metadata directly, alongside the HF MCP server.

AAA Skill 50k
db-repairgarrytan
94

Diagnoses and repairs gbrain's Postgres access when a command or MCP result shows a GBRAIN_DB_ACCESS marker, or when the operator reports the brain database is down. It runs the hardcoded gbrain db-repair ladder and verifies the result with a re-probe.

AAA Skill 34k
alloydb-basicsgoogle
94

Manages clusters, instances, and backups for AlloyDB for PostgreSQL. Built for creating, configuring, and administering AlloyDB databases, not general PostgreSQL or Cloud SQL instances.

AAA Skill 26k
clickhouse-logs-queriessupabase
94

Writes, reviews and migrates Supabase logs queries against the ClickHouse logs table served by the logs.all.otel endpoint. Built for developers who write Logs Explorer SQL or convert older BigQuery logs queries.

AAA Skill 116k
fix-slow-queriespaperclipai
94

Diagnoses and fixes slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local benchmarks, regression tests, and a pull request with passing checks. Built for engineers working on Paperclip.

AAA Skill 119k
prisma-8prisma
94

Guides AI assistants through Prisma 8 projects built on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo. It covers data contracts, migrations, typed queries and runtime setup for developers on Prisma 8.

AAA Skill 48k

Compare with hugging-face-datasets, db-repair or alloydb-basics

querying-local-postgres: common questions

Can this skill change data in my local PostgreSQL database?

No. The skill forces a read-only connection with PGOPTIONS and refuses INSERT, UPDATE, DELETE, DDL and similar statements. Postgres also rejects writes on that connection.

Where are analytics events stored in PostHog?

The source says analytics event data lives in ClickHouse, not Postgres. For events-style questions it recommends HogQL or ClickHouse tools.

Which database URL does the skill use by default?

It uses postgres://posthog:posthog@localhost:5432/posthog by default. It uses the DATABASE_URL variable instead when the user's local setup differs.

How do I install querying-local-postgres?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is querying-local-postgres free?

The code is published under the NOASSERTION licence. The service it connects to may have its own pricing.

Is querying-local-postgres safe to use?

It scores 84 of 100. Grades: maintenance A, licence F, quality A. Security check: grade B (allowed to use bash without limits). Review the code before you install. How grades work.

What are alternatives to querying-local-postgres?

Similar skills: hugging-face-datasets, db-repair, alloydb-basics, clickhouse-logs-queries.

querying-local-postgres Install

Add to stack

Loading.