kyle-chalmers

Claude Code Postgres — Data skill for Claude Code

Data community

Query a real PostgreSQL database in plain English from the terminal with Claude Code, safely: read-only role first, read the SQL, honest about what leaves your machine.

How to install Claude Code Postgres

This entry records only its repository, not the path inside it, so there is no exact command to give. Open kyle-chalmers/claude-code-postgres and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code Postgres does

Query a real PostgreSQL database in plain English from the terminal with Claude Code, safely: read-only role first, read the SQL, honest about what leaves your machine. Companion to the video.

Alternatives in Data

  • Claude Code Usage Monitor — by Maciek-roboblog - A real-time terminal-based tool for monitoring Claude Code token usage 7k ★
  • 06 Ink React Terminal UI — Prompt 06: Verify and Fix the Ink/React Terminal UI Pipeline 2.3k ★
  • Knowledge Pipeline — Terminal-vibe sunum + LLM-Wiki skill'i. Ham sohbetleri, şemayla disipline edilen büyüyen bir wiki'ye dönüştürm 149 ★

README

Claude Code + PostgreSQL: query your database in plain English, safely

Point [Claude Code](https://www.anthropic.com/claude-code) at a real PostgreSQL database, ask questions in plain English, and read the answers, without ever giving the agent the power to change a single row or read a raw personal record. The safe version puts the guardrails at the database:

  1. Create a read-only role first so the agent cannot write to, drop, or delete your data. The database enforces it, not the model's good behavior.
  2. Put a curated, PII-safe schema in front of it (see Connect to PII safely) so it analyzes real data without ever reading raw personal values: hash what it must join on, drop the rest.
  3. Read the SQL it writes before it runs. A strong model rarely produces broken SQL; the quieter failure is correct SQL that answers the wrong question.
  4. Be honest about what leaves your machine. When the database is in the cloud the SQL runs on the provider's server (your local psql only sends the query text and receives rows), and your question, the schema, and the result rows go on to a separate model API.

![The plan: guardrails at the database before the agent ever connects, then psql, then reading every SQL statement before it runs](./images/the-plan-guardrails-first.png)

This repo is the companion to the video. It gives you a small sample database, the exact read-only role commands, and the prompts to try, so you can reproduce the whole thing in a few minutes.

Channel: [Kyle Chalmers Data Plus AI](https://www.youtube.com/@kylechalmersdataai)

How it connects (official-first)

`psql` is PostgreSQL's official, first-party command-line client. It ships with Postgres, so there is nothing third-party between Claude Code and your database, even when that database is a managed cloud one (Neon, Supabase, Amazon RDS or Aurora, Google Cloud SQL, Azure Database for PostgreSQL, Render, Railw