Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

prisma-relations

verified

Prisma relation modeling patterns

View on GitHub

Marketplace

alphaagent-team

the-answerai/alphaagent-team

Plugin

aai-stack-prisma

stack

Repository

the-answerai/alphaagent-team

plugins/aai-stack-prisma/skills/prisma-relations/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
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-relations

Installation paths:

Claude
.claude/skills/prisma-relations/
Powered by add-skill CLI

Instructions

# 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

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5823 chars