prisma-orm-patterns-and-migrations

prisma-orm-patterns-and-migrations is a skill for Claude Code, Codex from hamzabellouch/agent-skills. It costs 58 tokens per session (1,434 once invoked), scanned A, original, MIT.

A guide to using Prisma, a tool that maps application code to database tables, in Node.js and TypeScript applications. It covers schema design, query performance, connection pooling, tenant separation, and database migrations without extended downtime.

In plain words
What is it for?
Use it to design Prisma schemas and relationships, optimize queries, prevent N+1 query problems, manage connections, model multiple tenants, and plan safe migrations.
Why use it?
It helps teams model related data clearly, avoid inefficient repeated queries, and change database structure while keeping applications available.

Skill for Claude CodeCodex

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

Good fit Use it to design Prisma schemas and relationships, optimize queries, prevent N+1 query problems, manage connections, model multiple tenants, and plan safe migrations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations
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 hamzabellouch/agent-skills --skill prisma-orm-patterns-and-migrations
Clone the repo
git clone --depth 1 https://github.com/hamzabellouch/agent-skills

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 prisma-orm-patterns-and-migrations

README.md
[![agentmods](https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations/github.svg)](https://agentmods.dev/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations)
Your own site
<a href="https://agentmods.dev/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations"><img src="https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations/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 prisma-orm-patterns-and-migrations

Your own site · 80×15
<a href="https://agentmods.dev/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations"><img src="https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/prisma-orm-patterns-and-migrations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,434 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.00058 $0.01434
Opus 5 $0.00029 $0.00717
Sonnet 5 $0.00012 $0.00287
Haiku 4.5 $0.00006 $0.00143

Measured 5d ago against content hash 52bcdf844e39, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

prisma-orm-patterns-and-migrations 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 5d 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.

Databases and Caching/prisma-orm-patterns-and-migrations/SKILL.md · 181 lines

How it starts

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

Prisma ORM Patterns & Migrations Architecture Guide

Production reference for building scalable Node.js and TypeScript applications using Prisma ORM, optimizing database access, executing zero-downtime migrations, and managing connections.


1. Schema Modeling & Relationship Patterns

1.1 Explicit Many-to-Many vs. Implicit Many-to-Many

  • Implicit: Prisma manages join table automatically. Use when join table needs no additional metadata.
  • Explicit: User defines join table model. Use when storing timestamps or custom payload on relation records (e.g., role, assignedAt).
// Explicit Many-to-Many with Relation Attributes
model User {
  id        String         @id @default(uuid())
  email     String         @unique
  memberships UserOrganization[]
}

model Organization {
  id        String         @id @default(uuid())
  name      String
  members   UserOrganization[]
}

model UserOrganization {
  userId         String
  organizationId String
  role           String       @default("MEMBER")
  assignedAt     DateTime     @default(now())

  user         User         @relation(fields: [userId], references: [id], onDelete: Cascade)
  organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)

  @@id([userId, organizationId])
  @@index([organizationId])
}

1.2 Referential Actions & Performance Indexing

  • Always explicitly define foreign key indexes using @@index([foreignKeyField]) to optimize join performance and cascading updates/deletes.
  • Set appropriate onDelete actions (Cascade, SetNull, Restrict, NoAction).

2. Query Optimization & Preventing N+1 Problems

2.1 Fine-Grained Projection (select vs include)

Avoid blind include queries that fetch all fields from related tables. Use explicit select payloads to reduce payload over-fetching.

// ❌ ANTI-PATTERN: Over-fetching full nested objects
const posts = await prisma.post.findMany({
  include: { author: true, comments: true }
});

// ✅ PRODUCTION PATTERN: Explicit field selection
const posts = await prisma.post.findMany({
  select: {
    id: true,
    title: true,
    author: {
      select: {
        id: true,
        name: true
      }
    },
    _count: {
      select: { comments: true }
    }
  }
});

Read the full file on GitHub · 181 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. 5d ago First seen · 181 lines · 58 tokens per session scan A 52bcdf844e39

Subscribe to this mod's changes

prisma-orm-patterns-and-migrations is a skill published in the GitHub repository hamzabellouch/agent-skills (4 stars, last pushed 1mo ago), licensed MIT. It adds 58 tokens to every session and 1,434 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-03.

Related

Other skills, from other repositories

drizzle

Drizzle TypeScript ORM with SQL-like syntax. Use for database access.

G1Joshi/Agent-Skills · 18 tokens

prisma

Prisma TypeScript ORM with migrations. Use for database access.

G1Joshi/Agent-Skills · 16 tokens

neo4j-driver-javascript-skill

Neo4j JavaScript/TypeScript Driver v6 — driver lifecycle, executeQuery, managed transactions (executeRead/executeWrite), session.run, Integer handling, JSON serialization, record access, async/await patterns, TypeScript types, error handling, and connection setup for Node.js and browser. Use when writing JS/TS code…

neo4j-contrib/neo4j-skills · 157 tokens

database-orm-expert

Expert guide for database schema design, ORM tools (Prisma 6, Drizzle ORM, TypeORM), migrations, query optimization, and type-safe SQL patterns in TypeScript / Panduan ahli untuk desain skema database, ORM tools (Prisma 6, Drizzle ORM, TypeORM), migrasi, optimasi query, dan pola SQL type-safe di TypeScript.

roedyrustam/vibes-plug · 82 tokens

typescript-react-nextjs-patterns

Production-grade TypeScript reference for React & Next.js frontend development. Covers type narrowing, component Props, generic hooks, discriminated unions, as const, satisfies, Zod validation, TanStack Query, server/client boundaries, forms, state management, performance, accessibility, debugging, and code review.…

leejpsd/typescript-react-nextjs-patterns · 142 tokens

prisma

TypeScript and Prisma ORM best practices for schema design, type-safe queries, migrations, and error handling. Use when writing Prisma schemas, building database access layers, or debugging query performance in TypeScript projects.

nateslabach/skills · 44 tokens