plugins/aai-stack-prisma/skills/prisma-queries/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-stack-prisma/skills/prisma-queries/SKILL.md -a claude-code --skill prisma-queriesInstallation paths:
.claude/skills/prisma-queries/# Prisma Queries Skill
Patterns for querying data with Prisma Client.
## Basic CRUD
### Create
```typescript
// Create single record
const user = await prisma.user.create({
data: {
email: 'john@example.com',
name: 'John Doe',
},
})
// Create with relations
const user = await prisma.user.create({
data: {
email: 'john@example.com',
profile: {
create: { bio: 'Hello!' },
},
posts: {
create: [
{ title: 'First Post' },
{ title: 'Second Post' },
],
},
},
include: {
profile: true,
posts: true,
},
})
// Create many
const users = await prisma.user.createMany({
data: [
{ email: 'user1@example.com' },
{ email: 'user2@example.com' },
],
skipDuplicates: true,
})
```
### Read
```typescript
// Find by ID
const user = await prisma.user.findUnique({
where: { id: userId },
})
// Find by unique field
const user = await prisma.user.findUnique({
where: { email: 'john@example.com' },
})
// Find first matching
const user = await prisma.user.findFirst({
where: { role: 'ADMIN' },
})
// Find many with conditions
const users = await prisma.user.findMany({
where: {
role: 'USER',
createdAt: { gte: new Date('2024-01-01') },
},
orderBy: { createdAt: 'desc' },
take: 10,
skip: 0,
})
// Find or throw
const user = await prisma.user.findUniqueOrThrow({
where: { id: userId },
})
```
### Update
```typescript
// Update by ID
const user = await prisma.user.update({
where: { id: userId },
data: { name: 'New Name' },
})
// Update many
const result = await prisma.user.updateMany({
where: { role: 'GUEST' },
data: { role: 'USER' },
})
// Upsert (create or update)
const user = await prisma.user.upsert({
where: { email: 'john@example.com' },
update: { name: 'John' },
create: { email: 'john@example.com', name: 'John' },
})
```
### Delete
```typescript
// Delete by ID
const user = await prisma.user.delete({
where: { id: userId },
})
// Delete many
const result