plugins/aai-stack-prisma/skills/prisma-relations/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-relations/SKILL.md -a claude-code --skill prisma-relationsInstallation paths:
.claude/skills/prisma-relations/# Prisma Relations Skill
Patterns for modeling relationships in Prisma.
## One-to-One Relations
### Basic One-to-One
```prisma
model User {
id String @id @default(uuid())
email String @unique
profile Profile?
}
model Profile {
id String @id @default(uuid())
bio String?
avatar String?
userId String @unique
user User @relation(fields: [userId], references: [id])
}
```
### Queries
```typescript
// Create with relation
const user = await prisma.user.create({
data: {
email: 'john@example.com',
profile: {
create: { bio: 'Hello world' },
},
},
include: { profile: true },
})
// Update nested
await prisma.user.update({
where: { id: userId },
data: {
profile: {
upsert: {
create: { bio: 'New bio' },
update: { bio: 'Updated bio' },
},
},
},
})
// Delete relation
await prisma.user.update({
where: { id: userId },
data: {
profile: { delete: true },
},
})
```
## One-to-Many Relations
### Basic One-to-Many
```prisma
model User {
id String @id @default(uuid())
posts Post[]
}
model Post {
id String @id @default(uuid())
title String
authorId String
author User @relation(fields: [authorId], references: [id])
@@index([authorId])
}
```
### Queries
```typescript
// Create with multiple related
const user = await prisma.user.create({
data: {
email: 'author@example.com',
posts: {
create: [
{ title: 'Post 1' },
{ title: 'Post 2' },
],
},
},
include: { posts: true },
})
// Add to existing relation
await prisma.post.create({
data: {
title: 'New Post',
author: {
connect: { id: userId },
},
},
})
// Update relation
await prisma.user.update({
where: { id: userId },
data: {
posts: {
create: { title: 'Another Post' },
updateMany: {
where: { published: false },
data: { published: true },
},
},
},
})
// Filter by relation
const