skills/djordjevuckovic/prisma-v7/SKILL.md
Expert guidance for Prisma ORM v7 (7.0+). Use when working with Prisma schema files, migrations, Prisma Client queries, database setup, or when the user mentions Prisma, schema.prisma, @prisma/client, database models, or ORM. Covers ESM modules, driver adapters, prisma.config.ts, Rust-free client, and migration from v6.
npx skillsauth add aiskillstore/marketplace prisma-v7Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive guidance for working with Prisma ORM version 7.x and later.
Prisma v7 ships as an ES module. Your project must use ESM:
package.json:
{
"type": "module"
}
tsconfig.json:
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2023",
"strict": true,
"esModuleInterop": true
}
}
All databases now require driver adapters. The Rust-free client provides better performance and smaller bundle sizes.
Available Adapters:
@prisma/adapter-pg (with pg driver)@prisma/adapter-mariadb (with mariadb driver)@prisma/adapter-better-sqlite3 (with better-sqlite3)@prisma/adapter-pg (with pg driver)@prisma/adapter-neon (with @neondatabase/serverless)@prisma/adapter-planetscale (with @planetscale/database)@prisma/adapter-d1@prisma/adapter-mssqlThe output field is now required and the new prisma-client provider is standard:
generator client {
provider = "prisma-client"
output = "./generated/prisma"
}
Note: Client is no longer generated in node_modules by default.
Database URLs and CLI configuration now live in prisma.config.ts instead of the schema file.
Basic setup:
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: env('DATABASE_URL'),
},
})
Note: For Bun, skip import 'dotenv/config' as it auto-loads .env files.
Remove url, directUrl, and shadowDatabaseUrl from schema.prisma:
v7 schema.prisma:
datasource db {
provider = "postgresql"
// url field removed - now in prisma.config.ts
}
generator client {
provider = "prisma-client"
output = "./generated/prisma"
}
# Install dependencies
npm install prisma@latest @prisma/client@latest
# Choose appropriate adapter
npm install @prisma/adapter-pg pg # PostgreSQL
npm install @prisma/adapter-mariadb mariadb # MySQL/MariaDB
npm install @prisma/adapter-better-sqlite3 better-sqlite3 # SQLite
# Install dev tools
npm install -D tsx dotenv
# Initialize Prisma (creates prisma.config.ts automatically)
npx prisma init
# Update packages
npm install prisma@latest @prisma/client@latest
# Install adapter for your database
npm install @prisma/adapter-pg pg # for PostgreSQL
# Install dotenv if not using Bun
npm install dotenv
# Regenerate client
npx prisma generate
import { PrismaClient } from './generated/prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import 'dotenv/config'
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL
})
const prisma = new PrismaClient({ adapter })
export default prisma
import { PrismaClient } from './generated/prisma/client'
import { PrismaMariaDb } from '@prisma/adapter-mariadb'
import 'dotenv/config'
const adapter = new PrismaMariaDb({
host: 'localhost',
port: 3306,
connectionLimit: 5
})
const prisma = new PrismaClient({ adapter })
export default prisma
import { PrismaClient } from './generated/prisma/client'
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3'
import 'dotenv/config'
const adapter = new PrismaBetterSqlite3({
url: process.env.DATABASE_URL || 'file:./dev.db'
})
const prisma = new PrismaClient({ adapter })
export default prisma
If using Prisma Accelerate for caching, do NOT use a driver adapter:
import { PrismaClient } from './generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'
const prisma = new PrismaClient({
accelerateUrl: process.env.DATABASE_URL // prisma:// or prisma+postgres:// URL
}).$extends(withAccelerate())
export default prisma
Important: Never pass prisma:// or prisma+postgres:// URLs to driver adapters.
// schema.prisma
datasource db {
provider = "postgresql"
}
generator client {
provider = "prisma-client"
output = "./generated/prisma"
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([authorId])
}
One-to-Many:
model User {
id Int @id @default(autoincrement())
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
author User @relation(fields: [authorId], references: [id])
authorId Int
@@index([authorId])
}
Many-to-Many:
model Post {
id Int @id @default(autoincrement())
categories Category[]
}
model Category {
id Int @id @default(autoincrement())
posts Post[]
}
One-to-One:
model User {
id Int @id @default(autoincrement())
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
# Generate Prisma Client
npx prisma generate
# Create and apply migration
npx prisma migrate dev --name init
# Apply migrations in production
npx prisma migrate deploy
# Reset database (dev only)
npx prisma migrate reset
# Open Prisma Studio
npx prisma studio
# Format schema
npx prisma format
# Validate schema
npx prisma validate
# Pull schema from database
npx prisma db pull
# Push schema to database (prototyping)
npx prisma db push
# Seed database
npx prisma db seed
// Create
const user = await prisma.user.create({
data: {
email: '[email protected]',
name: 'John Doe',
},
})
// Read
const user = await prisma.user.findUnique({
where: { id: 1 },
})
const users = await prisma.user.findMany({
where: { email: { contains: '@example.com' } },
orderBy: { createdAt: 'desc' },
take: 10,
})
// Update
const user = await prisma.user.update({
where: { id: 1 },
data: { name: 'Jane Doe' },
})
// Delete
const user = await prisma.user.delete({
where: { id: 1 },
})
// Create with relations
const user = await prisma.user.create({
data: {
email: '[email protected]',
posts: {
create: [
{ title: 'First Post', content: 'Content...' },
{ title: 'Second Post', content: 'More content...' },
],
},
},
})
// Query with relations
const userWithPosts = await prisma.user.findUnique({
where: { id: 1 },
include: {
posts: true,
},
})
// Select specific fields
const user = await prisma.user.findUnique({
where: { id: 1 },
select: {
id: true,
email: true,
posts: {
select: {
id: true,
title: true,
},
},
},
})
// Filtering
const posts = await prisma.post.findMany({
where: {
OR: [
{ title: { contains: 'Prisma' } },
{ content: { contains: 'database' } },
],
published: true,
author: {
email: { endsWith: '@prisma.io' },
},
},
})
// Aggregations
const result = await prisma.post.aggregate({
_count: true,
_avg: { authorId: true },
_sum: { authorId: true },
})
// Group by
const groups = await prisma.post.groupBy({
by: ['authorId'],
_count: true,
having: {
authorId: { gt: 10 },
},
})
// Transactions
const [user, post] = await prisma.$transaction([
prisma.user.create({ data: { email: '[email protected]' } }),
prisma.post.create({ data: { title: 'Post', authorId: 1 } }),
])
// Interactive transactions
await prisma.$transaction(async (tx) => {
const user = await tx.user.create({
data: { email: '[email protected]' },
})
await tx.post.create({
data: { title: 'Post', authorId: user.id },
})
})
# Create migration and apply
npx prisma migrate dev --name add_user_table
# Apply pending migrations
npx prisma migrate dev
# Reset database
npx prisma migrate reset
# Apply migrations
npx prisma migrate deploy
# Check migration status
npx prisma migrate status
# Push schema changes without creating migrations
npx prisma db push
.env:
# PostgreSQL
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
# MySQL
DATABASE_URL="mysql://user:password@localhost:3306/mydb"
# SQLite
DATABASE_URL="file:./dev.db"
# Prisma Accelerate
DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=..."
# Direct URL (for migrations with Accelerate)
DIRECT_DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
In v7, connection pooling is handled by the driver adapter, not by Prisma's URL parameters.
PostgreSQL with pg driver:
import { Pool } from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from './generated/prisma/client'
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
max: 10, // connection pool size
})
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
package.json:
{
"prisma": {
"seed": "tsx prisma/seed.ts"
}
}
prisma/seed.ts:
import { PrismaClient } from '../generated/prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import 'dotenv/config'
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL
})
const prisma = new PrismaClient({ adapter })
async function main() {
const user = await prisma.user.create({
data: {
email: '[email protected]',
name: 'Admin User',
},
})
console.log('Seeded:', user)
}
main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})
Run with: npx prisma db seed
Problem: Cannot find module './generated/prisma/client'
Solution:
"type": "module" in package.jsonnpx prisma generateProblem: Cannot connect to database
Solution:
import 'dotenv/config' is at the top of filesProblem: Migration cannot be applied
Solution:
npx prisma validateprisma/migrations/npx prisma migrate reset in developmentnpx prisma migrate resolve@@index([email])
@@index([authorId, createdAt])
await prisma.user.createMany({
data: [{ email: '[email protected]' }, { email: '[email protected]' }]
})
await prisma.$queryRaw`SELECT * FROM users WHERE email LIKE ${'%@example.com'}`
| Aspect | v6 | v7 |
|--------|----|----|
| Module System | CommonJS or ESM | ESM only |
| Client Generator | prisma-client-js | prisma-client |
| Output Location | node_modules default | Custom path required |
| Database Connection | Built-in drivers | Driver adapters required |
| Config Location | schema.prisma | prisma.config.ts |
| Environment Variables | Auto-loaded | Must use dotenv or Bun |
| Rust Dependencies | Yes | No (Rust-free) |
// lib/prisma.ts
import { PrismaClient } from './generated/prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import 'dotenv/config'
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined
}
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL
})
export const prisma = globalForPrisma.prisma ?? new PrismaClient({ adapter })
if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = prisma
}
enum Role {
USER
ADMIN
MODERATOR
}
model User {
id Int @id @default(autoincrement())
role Role @default(USER)
}
Usage:
import { Role } from './generated/prisma/client'
const admin = await prisma.user.create({
data: {
email: '[email protected]',
role: Role.ADMIN,
},
})
Good fit:
Consider alternatives if:
npx prisma generate after schema changesnpx prisma studio to visualize your databasenpx prisma format to keep schema cleandevelopment
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.