From harness-claude
Designs Prisma schemas with datasource, generator blocks, models, enums, field types, attributes, IDs, indexes, and native types for PostgreSQL, MySQL, SQLite. Useful for new projects or extending existing schemas.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Design Prisma schemas with datasource, generator, models, field types, and field attributes
Assists with Prisma schema helper operations: generates configurations, code, and best practices for backend database tasks in Node.js, Python, or Go. Auto-activates on 'prisma schema helper' mentions.
Generates database schemas from natural language descriptions in SQL (PostgreSQL/MySQL), Prisma, Drizzle, TypeORM, or Mongoose formats. Includes relationships, indexes, timestamps, soft deletes.
Provides expert guidance on Prisma ORM for TypeScript apps: schema design, migrations, Prisma Client queries, relations, edge deployment, and performance optimization.
Share bugs, ideas, or general feedback.
Design Prisma schemas with datasource, generator, models, field types, and field attributes
datasource block specifying the provider and connection string via env():datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator block for Prisma Client. Place it immediately after the datasource:generator client {
provider = "prisma-client-js"
}
@id field or a @@id composite key:model User {
id String @id @default(cuid())
email String @unique
name String?
role Role @default(USER)
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Use the correct scalar types: String, Int, BigInt, Float, Decimal, Boolean, DateTime, Json, Bytes. Append ? for optional fields.
Apply field-level attributes in this order: @id, @unique, @default(...), @map("column_name"), @db.VarChar(255).
Use @@map("table_name") to decouple Prisma model names from database table names when working with legacy databases.
Use @@unique([fieldA, fieldB]) for composite unique constraints and @@index([fieldA, fieldB]) for composite indexes.
Define enums at the schema level and reference them as field types:
enum Role {
USER
ADMIN
MODERATOR
}
Use @default(autoincrement()) for integer IDs, @default(cuid()) or @default(uuid()) for string IDs. Prefer cuid() unless your system requires UUID format.
Add @updatedAt to a DateTime field to auto-set the timestamp on every update. Only one @updatedAt per model.
Prisma schema is the single source of truth for your database structure and the generated TypeScript client. The schema file (prisma/schema.prisma) is declarative and uses its own DSL.
Datasource providers: postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb. Each provider supports a different subset of native types (e.g., @db.VarChar(255) for PostgreSQL, @db.Text for MySQL).
Native type annotations let you override the default database column type. Without them, Prisma maps scalar types to sensible defaults (e.g., String maps to text on PostgreSQL). Use @db.VarChar(n) when you need a length constraint at the database level.
Multi-file schemas are supported via the prismaSchemaFolder preview feature. Split large schemas into multiple .prisma files within the prisma/schema/ directory.
Trade-offs:
cuid() IDs are shorter and URL-safe but not a standard format; uuid() is universally recognized but longerJson fields bypass Prisma's type system — validate JSON content at the application layer or use Zod@default(now()) is evaluated at the database level; @default(dbgenerated("gen_random_uuid()")) delegates to database functionsDecimal preserves precision for financial data; Float introduces IEEE 754 roundingCommon mistakes:
@updatedAt means the field stays at its initial value foreverInt for IDs on tables that will exceed 2.1 billion rows — use BigInt instead@@index on foreign key fields — Prisma does not create indexes automatically for relation fieldshttps://prisma.io/docs/orm/prisma-schema