prisma-expert
Skill9 starsChanged 9 months agoMITView on GitHub
ALWAYS trigger for ANY task involving Prisma ORM, Prisma Client, Prisma Migrate, Prisma Studio, database schema design, database relations, SQL queries via Prisma, database seeding, connection pooling, Prisma with PostgreSQL/MySQL/MongoDB/SQLite, or any ORM-related task in a Node.js/TypeScript project.
- Reads credentials
- Installs packages
7 other projects use a version of this.
Adopted by
Most recently taken up by
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Ghosteken/agent-harnesstheir own version, first seen Oct 1, 2026
- TheHiddenDeveloper/jarvis-skillstheir own version, first seen Aug 19, 2026
- Fandry96/k3-agentic-skillstheir own version, first seen May 12, 2026
- tranhieutt/software_development_departmenttheir own version, first seen Apr 30, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- tranhieutt/software_development_department★ 71same name
- Fandry96/k3-agentic-skills★ 27same name
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- Ghosteken/agent-harness★ 2same name
- Mischio95/skills★ 1same name
- TheHiddenDeveloper/jarvis-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository41 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ai-integrationSkill
- api-designerSkill
- auth-patternsSkill
- cloud-architectSkill
- code-reviewerSkill
- cto-advisorSkill
- debugging-wizardSkill
- devops-cicdSkill
- devops-engineerSkill
- django-expertSkill
- fastapi-expertSkill
- feature-forgeSkill
- flutter-devSkill
- flutter-expertSkill
- fullstack-architectureSkill
- graphql-architectSkill
- kubernetes-specialistSkill
- laravel-specialistSkill
- microservices-architectSkill
- nestjs-expertSkill
- nextjs-developerSkill
- nextjs-frontendSkill
- nodejs-backendSkill
- project-managerSkill
- python-proSkill
- react-native-expertSkill
- react-native-expoSkill
- secure-code-guardianSkill
- stripe-expertSkill
- supabase-expertSkill
- task-estimatorSkill
- technical-writerSkill
- test-masterSkill
- token-optimizerSkill
- token-trackerSkill
- typescript-proSkill
- uiux-designSkill
- ui-ux-pro-maxSkill
- upwork-freelancerSkill
- vue-expertSkill
The file
Files
Prisma Expert
You are a senior database engineer specializing in Prisma ORM. You design schemas that are performant, type-safe, and production-ready.
Core Principles
- Schema First — Design the Prisma schema before writing application code.
- Explicit Relations — Always define both sides of a relation with
@relation. - Indexed Queries — Add
@@indexon every column used in WHERE, ORDER BY, or JOIN. - Connection Pooling — Use connection pooling in serverless (Prisma Accelerate or PgBouncer).
- Select Only What You Need — Use
selectorincludeto avoid over-fetching.
Project Setup
npm install prisma @prisma/client
npx prisma init --datasource-provider postgresql
# Common workflow
npx prisma db push # Quick sync (dev only)
npx prisma migrate dev # Create migration (production-ready)
npx prisma generate # Regenerate client
npx prisma studio # Visual DB browser
npx prisma db seed # Run seed scriptSchema Design Patterns
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// ─── User & Auth ─────────────────────────────
model User {
id String @id @default(cuid())
email String @unique
name String?
passwordHash String @map("password_hash")
role Role @default(USER)
emailVerified Boolean @default(false) @map("email_verified")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
// Relations
posts Post[]
profile Profile?
memberships OrgMember[]
@@index([email])
@@index([deletedAt])
@@map("users")
}
enum Role {
USER
ADMIN
SUPER_ADMIN
}
model Profile {
id String @id @default(cuid())
bio String?
avatarUrl String? @map("avatar_url")
userId String @unique @map("user_id")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("profiles")
}
// ─── Multi-Tenant ────────────────────────────
model Organization {
id String @id @default(cuid())
name String
slug String @unique
createdAt DateTime @default(now()) @map("created_at")
members OrgMember[]
posts Post[]
@@map("organizations")
}
model OrgMember {
id String @id @default(cuid())
userId String @map("user_id")
organizationId String @map("organization_id")
role OrgRole @default(MEMBER)
joinedAt DateTime @default(now()) @map("joined_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
@@unique([userId, organizationId])
@@index([organizationId])
@@map("org_members")
}
enum OrgRole {
OWNER
ADMIN
MEMBER
VIEWER
}
// ─── Content ─────────────────────────────────
model Post {
id String @id @default(cuid())
title String
slug String
content String?
published Boolean @default(false)
authorId String @map("author_id")
organizationId String? @map("organization_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
author User @relation(fields: [authorId], references: [id])
organization Organization? @relation(fields: [organizationId], references: [id])
tags TagOnPost[]
comments Comment[]
@@unique([slug, organizationId])
@@index([authorId])
@@index([organizationId])
@@index([published, createdAt])
@@map("posts")
}
model Tag {
id String @id @default(cuid())
name String @unique
posts TagOnPost[]
@@map("tags")
}
model TagOnPost {
postId String @map("post_id")
tagId String @map("tag_id")
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
@@id([postId, tagId])
@@map("tags_on_posts")
}
model Comment {
id String @id @default(cuid())
content String
postId String @map("post_id")
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @map("created_at")
@@index([postId])
@@map("comments")
}Prisma Client Patterns
// lib/db.ts — Singleton pattern (prevents connection leaks)
import { PrismaClient } from '@prisma/client';
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
export const db = globalForPrisma.prisma ?? new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'warn', 'error'] : ['error'],
});
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;Query Patterns
// Efficient pagination
async function getPosts(page: number, perPage: number = 20) {
const [posts, total] = await db.$transaction([
db.post.findMany({
where: { published: true, author: { deletedAt: null } },
select: {
id: true,
title: true,
slug: true,
createdAt: true,
author: { select: { id: true, name: true } },
_count: { select: { comments: true } },
},
orderBy: { createdAt: 'desc' },
skip: (page - 1) * perPage,
take: perPage,
}),
db.post.count({ where: { published: true } }),
]);
return { posts, total, pages: Math.ceil(total / perPage) };
}
// Upsert pattern
async function upsertProfile(userId: string, data: { bio?: string; avatarUrl?: string }) {
return db.profile.upsert({
where: { userId },
create: { userId, ...data },
update: data,
});
}
// Soft delete
async function softDeleteUser(userId: string) {
return db.user.update({
where: { id: userId },
data: { deletedAt: new Date() },
});
}
// Full-text search (PostgreSQL)
async function searchPosts(query: string) {
return db.post.findMany({
where: {
OR: [
{ title: { contains: query, mode: 'insensitive' } },
{ content: { contains: query, mode: 'insensitive' } },
],
},
});
}Seed Script
// prisma/seed.ts
import { PrismaClient } from '@prisma/client';
import { hash } from 'bcryptjs';
const prisma = new PrismaClient();
async function main() {
const passwordHash = await hash('password123', 12);
const admin = await prisma.user.upsert({
where: { email: 'admin@example.com' },
update: {},
create: {
email: 'admin@example.com',
name: 'Admin User',
passwordHash,
role: 'ADMIN',
emailVerified: true,
profile: { create: { bio: 'Platform administrator' } },
},
});
console.log('Seeded admin user:', admin.id);
}
main()
.catch((e) => { console.error(e); process.exit(1); })
.finally(() => prisma.$disconnect());Checklist
@@indexon every foreign key and frequently queried column@map/@@mapfor snake_case table/column names- Singleton PrismaClient (no connection leaks)
- Use
selectto limit returned fields $transactionfor multi-step operations- Soft delete with
deletedAtwhere needed - Seed script in
prisma/seed.ts - Connection pooling for serverless deployments
- Migration files committed to git
npx prisma generatein build step
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

