postgres-patterns

postgres-patterns is a skill for Claude Code, Codex from pekral/cursor-rules. It costs 73 tokens per session (2,813 once invoked), scanned A, original, MIT.

A guide to designing advanced features in PostgreSQL, a relational database system, including indexes, JSON data, locking, queues, pagination, and access rules.

In plain words
What is it for?
Use it when building PostgreSQL schemas or Laravel data-access code that needs advanced indexing, upserts, queue workers, row-level security, or precise data types.
Why use it?
It helps avoid database designs that are slow, unsafe, or incompatible with the installed PostgreSQL version.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building PostgreSQL schemas or Laravel data-access code that needs advanced indexing, upserts, queue workers, row-level security, or precise data types.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pekral/cursor-rules/postgres-patterns
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 pekral/cursor-rules --skill postgres-patterns
Clone the repo
git clone --depth 1 https://github.com/pekral/cursor-rules

Made for: Claude Code, Codex.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/pekral/cursor-rules/postgres-patterns"><img src="https://agentmods.dev/badge/skills/pekral/cursor-rules/postgres-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,813 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.00073 $0.02813
Opus 5.5 $0.00029 $0.01125
Sonnet 5.5 $0.00015 $0.00563
Haiku 4.5 $0.00007 $0.00281

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

Security

Grade A, and why

postgres-patterns 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 3mo 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-patterns/SKILL.md · 217 lines

How it starts

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

PostgreSQL Patterns

Constraints

  • Apply @rules/sql/optimalize.mdc — it already owns indexing fundamentals, SARGable WHERE, seek/keyset pagination, EXPLAIN, transactions/locking basics, and batch-over-per-row. Do not re-explain those; defer to it. Note it is written for MySQL — translate engine-specific syntax (EXPLAIN ANALYZE, plan flags) to Postgres equivalents here.
  • This skill is the Postgres counterpart to @skills/mysql-patterns/SKILL.md. It is for designing features. For diagnosing an existing slow query, the closest fit is @skills/mysql-problem-solver/SKILL.md (apply its method; substitute Postgres EXPLAIN/pg_stat_statements).
  • If the project uses Laravel, also apply @rules/laravel/laravel.mdc and @rules/laravel/architecture.mdc.
  • Apply @rules/security/backend.md — parameterized queries / Eloquent only, least-privilege DB users, never hardcode credentials.
  • final classes, declare(strict_types=1), Pest tests for any data-access code added.
  • Confirm the major version (SELECT version();) before using version-specific features — MERGE (15+), covering INCLUDE indexes (11+), and NULLS NOT DISTINCT (15+) are not in older servers.

Use when

  • Adding jsonb columns, GIN/BRIN/partial/covering indexes, or full-text search to a Laravel app on Postgres.
  • Building a queue/worker that pulls jobs with FOR UPDATE SKIP LOCKED, or paginating large result sets by cursor.
  • Adding ON CONFLICT upserts, Row-Level Security for multi-tenancy, or correct timestamptz/numeric typing.
  • Reviewing a migration that introduces any of the above on a large table.

Set DB_CONNECTION=pgsql. These topics complement the query-tuning rules; they are not covered there.

Data Type Discipline

Pick the right type once — wrong choices are expensive to migrate later.

Schema::create('orders', function (Blueprint $table): void {
    $table->id();                                  // bigint identity
    $table->decimal('amount', 12, 2);              // numeric — never float/double for money
    $table->timestampTz('placed_at');              // timestamptz — stores UTC instant
    $table->jsonb('meta')->default('{}');          // jsonb (binary, indexable), not json
    $table->boolean('is_paid')->default(false);
});

Read the full file on GitHub · 217 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. 3mo ago First seen · 217 lines · 73 tokens per session scan A 93bf4e4e5952

Subscribe to this mod's changes

postgres-patterns is a skill published in the GitHub repository pekral/cursor-rules (11 stars, last pushed yesterday), licensed MIT. It adds 73 tokens to every session and 2,813 once invoked, about $0.0003 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-31.

Related

postgres-patterns compared with skills from other repositories

postgres-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
postgres-patternspekral/cursor-rulesSkill11yesterdayMITA73Claude Code, Codex
postgresql-table-designwshobson/agentsSkill43kyesterdayMITA37Claude Code
laravel-eloquentFoysal50x/skillsSkill121mo agoMITA93Claude Code
laravel-brainlaramint/laravel-brainSkill94023d agononeA118Claude Code, Codex
Laravel Eloquent N+1 and Query Efficiency Reviews977043/river-reviewSkill8yesterdayMITA48Claude Code
Laravel Migration Safety Reviews977043/river-reviewSkill8yesterdayMITA32Claude Code
laravel-mysql-to-postgresmajdghithan/agent-skillsSkill72mo agoMITA104Claude Code, Codex