/major-ai-skills:prismafrom major-ai-skills
Operate Prisma schema, migrate dev/deploy, typed Client queries, transactions, and pooled vs direct DB URLs—avoiding serverless connection exhaustion and N+1 relation loads.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Prisma maps a declarative schema.prisma to a generated TypeScript Client. Migrate evolves the database (SQL history in prisma/migrations); the Client provides type-safe queries. Agents treat the schema as source of truth, never hand-edit prod schema, use $transaction for multi-step writes, select/include intentionally to control cost, and split pooled runtime URLs from direct URLs for migrate/admin.
┌─────────────────────────────────────────────────────────────┐
│ Prisma schema → DB → Client │
│ │
│ schema.prisma │
│ ├── migrate dev (local) → migrations/ SQL │
│ ├── migrate deploy (CI/prod, direct URL) │
│ └── prisma generate → @prisma/client │
│ │
│ Runtime │
│ ├── singleton PrismaClient (module scope) │
│ ├── DATABASE_URL pooled (PgBouncer / Accelerate) │
│ └── queries: select/include · $transaction · batch │
└─────────────────────────────────────────────────────────────┘
Use when
Do not use when
@postgresql / @supabase-rls (Prisma can sit above).DATABASE_URL, run migrate reset on prod, or db push as the only prod workflow → refuse destructive shortcuts.prisma migrate dev --name …; CI/prod prisma migrate deploy only—do not drift with manual SQL in prod.DIRECT_URL (or CLI datasource) for migrate/studio/pull; use pooled DATABASE_URL for app traffic (PgBouncer transaction mode / provider pooler).PrismaClient per process (module singleton); in serverless, instantiate outside the handler so warm invokes reuse—pair with pooler; start from low connection_limit when needed.$transaction (interactive or batched).select / targeted include; never include entire graphs inside loops—batch with in or loaders (@graphql-apis DataLoader)..env with real credentials; use placeholders and secret stores.generate + tests against a disposable DB; in CI consider migrate diff to detect drift.generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
model User {
id String @id @default(cuid())
email String @unique
items Item[]
}
model Item {
id String @id @default(cuid())
sku String @unique
qty Int @default(0)
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id])
@@index([ownerId, createdAt])
}
.env (local placeholders — never real prod secrets):
# App / Prisma Client (pooled)
DATABASE_URL="postgresql://app@localhost:6432/app?pgbouncer=true"
# Migrate / introspect / studio (direct)
DIRECT_URL="postgresql://app@localhost:5432/app"
import { PrismaClient } from "@prisma/client";
const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === "development" ? ["error", "warn"] : ["error"],
});
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
export async function createItem(ownerId: string, sku: string, qty: number) {
return prisma.$transaction(async (tx) => {
const owner = await tx.user.findUniqueOrThrow({ where: { id: ownerId } });
return tx.item.create({
data: { ownerId: owner.id, sku, qty },
select: { id: true, sku: true, qty: true },
});
});
}
export async function listOwnerItems(ownerId: string) {
return prisma.item.findMany({
where: { ownerId },
orderBy: { createdAt: "desc" },
take: 50,
select: { id: true, sku: true, qty: true, createdAt: true },
});
}
Commands:
npx prisma init
npx prisma migrate dev --name add_items
npx prisma generate
npx prisma migrate deploy # CI/prod, direct URL
npx prisma migrate diff --from-migrations prisma/migrations --to-schema-datamodel prisma/schema.prisma --exit-code
npx prisma studio # local only
Host with @nodejs / @express / @nextjs; database with @postgresql; containers with @docker (run migrate as a release job, not from every serverless invoke).
| Signature | Likely cause | Fix path |
|---|---|---|
prepared statement "s0" already exists on migrate | Migrate through PgBouncer/pooler | Use directUrl / DIRECT_URL for CLI migrate |
Too many connections | New client per request; direct URL under load; unbounded serverless concurrency | Singleton + pooled URL; cap concurrency; tune pool |
| Partial writes / inconsistent rows | Multi-step without $transaction | Interactive or batched transaction |
| Latency spike listing relations | N+1 include in loops | Batch where: { id: { in } }; select fields; DataLoader |
| P2022 / column missing | Deployed code ahead of migrations | Run migrate deploy before/with release |
| P2002 unique violation | App race or missing upsert | Upsert or handle conflict; align unique in schema |
| Serverless cold pool thrash | Client inside handler | Hoist client; connection_limit; Accelerate/pooler |
| Drift local vs prod | db push in one env, migrate in another | One migrate workflow everywhere for SQL DBs |
prisma/migrations/**; treat migrate history as production artifact.db push for shared/staging/prod SQL databases (db push is prototyping).migrate reset against shared DBs.@graphql-apis loaders to avoid per-field finds.@typescript / @nodejs — typed runtime hosting the Client@postgresql — engine-level Postgres, pooling, backups@express / @nextjs — common HTTP hosts@docker — DB/service Compose and release migrate jobs@graphql-apis — Prisma under GraphQL resolversMANDATORY: Schema changes ship as migrations. Use direct URL for migrate, pooled URL for runtime. Singleton Client; transactions for multi-write; intentional
select/include. Never commit realDATABASE_URLs or reset production databases.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job