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

@sivansakthivel_06/pg-agent

v1.0.0

Published

A new CLI generated with oclif

Readme

pg-agent

AI-native PostgreSQL deployment validation CLI — powered by Google Gemini

npm version Node.js version License Docker required

pg-agent is a CLI tool designed to eliminate "deployment anxiety" for PostgreSQL developers. By leveraging LLMs (Large Language Models), it automatically generates comprehensive pgTAP unit tests for your migration scripts, executes them in an isolated Docker sandbox, and even self-heals failing tests by analyzing root causes. It ensures your schema changes are correct, your triggers fire as expected, and your functions handle edge cases before they ever touch production.


🚀 Quick Demo

$ pg-agent validate migration_v1.sql

🔍 Parsing SQL... Found 3 objects.
🏗 Building context... 
✨ Generating pgTAP tests with Gemini... Done (12 assertions).
🐳 Starting sandbox... Container started on port 5450.
🚀 Running deployment... ✅ All 3 statements executed successfully (45ms).
🧪 Running tests... ❌ 10/12 tests passed (112ms).

🔄 Healing attempt 1/3...
📊 Healing Analysis:
┌────────┬────────────────────┬────────────────────────────────────────┐
│ Test # │ Category           │ Root Cause                             │
├────────┼────────────────────┼────────────────────────────────────────┤
│ 7      │ missing_fixture    │ calculate_order_total needs an order.  │
└────────┴────────────────────┴────────────────────────────────────────┘

✅ All tests healed after 1 attempt.
✅ PASSED
12 assertions → migration_v1.test.sql

🛠 Requirements

  • Node.js: 22 or higher
  • Docker: Must be running locally (used for sandbox isolation)
  • pg_prove: Part of the pgTAP toolset.
    • macOS: brew install pgformatter (includes dependencies) or cpan TAP::Parser::SourceHandler::pgTAP
    • Ubuntu: sudo apt install libtap-parser-sourcehandler-pgtap-perl
  • Google Gemini API Key: Get one for free at Google AI Studio

📦 Installation

npm install -g pg-agent

⏱ 60-Second Quickstart

Step 1: Configure

pg-agent config set

Follow the prompts to select Gemini as your provider and paste your API key.

Step 2: Create a Deployment File

Create deployment.sql:

CREATE TABLE users (id UUID PRIMARY KEY, email TEXT UNIQUE);
CREATE OR REPLACE FUNCTION get_user_count() RETURNS INT AS 'SELECT count(*)::int FROM users' LANGUAGE sql;

Step 3: Validate

pg-agent validate deployment.sql

Step 4: Review Results

pg-agent will generate deployment.test.sql, spin up a sandbox, deploy your SQL, run the tests, and report back.


⌨ Commands Overview

| Command | What it does | When to use it | | :--- | :--- | :--- | | pg-agent chat | Interactive AI chat | When you need help debugging or writing SQL | | pg-agent validate | Full pipeline (Gen → Test → Heal) | Before committing a migration or PR | | pg-agent generate | Create pgTAP tests only | When you want to review/edit tests manually | | pg-agent analyze | Parse SQL & dependency graph | To check deployment order or find missing refs | | pg-agent run | Execute tests in sandbox | When you have existing test files | | pg-agent config | Manage settings | Initial setup or switching models |


📖 Full Documentation


⚙ How it works

deployment.sql 
      ↓
  [ Parser ] → Dependency Graph & Object Detection
      ↓
  [ Gemini ] → Context-aware pgTAP Test Generation
      ↓
[ Docker Sandbox ] ← pgTAP Extension & psql
      ↓
  [ pg_prove ] → TAP Output Analysis
      ↓
  [ Healer ] → AI Failure Analysis & Automatic Repair
      ↓
   [ Report ] → Final Status & Saved Test Files

🤝 Contributing

We welcome contributions! Please see our Contributor Guide for setup instructions and project conventions.

📄 License

MIT © 2026 SivanSakthivel