postgres-patterns-hardened

postgres-patterns-hardened is a skill for Claude Code from faberlens/hardened-skills. It costs 31 tokens per session (1,182 once invoked), scanned A, original, MIT.

A reference for designing and tuning PostgreSQL databases, including queries, schemas, indexes, security rules, and connection pooling. PostgreSQL is a relational database used to store structured application data.

In plain words
What is it for?
Write SQL and migrations, choose indexes and data types, design schemas, troubleshoot query performance, configure connection pooling, and implement Row Level Security.
Why use it?
It helps avoid common database design mistakes and gives practical patterns for improving slow queries and controlling data access.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the devops-hardened-skills plugin — 20 skills shipped together

Good fit Write SQL and migrations, choose indexes and data types, design schemas, troubleshoot query performance, configure connection pooling, and implement Row Level Security.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/faberlens/hardened-skills/postgres-hardened
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add faberlens/hardened-skills --skill postgres-hardened
Clone the repo
git clone --depth 1 https://github.com/faberlens/hardened-skills

Made for: Claude Code.

Or install devops-hardened-skills, the plugin that ships this one along with the rest of its 20 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgres-patterns-hardened

README.md
[![agentmods](https://agentmods.dev/badge/skills/faberlens/hardened-skills/postgres-hardened/github.svg)](https://agentmods.dev/skills/faberlens/hardened-skills/postgres-hardened)
Your own site
<a href="https://agentmods.dev/skills/faberlens/hardened-skills/postgres-hardened"><img src="https://agentmods.dev/badge/skills/faberlens/hardened-skills/postgres-hardened/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for postgres-patterns-hardened

Your own site · 80×15
<a href="https://agentmods.dev/skills/faberlens/hardened-skills/postgres-hardened"><img src="https://agentmods.dev/badge/skills/faberlens/hardened-skills/postgres-hardened.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,182 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00031 $0.01182
Opus 5 $0.00015 $0.00591
Sonnet 5 $0.00006 $0.00236
Haiku 4.5 $0.00003 $0.00118

Measured 7d ago against content hash f05afbcf269f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

postgres-patterns-hardened scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/postgres-hardened/SKILL.md · 157 lines

How it starts

The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PostgreSQL Patterns

Quick reference for PostgreSQL best practices. For detailed guidance, use the database-reviewer agent.

When to Activate

  • Writing SQL queries or migrations
  • Designing database schemas
  • Troubleshooting slow queries
  • Implementing Row Level Security
  • Setting up connection pooling

Quick Reference

Index Cheat Sheet

Query Pattern Index Type Example
WHERE col = value B-tree (default) CREATE INDEX idx ON t (col)
WHERE col > value B-tree CREATE INDEX idx ON t (col)
WHERE a = x AND b > y Composite CREATE INDEX idx ON t (a, b)
WHERE jsonb @> '{}' GIN CREATE INDEX idx ON t USING gin (col)
WHERE tsv @@ query GIN CREATE INDEX idx ON t USING gin (col)
Time-series ranges BRIN CREATE INDEX idx ON t USING brin (col)

Data Type Quick Reference

Use Case Correct Type Avoid
IDs bigint int, random UUID
Strings text varchar(255)
Timestamps timestamptz timestamp
Money numeric(10,2) float
Flags boolean varchar, int

Common Patterns

Composite Index Order:

-- Equality columns first, then range columns
CREATE INDEX idx ON orders (status, created_at);
-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'

Covering Index:

CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
-- Avoids table lookup for SELECT email, name, created_at

Partial Index:

CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
-- Smaller index, only includes active users

RLS Policy (Optimized):

CREATE POLICY policy ON orders
  USING ((SELECT auth.uid()) = user_id);  -- Wrap in SELECT!

UPSERT:

INSERT INTO settings (user_id, key, value)
VALUES (123, 'theme', 'dark')
ON CONFLICT (user_id, key)
DO UPDATE SET value = EXCLUDED.value;

Cursor Pagination:

SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
-- O(1) vs OFFSET which is O(n)

Read the full file on GitHub · 157 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 157 lines · 31 tokens per session scan A f05afbcf269f

Subscribe to this mod's changes

postgres-patterns-hardened is a skill published in the GitHub repository faberlens/hardened-skills (23 stars, last pushed 4mo ago), licensed MIT. It adds 31 tokens to every session and 1,182 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

postgres-hardening

Harden a PostgreSQL deployment whether managed or self-hosted. Covers pghba network and authentication rules, role separation (read-only, read-write, migration), row-level security for multi-tenant data, TLS configuration, backup encryption, and pgaudit logging. Invoke when provisioning a new Postgres, before opening…

GoldenWing-360/claude-security-skills · 86 tokens

sql-optimization-patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

aisa-group/skill-inject · 44 tokens

database-migration

Execute database migrations across ORMs and platforms with zero-downtime strategies, data transformation, and rollback procedures. Use when migrating databases, changing schemas, performing data transformations, or implementing zero-downtime deployment strategies.

aisa-group/skill-inject · 47 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 229 tokens

nw-database-technology-selection

Database comparison catalogs, RDBMS vs NoSQL selection criteria, CAP/ACID/BASE theory, OLTP vs OLAP, and technology-specific characteristics.

nWave-ai/nWave · 38 tokens

postgresdb

Use when PostgreSQL engine behaviour decides the answer — schema and type design, index choice, reading EXPLAIN on a slow query, zero-downtime DDL and backfills, or ops (roles, RLS, pooling, vacuum, partitioning, PITR). PG16, ORM-agnostic. NOT portable query logic (that is sql), NOT a managed provider's platform…

ericrisco/rsc-harness · 91 tokens