Secure PostgreSQL CLI for AI Agents

VerifiedCaution

Secure PostgreSQL CLI for AI agents to query databases, list tables, and describe schemas without handling credentials.

Sby Skills Guide Bot
Data & AIBeginner
7/25/2026
Claude CodeCursorCodex
#postgresql#sql-query#database#cli#schema-inspection

Recommended for

Automated summary

A skill that gives an agent read-only access to PostgreSQL through the pglr CLI without ever exposing connection credentials.

Strengths

  • Consistent JSON output (success, rowCount, rows, executionTimeMs) that agents can parse reliably
  • Parameterized queries via $1 and --params to prevent SQL injection
  • Writes are blocked by default and only unlocked with --allow-writes
  • Dedicated tables, describe and schema commands for exploring structure before querying

Limitations

  • Requires a global pglr install plus a human-configured connection before anything works
  • Capped at 1000 rows per query, which blocks large exports
  • No transaction or migration handling, only single statements
When to use it

Use it when an agent needs to inspect a PostgreSQL schema or query data without handling credentials itself.

When not to use it

Avoid it for bulk operations, multi-step transactions, or when the agent must manage its own direct database credentials.

Security analysis

Caution
Quality score90/100

The skill is not malicious and does not instruct exfiltration or destructive behavior, but it provides powerful database access and an explicit write capability. The risk is moderated by read-only defaults, restricted allowed-tools, and clear instruction to use writes only when requested.

Findings
  • •Grants database query access through pglr, which can expose sensitive data depending on configured permissions.
  • •Includes a write path via --allow-writes, allowing INSERT/UPDATE/DELETE when explicitly requested; safety depends on pglr's enforcement.
  • •Prerequisite example includes a PostgreSQL connection URL with credentials, which may leak via shell history or process listing if run carelessly.
  • •Depends on a globally installed npm package; supply-chain trust in pglr is assumed.
How this analysis is made

Examples

Explore a database schema
Connect to the configured database and give me an overview of the schema, then describe the orders table.
Parameterized lookup
Use pglr to find the user with email user@example.com and show me their id and signup date.
Recent pending orders
Query the 20 most recent pending orders with their id, status and created_at, and summarize them for me.

name: pglr description: Secure PostgreSQL CLI for AI agents. Query databases, list tables, describe schemas without handling credentials. Use when tasks involve database queries, data exploration, or schema inspection. license: MIT compatibility: Requires pglr CLI installed globally (npm install -g pglr). Human must configure connection first. metadata: author: progremir version: "1.0.0" allowed-tools: Bash(pglr:*)

pglr - PostgreSQL CLI for AI Agents

You have access to pglr, a secure PostgreSQL CLI. Use it to query databases without needing connection credentials.

Prerequisites

A human must first configure a connection:

pglr connect postgres://user:pass@host/database

If you get "No connection configured", ask the user to run the connect command.

Commands

Query the database

pglr query "SELECT * FROM users WHERE active = true"

With parameters (prevents SQL injection):

pglr query "SELECT * FROM users WHERE id = $1" --params '[123]'

List all tables

pglr tables

Describe a table's structure

pglr describe users
pglr describe myschema.orders

Get full schema overview

pglr schema

Output Format

All commands return JSON:

{
  "success": true,
  "rowCount": 5,
  "rows": [{"id": 1, "name": "Alice"}, ...],
  "executionTimeMs": 12,
  "truncated": false
}

On error:

{
  "success": false,
  "error": "Table does not exist"
}

Constraints

  • Read-only by default: INSERT, UPDATE, DELETE, DROP are blocked
  • Row limit: Max 1000 rows returned (use LIMIT for smaller results)
  • No credentials access: You cannot see or modify connection details

Write Operations

If the user explicitly requests data modification:

pglr query "INSERT INTO logs (message) VALUES ($1)" --params '["test"]' --allow-writes

Only use --allow-writes when the user explicitly asks to modify data.

Best Practices

  1. Always check table structure first:

    pglr describe users
    
  2. Use parameters for user input:

    # Good - parameterized
    pglr query "SELECT * FROM users WHERE email = $1" --params '["user@example.com"]'
    
    # Bad - string interpolation (SQL injection risk)
    pglr query "SELECT * FROM users WHERE email = 'user@example.com'"
    
  3. Limit results when exploring:

    pglr query "SELECT * FROM large_table LIMIT 10"
    
  4. Use schema command to understand the database:

    pglr schema
    

Multiple Connections

If multiple databases are configured:

# List available connections
pglr connections

# Query specific connection
pglr query "SELECT 1" --connection prod
pglr tables --connection staging

Example Workflow

# 1. Understand the database structure
pglr schema

# 2. Explore a specific table
pglr describe orders

# 3. Query data
pglr query "SELECT id, status, created_at FROM orders WHERE status = $1 ORDER BY created_at DESC LIMIT 20" --params '["pending"]'

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/secure-postgresql-cli-for-ai-agents-mrzxup10/download' --output '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md.part' && mv '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md.part' '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Environment declared by the author: Requires pglr CLI installed globally (npm install -g pglr). Human must configure connection first.

Tools declared by the author (check availability in your agent): Bash(pglr:*)

Original excerpt: Prerequisites

A human must first configure a connection:

pglr connect postgres://user:pass@host/database

If you get "No connection configured", ask the user to run the connect command.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && test -s '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/pglr' && cp -R '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10' '.claude/skills/pglr'

Cursor
test -f '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && test -s '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/pglr' && cp -R '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10' '.cursor/skills/pglr'

Codex
test -f '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && test -s '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/pglr' && cp -R '.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10' '.agents/skills/pglr'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10'

openskills read 'secure-postgresql-cli-for-ai-agents-mrzxup10'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/secure-postgresql-cli-for-ai-agents-mrzxup10/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills