agentsclimarketplace

Prisma patterns

Skill felixhennequin-gif/claude-code-config-template/.claude/skills/stacks/prisma-patterns

Production-ready AI config template for Claude Code. CLAUDE.md, agents, skills, hooks, routines, and commands — based on analysis of 55+ open-source repos (Supabase, Bitwarden, Vercel, Cloudflare, OpenAI).

Install
npx -y skills add felixhennequin-gif/claude-code-config-template --skill prisma-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Prisma ORM conventions and patterns. Activates when working on the Prisma schema, migrations, queries, or services that call Prisma.

SKILL.md

3.6 KB, 889 tokens by cl100k_base, as published. Nobody here has run it

Prisma — Project conventions

Applies to Prisma 6.x and 7.x. Preview-only features are flagged inline.

Schema

  • One model per domain entity. No technical tables surfaced in the schema (except sessions / tokens).
  • Explicit relations via @relation. Always name the relation when there's ambiguity.
  • @updatedAt on every model whose content can change.
  • String IDs: prefer @default(uuid(7)) (Prisma 5.18+) for new projects — UUIDv7 is time-ordered, which keeps B-tree indexes happy. @default(cuid()) still works but cuid is in maintenance mode per the Prisma team — avoid it in new schemas. Do not use @default(ulid()) — ULID is not a native Prisma generator; use uuid(7) or wire a manual @default via dbgenerated if you truly need ULID.
  • Int IDs: @default(autoincrement()).
  • Enums for fixed values (roles, statuses, visibility).

Queries

  • Always use an explicit select or include. Never findMany() without a filter on a large table.
  • omit for sensitive fields (GA in Prisma 6.2+) — exclude fields like password or secret at the query level instead of manual select:
    const user = await prisma.user.findUnique({
      where: { id },
      omit: { password: true },
    });
    
    Prefer this over select-ing every field individually when you only want to hide one or two.
  • Avoid N+1: use include with the needed relations rather than loops calling findUnique.
  • Cursor-based pagination for long lists (feed, search results). Pattern:
    const items = await prisma.model.findMany({
      take: limit + 1,
      cursor: cursor ? { id: cursor } : undefined,
      skip: cursor ? 1 : 0,
      orderBy: { createdAt: 'desc' },
    });
    const hasMore = items.length > limit;
    if (hasMore) items.pop();
    
  • typedSql ⚠️ Preview feature since Prisma 5.19 — still preview as of last verified 2026-04-15. Re-check Prisma's preview-features list before adopting, because preview flags can break, rename, or get removed between minor releases. When you're comfortable pinning a Prisma version and revisiting on upgrades, enable with previewFeatures = ["typedSql"] in the generator block, put .sql files under prisma/sql/, and call them via prisma.$queryRawTyped() — this gives type-safe raw SQL without string interpolation. On a production codebase that can't absorb preview churn, stay on $queryRaw with careful review instead.
  • Transactions for multi-model operations that must be atomic.

Migrations

  • npx prisma migrate dev --name short-description in dev.
  • Never db push in production. Always migrate deploy.
  • Review the generated migration before committing — Prisma may emit unexpected DROPs.

Seed

  • prisma/seed.js or prisma/seed.ts. Idempotent: prefer upsert over create.
  • Realistic seed data — no test123.

Anti-patterns

  • prisma.$queryRaw with unchecked template literals — if the typedSql preview flag is acceptable for your project, prefer $queryRawTyped + .sql files. If you can't depend on preview flags, stay on $queryRaw but sanitize inputs yourself and review each call carefully. Either way, only use raw SQL when the query builder can't express the query.
  • deleteMany() without a where — always spell out the filter
  • ❌ Deeply nested writes (> 2 levels) — split into sequential transactions
  • ❌ Missing @@index on fields that are frequently filtered

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Gives 0 of the 12 instructions most databases sql skills give in 889 tokens

Counted across 589 of the 662 authors here whose files we hold, read 2026-08-07

  • Use parameterized queriesin 37 of 589, across 34 files
  • Use timestamptz for timestampsin 30 of 589, across 14 files
  • Index foreign keysin 29 of 589, across 18 files
  • Create indexes concurrentlyin 29 of 589, across 24 files
  • Use numeric type for moneyin 25 of 589, across 8 files
  • Use cursor pagination instead of offsetin 24 of 589, across 17 files
  • Select only required columnsin 24 of 589, across 20 files
  • Add indexes manually on foreign key columnsin 22 of 589, across 12 files
  • Normalize to third normal formin 19 of 589, across 10 files
  • Configure connection poolingin 19 of 589, across 17 files
  • Put equality columns before range columns in indexesin 18 of 589, across 10 files
  • Read individual rule files for detailed explanationsin 18 of 589, across 4 files

Said here and by no other author read

  • use one model per domain entity
  • add @updatedAt to mutable models
  • default new string IDs to uuid(7)
  • use enums for fixed values
  • use explicit select or include in queries
  • omit sensitive fields at query level

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.