Use Claude to Design and Write a Prisma Schema
Writing a Prisma schema from scratch means remembering relation syntax, deciding where to put @relation fields, and setting up indexes correctly. Let Claude draft the schema while you focus on your domain model.
Design a Prisma schema for a multi-tenant SaaS app with:
- Organisations (name, slug, plan enum: free/pro/enterprise)
- Users with organisation membership and a role enum
- Projects belonging to organisations
- Audit logs tracking who changed what and when
Claude will generate a complete schema.prisma with proper @relation annotations, @@index declarations, enum definitions, and createdAt/updatedAt timestamps. It adds @@unique constraints where they make sense (like slug on organisations) and suggests a Role enum for membership types.
model Organisation {
id String @id @default(cuid())
name String
slug String @unique
plan Plan @default(FREE)
members Member[]
projects Project[]
createdAt DateTime @default(now())
}
After reviewing the schema, follow up with "generate the initial migration" or "write Prisma seed data for local development" to keep moving.
Claude also handles trickier patterns like self-referential relations (parent/child categories) and polymorphic-style setups using separate join tables.
Describe your domain, and Claude will give you a Prisma schema that's production-ready on the first draft.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.