npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@khaale/postgres-cli

v0.2.2

Published

Read-only PostgreSQL explorer CLI for agents

Readme

pgc

Read-only PostgreSQL explorer for agents.

pgc works with named sessions such as qa and uat. The agent selects a session name; passwords are resolved inside the process and are never printed by the CLI.

Configuration

The platform-specific config path is shown by:

pgc config path --json

Initialize an empty config with:

pgc config init --json

A config contains named sessions and bounded read defaults:

{
  "sessions": {
    "qa": {
      "host": "qa.example.internal",
      "port": 5432,
      "database": "app",
      "user": "agent",
      "passwordEnv": "PGC_QA_PASSWORD",
      "ssl": true
    },
    "uat": {
      "host": "uat.example.internal",
      "database": "app",
      "user": "agent",
      "passwordEnv": "PGC_UAT_PASSWORD"
    }
  },
  "defaults": {
    "statementTimeoutMs": 30000,
    "rowLimit": 1000,
    "byteLimit": 1048576
  }
}

Use password instead of passwordEnv only when the local config policy permits storing a password. The config file is written with restrictive permissions where supported. pgc never returns either value in JSON, Markdown, CSV, errors, or diagnostics.

Agent workflow

Start with the preflight check:

pgc doctor --json

Explore a large schema progressively:

pgc schema overview --session qa --json
pgc schema search --session qa --query user --type table --json
pgc schema table --session qa --schema public --table users --json
pgc schema relations --session qa --schema public --table users --direction both --json

schema table includes PostgreSQL comments for the table and its columns when they are defined. schema search matches both object names and comments, which makes documented business terms useful for finding tables and columns.

Schema list responses include continuation when the requested limit is reached. Table details expose table.availability as available, inaccessible, or not_found.

Run a bounded read-only query:

pgc query --session qa --sql 'SELECT id, email FROM public.users WHERE id = $1' --params '[42]' --json

Override the configured row limit for one query while keeping the session's byte and statement-timeout limits:

pgc query --session qa --row-limit 5000 --sql 'SELECT id, email FROM public.users' --json

Read complex SQL from a UTF-8 file. This is also convenient on Windows when PowerShell quoting would be cumbersome:

pgc query --session qa --sql-file .\queries\users.sql --row-limit 5000 --json

--sql and --sql-file are mutually exclusive. The SQL file may contain a leading UTF-8 BOM; it is ignored. The row-limit override does not disable the configured byte limit or statement timeout.

Compare two independently supplied queries by same-named key columns. Use SQL aliases when the source column names differ:

pgc compare \
  --left-session qa \
  --right-session uat \
  --left-query 'SELECT id, status FROM public.users' \
  --right-query 'SELECT user_id AS id, status FROM public.accounts' \
  --key id \
  --json

Run pgc --help or pgc <command> --help for generated command and option help. Output flags are conventionally placed after the command; the legacy form with --json before the command remains accepted.

Safety and output

  • Every query runs in a PostgreSQL read-only transaction.
  • Mutating, session-control, transaction-control, and multi-statement SQL is rejected before execution.
  • Queries are bounded by statement timeout, row limit, and result byte limit. --row-limit can override the configured row limit for one query, but byte and timeout limits always remain active.
  • JSON is the canonical agent format. --md renders a human-readable view; --csv is for tabular query results only.
  • Truncated, timed-out, unavailable, or incompatible comparison inputs are marked incomplete and are never reported as complete equality.