/vibe:prisma-expertfrom vibe
Provides deep expertise in Prisma ORM covering schema design, data modeling, migrations, client generation, query optimization, and production database operations.
Ships in vibe. 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.
None: SKILL.md is the whole skill.
You are an expert Prisma ORM specialist with deep knowledge of schema design, data modeling, migrations, client generation, performance optimization, and production database operations.
// schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
USER
ADMIN
MODERATOR
}
model User {
id String @id @default(cuid())
email String @unique
name String?
role Role @default(USER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([email])
@@map("users")
}
model Post {
id String @id @default(cuid())
title String
content String
published Boolean @default(false)
authorId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([authorId])
@@index([createdAt(sort: Desc)])
@@map("posts")
}
model Comment {
id String @id @default(cuid())
content String
postId String
authorId String
createdAt DateTime @default(now())
@@index([postId])
@@index([authorId])
@@map("comments")
}
relation PostComments {
model Post
}
relation CommentAuthor {
model Comment
}
Use appropriate field types:
model User {
// Primary keys
id String @id @default(cuid())
// String fields
username String @unique
email String @unique
bio String?
// Numeric fields
age Int?
score Float @default(0.0)
// Boolean
isActive Boolean @default(true)
// DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Enum
role Role @default(USER)
// JSON (PostgreSQL)
metadata Json?
// Bytes
avatar Bytes?
}
One-to-Many:
model User {
id String @id @default(cuid())
posts Post[]
}
model Post {
id String @id @default(cuid())
author User @relation(fields: [authorId], references: [id])
authorId String
@@index([authorId])
}
Many-to-Many:
model Post {
id String @id @default(cuid())
tags Tag[]
}
model Tag {
id String @id @default(cuid())
posts Post[]
}
model PostTags {
postId String
tagId String
@@id([postId, tagId])
@@relation([Post, Tag])
}
One-to-One:
model User {
id String @id @default(cuid())
profile Profile?
}
model Profile {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id])
@@unique([userId])
}
# Create migration based on schema changes
npx prisma migrate dev --name add_user_role
# Or create migration manually
npx prisma migrate dev --create-only --name custom_migration
// migrations/20240115000000_add_user_role/migration.ts
import { Migration } from "@prisma/client/runtime/library";
export const AddUserRole: Migration = {
name: "AddUserRole",
async up(client, Prisma) {
// Run SQL directly if needed
await client.$executeRaw`
ALTER TABLE users
ADD COLUMN role VARCHAR(20) DEFAULT 'USER';
`;
// Or use client API
await client.$executeRaw`
CREATE TYPE Role AS ENUM ('USER', 'ADMIN', 'MODERATOR');
`;
},
async down(client, Prisma) {
// Rollback migration
await client.$executeRaw`
ALTER TABLE users DROP COLUMN role;
`;
},
};
// ✅ Good - Migration adds column with default
ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'USER';
// ❌ Bad - Migration adds column without default
ALTER TABLE users ADD COLUMN role VARCHAR(20);
// ✅ Good - Backward compatible migration
async up(client, Prisma) {
await client.user.updateMany({
where: { role: null },
data: { role: 'USER' },
});
}
// ❌ Bad - Breaks existing data
async up(client, Prisma) {
await client.$executeRaw`
DELETE FROM users WHERE role IS NULL;
`;
}
# Development - reset database (dangerous!)
npx prisma migrate reset
# Development - reset and reseed
npx prisma migrate reset --force
# Production - NEVER use migrate reset
# Use proper migrations instead
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
// Find single record
const user = await prisma.user.findUnique({
where: { email: "[email protected]" },
});
// Find first record
const user = await prisma.user.findFirst({
where: { name: "Alice" },
});
// Find many records
const users = await prisma.user.findMany({
where: {
isActive: true,
},
orderBy: {
createdAt: "desc",
},
take: 10,
skip: 0,
});
// ✅ Good - Select only needed fields
const users = await prisma.user.findMany({
select: {
id: true,
email: true,
name: true,
},
});
// ❌ Bad - Selects all fields
const users = await prisma.user.findMany();
// ✅ Good - Include relations
const posts = await prisma.post.findMany({
include: {
author: {
select: {
id: true,
name: true,
email: true,
},
},
},
});
// ✅ Better - Nested include
const posts = await prisma.post.findMany({
include: {
author: {
select: {
id: true,
name: true,
},
},
comments: {
include: {
author: {
select: {
id: true,
name: true,
},
},
},
},
},
});
// Simple filter
const users = await prisma.user.findMany({
where: {
isActive: true,
},
});
// Multiple conditions (AND)
const users = await prisma.user.findMany({
where: {
isActive: true,
role: "ADMIN",
},
});
// OR conditions
const users = await prisma.user.findMany({
where: {
OR: [{ name: { contains: "Alice" } }, { email: { contains: "alice" } }],
},
});
// IN query
const users = await prisma.user.findMany({
where: {
id: { in: ["1", "2", "3"] },
},
});
const skip = (page - 1) * pageSize;
const users = await prisma.user.findMany({
skip,
take: pageSize,
orderBy: { createdAt: "desc" },
});
const total = await prisma.user.count();
const hasMore = skip + pageSize < total;
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
async function transferMoney(fromUserId: string, toUserId: string, amount: number) {
await prisma.$transaction(async (tx) => {
// Decrement balance
await tx.balance.update({
where: { userId: fromUserId },
data: { amount: { decrement: amount } },
});
// Increment balance
await tx.balance.update({
where: { userId: toUserId },
data: { amount: { increment: amount } },
});
});
}
async function createPostWithTags(title: string, content: string, tagIds: string[]) {
await prisma.$transaction(
async (tx) => {
const post = await tx.post.create({
data: { title, content },
});
for (const tagId of tagIds) {
await tx.postTags.create({
data: { postId: post.id, tagId },
});
}
},
{
maxWait: 5000, // Maximum wait time
timeout: 10000, // Timeout
},
);
}
// schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// Environment variables
DATABASE_URL="postgresql://user:pass@localhost:5432/db?connection_limit=10&pool_timeout=20"
model User {
id String @id
email String @unique
username String
createdAt DateTime
updatedAt DateTime @updatedAt
@@index([email])
@@index([username])
@@index([createdAt(sort: Desc)]) // Compound index
@@index([email, username]) // Multi-column index
}
// ✅ Good - Use findUnique with indexed fields
const user = await prisma.user.findUnique({
where: { email: "[email protected]" },
});
// ❌ Bad - Use findFirst when findUnique works
const user = await prisma.user.findFirst({
where: { email: "[email protected]" },
});
// ✅ Good - Select specific fields
const users = await prisma.user.findMany({
select: { id: true, email: true },
});
// ✅ Good - Use cursor-based pagination
const users = await prisma.user.findMany({
cursor: { id: lastUserId },
take: 10,
});
// ❌ Bad - Use offset-based pagination (slower)
const users = await prisma.user.findMany({
skip: 100,
take: 10,
});
migrate reset in productionimport { PrismaClient } from "@prisma/client";
import { mockDeep } from "jest-mock-extended";
jest.mock("@prisma/client", () => ({
PrismaClient: jest.fn().mockImplementation(() => ({
user: {
findUnique: mockDeep(),
findMany: mockDeep(),
create: mockDeep(),
},
post: {
findMany: mockDeep(),
create: mockDeep(),
},
})),
}));
describe("transferMoney", () => {
it("should transfer money atomically", async () => {
const prisma = new PrismaClient({
datasources: {
db: { url: "file:./test.db" },
},
});
await transferMoney(prisma, "user1", "user2", 100);
const user1 = await prisma.balance.findUnique({
where: { userId: "user1" },
});
const user2 = await prisma.balance.findUnique({
where: { userId: "user2" },
});
expect(user1.amount).toBe(900);
expect(user2.amount).toBe(1100);
});
});
# Migration failed, need to resolve
npx prisma migrate resolve
# Reset to last working migration
npx prisma migrate reset
# Re-run migrations
npx prisma migrate dev
// Connection timeout
const prisma = new PrismaClient({
log: ["query", "error", "warn"],
datasources: {
db: {
url: process.env.DATABASE_URL,
},
},
});
// Connection pool configuration
const prisma = new PrismaClient({
datasources: {
db: {
url: process.env.DATABASE_URL,
pool_timeout: 20,
connection_limit: 10,
},
},
});
# Generate Prisma Client
npx prisma generate
# Create migration
npx prisma migrate dev --name add_field
# Apply migrations
npx prisma migrate deploy
# Reset database (development only!)
npx prisma migrate reset
# Open Prisma Studio
npx prisma studio
# Validate schema
npx prisma validate
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job