Instructions
Design or review Prisma data models for Next.js applications.
When to Use
- Use for Prisma schema design/review (relations, indexes, naming).
- Prefer
data-layer-handbookfirst if ORM is undecided. - Prefer
api-handbookfor HTTP shapes over the schema.
Mode A - generate schema
- Parse the user’s plain-English domain model (entities, relationships, enums).
- Produce
schema.prismawith:@@map/@maponly if user prefers snake_case tables- IDs (
cuid()oruuid()- match repo if exists) - indexes on foreign keys and frequent filters
- Include migration commands:
pnpm exec prisma migrate dev --name init(or match project scripts). - Requires user approval before writing files.
Mode B - audit existing schema
- Read
prisma/schema.prismaand related queries if present. - Report: missing indexes, ambiguous relations, cascade risks, N+1-prone includes, naming inconsistencies.
- Suggest fixes as diffs or bullet list - no writes unless approved.
Outcomes
- Mode A: copy-paste-ready schema + migration instructions.
- Mode B: prioritized audit with severity labels.
Output Rules
State mode. For Mode A, fence schema.prisma only after approval summary.
Scope and boundaries
- In scope: Prisma schema design and review for Node/Next backends. If the team is choosing ORM vs SQL, point to
data-layer-handbookandreferences/data-layer-choice.mdfirst, then return here for Prisma. - Out of scope: raw SQL production migrations without user review, multi-database sharding, destructive data migrations, Drizzle schema authoring (see
data-layer-handbook).
Safety
- Mode A writes schema files -
requires_user_approval: true. - Never embed production database URLs or passwords; use
env("DATABASE_URL")only. - Warn before
onDelete: Cascadeon high-cardinality relations.
Troubleshooting
- Migrate drift: suggest
prisma migrate statusbefore new migrations. - PlanetScale / serverless: note provider-specific limitations if user names them.
- Monorepo: confirm
schema.prismapath (packages/dbvs root).
Related skills
data-layer-handbook- ORM vs SQL choice firstnext-server-patterns- query placementapi-handbook- API shapes over the schema
GitHub: https://github.com/bh611627/skillcodex/tree/main/skills/database-schema-agent/SKILL.md
npm: https://www.npmjs.com/package/@skillcodex/skills