Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Postgres

ASecurity

Read-only PostgreSQL database querying, schema introspection, and query planning. Use when the user asks to query a database, look up data, check a table, describe a schema, list tables, show indexes, explain a query plan, or any other read-only PostgreSQL interaction. Triggers on requests like "query the users table", "show me the schema", "what tables are in staging", "run this SQL", "describe the orders table", "check the database", "how many rows in X", "explain this query".

2 stars
0 votes
0 copies
0 views
Added 9/28/2026
databasespythongobashsqlgitdatabase

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add dversoza/claude-skills --skill postgres --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Postgres?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Postgres
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dversoza-postgres/badge)](https://www.skillsdirectory.com/skills/dversoza-postgres)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: postgres
description: Read-only PostgreSQL database querying, schema introspection, and query planning. Use when the user asks to query a database, look up data, check a table, describe a schema, list tables, show indexes, explain a query plan, or any other read-only PostgreSQL interaction. Triggers on requests like "query the users table", "show me the schema", "what tables are in staging", "run this SQL", "describe the orders table", "check the database", "how many rows in X", "explain this query".
---

# Postgres

Read-only access to PostgreSQL databases via `psql`. All connections enforce `default_transaction_read_only=on` at the server level -- writes and DDL are rejected by PostgreSQL itself.

## Connection Setup

The script resolves database aliases from a `` ```pg-databases``` `` fenced code block in the project's `CLAUDE.local.md`. It searches from the current working directory upward. Credentials never appear on the command line -- only the alias is passed as an argument.

To discover available aliases:

```bash
python3 ~/.claude/skills/postgres/scripts/pg_query.py list
```

If no `CLAUDE.local.md` exists or it has no `pg-databases` block, ask the user for connection details and suggest they add a block like this to their project's `CLAUDE.local.md`:

````markdown
```pg-databases
staging=postgres://user:pass@staging-host:5432/myapp
local=postgres://localhost:5432/myapp_dev
analytics=postgres://analyst:pass@analytics-host:5432/warehouse
```
````

Remind the user that `CLAUDE.local.md` should be in `.gitignore` to keep credentials out of version control.

Do NOT pass connection URIs on the command line. Always use the alias.

## Subcommands

All subcommands take a database alias as the first argument.

### Introspection

```bash
python3 ~/.claude/skills/postgres/scripts/pg_query.py schemas staging                    # list non-system schemas
python3 ~/.claude/skills/postgres/scripts/pg_query.py tables staging                     # list tables in public schema
python3 ~/.claude/skills/postgres/scripts/pg_query.py tables staging --schema analytics  # list tables in a specific schema
python3 ~/.claude/skills/postgres/scripts/pg_query.py describe staging users             # columns, types, nullability
python3 ~/.claude/skills/postgres/scripts/pg_query.py describe staging analytics.events  # schema-qualified table
python3 ~/.claude/skills/postgres/scripts/pg_query.py indexes staging users              # indexes on a table
```

### Queries

```bash
python3 ~/.claude/skills/postgres/scripts/pg_query.py query staging "SELECT id, name FROM users LIMIT 10"
python3 ~/.claude/skills/postgres/scripts/pg_query.py explain staging "SELECT id, name FROM users WHERE active = true"
```

All subcommands return JSON to stdout. Errors go to stderr as JSON with an `error` field.

## Query Guidelines

- Always add `LIMIT` to queries unless the user explicitly asks for all rows or the query already includes one. Default to `LIMIT 100`.
- Prefer specific columns over `SELECT *` when the table structure is known (use `describe` first if needed).
- For large result sets, suggest the user narrow the query rather than removing the limit.
- Writes are impossible: the connection is read-only at the PostgreSQL session level. If a write is attempted, psql returns `ERROR: cannot execute X in a read-only transaction`. Report this to the user and explain the read-only constraint.
- When exploring an unfamiliar database, start with `schemas` then `tables` then `describe` before running queries.

Attribution

dversozadversoza
View sourceMore from dversoza →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Mysql Best Practices

MySQL development best practices for schema design, query optimization, and database administration

2481 votes

Jpa Patterns

Spring Boot中的JPA/Hibernate实体设计、关系、查询优化、事务、审计、索引、分页和连接池模式。

2456590 votes

Clickhouse Io

ClickHouse数据库模式、查询优化、分析和数据工程最佳实践,适用于高性能分析工作负载。

2456590 votes

Postgres Patterns

基于Supabase最佳实践的PostgreSQL数据库模式,用于查询优化、架构设计、索引和安全。

2456590 votes

Sql Optimization Patterns

Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.

458250 votes
View all in databases →