postgres-data-modeling

postgres-data-modeling is a skill for Claude Code, Codex from AbdulmalekAlshugaa/claude-agents-fullstack. It costs 62 tokens per session (1,155 once invoked), scanned A, original, MIT.

A set of conventions for using PostgreSQL, a relational database, with Drizzle ORM in TypeScript. It covers table definitions, relationships, indexes, migrations, connections, and query patterns.

In plain words
What is it for?
Use it when creating or changing PostgreSQL tables, defining relationships and indexes, writing Drizzle queries, or investigating slow queries.
Why use it?
It removes guesswork when changing database structure or writing queries, helping keep application code and database migrations consistent.

Skill for Claude CodeCodex

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

Good fit Use it when creating or changing PostgreSQL tables, defining relationships and indexes, writing Drizzle queries, or investigating slow queries.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling
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 AbdulmalekAlshugaa/claude-agents-fullstack --skill postgres-data-modeling
Clone the repo
git clone --depth 1 https://github.com/AbdulmalekAlshugaa/claude-agents-fullstack

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-data-modeling

README.md
[![agentmods](https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling/github.svg)](https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling)
Your own site
<a href="https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling"><img src="https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling/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-data-modeling

Your own site · 80×15
<a href="https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling"><img src="https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/postgres-data-modeling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 62 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,155 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.00062 $0.01155
Opus 5 $0.00031 $0.00577
Sonnet 5 $0.00012 $0.00231
Haiku 4.5 $0.00006 $0.00115

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

Security

Grade A, and why

postgres-data-modeling 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 4d 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-data-modeling/SKILL.md · 111 lines

How it starts

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

PostgreSQL + Drizzle conventions

Schema definition pattern

One file per domain area in src/lib/db/schema/<name>.ts, all re-exported from src/lib/db/schema/index.ts (drizzle-kit points at the barrel):

import { pgTable, varchar, timestamp, uuid, index, uniqueIndex } from 'drizzle-orm/pg-core'

export const users = pgTable(
  'users',
  {
    id: uuid().primaryKey().defaultRandom(),
    email: varchar({ length: 255 }).notNull(),
    name: varchar({ length: 120 }).notNull(),
    role: varchar({ length: 20, enum: ['user', 'admin'] }).notNull().default('user'),
    createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
    updatedAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
  },
  (t) => [
    uniqueIndex('users_email_idx').on(t.email),
  ],
)

export type UserRow = typeof users.$inferSelect
export type NewUser = typeof users.$inferInsert

Connection in src/lib/db/index.ts, cached on globalThis (Next.js hot reload):

import { drizzle } from 'drizzle-orm/node-postgres'
import { env } from '@/lib/env'
import * as schema from './schema'

const cached = (globalThis as { __db?: ReturnType<typeof create> })
function create() {
  return drizzle(env.DATABASE_URL, { schema })
}
export const db = (cached.__db ??= create())

Rules

  • Types come from the schema: $inferSelect / $inferInsert — never hand-write a row type. API DTOs still derive from Zod (z.infer); map row → DTO in the service and never return raw rows to the client.
  • Every table gets createdAt/updatedAt (withTimezone: true); bump updatedAt in the service on update.
  • Foreign keys are real: .references(() => users.id, { onDelete: 'cascade' | 'restrict' }) chosen deliberately — say which and why. Add a relations() definition when you want db.query.* nested reads.
  • Index every real query pattern in the table's third argument; composite indexes ordered by selectivity, matching the WHERE + ORDER BY they serve. Flag indexes nothing uses.
  • Queries are built with the query builder or db.query — never string concatenation. If you must drop to SQL, use the sql template tag (it parameterises); sql.raw() with user input is an injection, full stop.
  • Ownership in the WHERE clause: db.select().from(items).where(and(eq(items.id, id), eq(items.userId, userId))) — not a post-fetch if. Return 404 for both missing and unowned.
  • No N+1: batch with inArray, join, or a db.query relation — never await a query inside a loop.
  • Always paginate list queries: .limit(n) + keyset cursor (where(lt(t.createdAt, cursor)) with a matching index) for real datasets; offset only for small admin lists.
  • Unique violations: catch Postgres error code 23505 in the service and return a 409-shaped result — don't let it bubble as a 500.

Read the full file on GitHub · 111 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. 4d ago First seen · 111 lines · 62 tokens per session scan A 40ec71303c05

Subscribe to this mod's changes

postgres-data-modeling is a skill published in the GitHub repository AbdulmalekAlshugaa/claude-agents-fullstack (3 stars, last pushed 3d ago), licensed MIT. It adds 62 tokens to every session and 1,155 once invoked, about $0.0003 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-05.