hivemind: Skill for Claude Code

.claude/skills/postgres-database/SKILL.md

postgres-database is a skill for Claude Code from cohen-liel/hivemind. It costs 36 tokens per session (612 once invoked), scanned A, original, Apache-2.0.

A set of patterns for designing PostgreSQL databases, including tables, relationships, indexes, and migrations. PostgreSQL is a relational database system that stores structured data in tables.

In plain words
What is it for?
Use it when designing schemas, adding database migrations, creating indexes, or improving PostgreSQL queries.
Why use it?
It helps avoid inconsistent database structures, missing relationships, slow common queries, and unsafe changes to an existing database.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: positional $N argument.

This is cohen-liel/hivemind's own configuration. It tells Claude Code how to work on hivemind itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything hivemind configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cohen-liel/hivemind. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cohen-liel/hivemind/main/.claude/skills/postgres-database/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/cohen-liel/hivemind

Made for: Claude Code.

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-database

README.md
[![agentmods](https://agentmods.dev/badge/skills/cohen-liel/hivemind/postgres-database/github.svg)](https://agentmods.dev/skills/cohen-liel/hivemind/postgres-database)
Your own site
<a href="https://agentmods.dev/skills/cohen-liel/hivemind/postgres-database"><img src="https://agentmods.dev/badge/skills/cohen-liel/hivemind/postgres-database/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-database

Your own site · 80×15
<a href="https://agentmods.dev/skills/cohen-liel/hivemind/postgres-database"><img src="https://agentmods.dev/badge/skills/cohen-liel/hivemind/postgres-database.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 612 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.00036 $0.00612
Opus 5.5 $0.00014 $0.00245
Sonnet 5.5 $0.00007 $0.00122
Haiku 4.5 $0.00004 $0.00061

Measured 1mo ago against content hash 2681abed2fd4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

postgres-database 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 1mo 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.

.claude/skills/postgres-database/SKILL.md · 75 lines

How it starts

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

PostgreSQL Database Patterns

Schema Design Principles

  • Always add created_at, updated_at timestamps to every table
  • Use UUID or BIGSERIAL for primary keys (UUID for distributed systems)
  • Use foreign key constraints (never orphaned rows)
  • Normalize to 3NF, then denormalize only for proven performance needs
  • Soft delete with deleted_at TIMESTAMP NULL instead of hard delete

Essential Indexes

-- Always index foreign keys
CREATE INDEX idx_posts_user_id ON posts(user_id);

-- Composite index for common filter+sort patterns
CREATE INDEX idx_posts_user_created ON posts(user_id, created_at DESC);

-- Partial index for active records only
CREATE INDEX idx_users_active_email ON users(email) WHERE deleted_at IS NULL;

-- Full text search
CREATE INDEX idx_posts_fts ON posts USING GIN(to_tsvector('english', title || ' ' || body));

Migration Pattern (Alembic)

def upgrade():
    op.create_table('posts',
        sa.Column('id', sa.BigInteger(), primary_key=True),
        sa.Column('user_id', sa.BigInteger(), sa.ForeignKey('users.id'), nullable=False),
        sa.Column('title', sa.String(255), nullable=False),
        sa.Column('body', sa.Text(), nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.func.now()),
        sa.Column('updated_at', sa.DateTime(timezone=True), onupdate=sa.func.now()),
    )
    op.create_index('idx_posts_user_id', 'posts', ['user_id'])

def downgrade():
    op.drop_table('posts')

Query Patterns

-- Pagination (use keyset, not OFFSET for large tables)
SELECT * FROM posts
WHERE created_at < $1  -- cursor
ORDER BY created_at DESC
LIMIT 20;

-- Avoid N+1: use JOIN or subquery
SELECT u.*, COUNT(p.id) as post_count
FROM users u
LEFT JOIN posts p ON p.user_id = u.id
GROUP BY u.id;

-- Upsert
INSERT INTO settings(user_id, key, value)
VALUES ($1, $2, $3)
ON CONFLICT (user_id, key) DO UPDATE SET value = EXCLUDED.value;

Rules

  • NEVER use SELECT * in production queries — list columns explicitly
  • Always use parameterized queries — never f-string SQL (SQL injection risk)
  • Use connection pooling (PgBouncer or SQLAlchemy pool_size)
  • Run EXPLAIN ANALYZE on slow queries before adding indexes
  • Use transactions for multi-table writes
  • Vacuum and analyze after bulk operations
  • Set statement_timeout to prevent runaway queries

Read the full file on GitHub · 75 lines

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. 1mo ago First seen · 75 lines · 36 tokens per session scan A 2681abed2fd4

Subscribe to this mod's changes

postgres-database is a skill published in the GitHub repository cohen-liel/hivemind (112 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 36 tokens to every session and 612 once invoked, about $0.0001 per session on Opus 5.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-08-30.

Related

Other skills, from other repositories

ring:using-lib-systemplane

Using lib-systemplane, the hot-reload runtime-config plane (Postgres LISTEN/NOTIFY or MongoDB change streams), in two modes. Sweep Mode detects DIY config reload (SIGHUP, fsnotify, viper, pgx LISTEN), manual tenant-scoping, hand-built admin CRUD, and v4 residue. Reference Mode catalogs client lifecycle and…

LerianStudio/ring · 106 tokens

ring:using-outbox

Using the transactional-outbox pattern across lib-streaming (writer) and lib-commons/v5/commons/outbox (repository + relay), in two modes. Sweep Mode detects DIY outbox tables, hand-rolled relay loops, send-and-pray emits, missing WithOutboxTx wrapping, and broker calls inside DB transactions. Reference Mode catalogs…

LerianStudio/ring · 98 tokens

ring:mapping-service-resources

Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects existing Postgres migrations, emits an HTML…

LerianStudio/ring · 97 tokens

ring:designing-data-model

Designing the physical data model as a real stack-native schema (schema.sql with CREATE TABLE DDL, indexes, and constraints for Postgres/Go; schema.prisma for Prisma/TS; Postgres schema.sql as fallback) from the Gate 4 OpenAPI spec and TRD. Gate 5 of ring:planning-large-features; runs after…

LerianStudio/ring · 120 tokens

db-audit

Database performance and safety audit. 70+ checks across 13 dimensions (DB1-DB13): query patterns, indexes, schema design, connections, transactions, migrations, caching, query optimization, ORM anti-patterns, observability, data lifecycle, DB security, and migration deployment safety. Code-level checks for all ORMs.…

greglas75/zuvo · 115 tokens

performance-audit

Full-stack performance health check across 12 dimensions. Rendering, bundles, assets, API/network, algorithms, memory, database, caching, Web Vitals, backend runtime, concurrency, and framework-specific pathologies. Evidence-based Impact Models with confidence tiers and a prioritized optimization roadmap. Switches…

greglas75/zuvo · 90 tokens