con un clic
prisma
Prisma schema conventions and migration workflow
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Prisma schema conventions and migration workflow
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
How to reuse ANY integration check's results in a feature via the universal CheckResultsService (apps/api integration-platform). Use whenever a feature needs data produced by an integration check — "show 2FA status on People", "surface AWS S3 findings in X", "reuse a check's results", "per-user/per-resource results from a connected integration", "which integrations feed task T". Read this BEFORE writing your own IntegrationCheckResult / CheckRunRepository query — don't hand-roll it.
MANDATORY for any UI work in apps/app, apps/portal, or packages/design-system — every component, page, or layout change must work on mobile (~375px), tablet (~768px), desktop (~1280px), and large desktop (~1920px) BY DEFAULT, without being asked. Read this before writing or editing any JSX/TSX that renders visible UI. Triggers on: new component, page, layout, table, toolbar, form, modal/sheet, dashboard, "build UI", "add a column", "add a filter", any styling change.
Use when building or editing frontend UI components, layouts, styling, design system usage, colors, dark mode, or icons.
The contract every new or modified API endpoint must follow so it is correct for the public OpenAPI spec, the MCP server (npm @trycompai/mcp-server), the ValidationPipe, and the docs. Triggers on "new endpoint", "add API", "new DTO", "@Body", "@RequirePermission", "MCP tool", "edit controller in apps/api", "OpenAPI", or whenever editing controllers under apps/api/src/.
Use when SDK generation failed or seeing errors. Triggers on "generation failed", "speakeasy run failed", "SDK build error", "workflow failed", "Step Failed", "why did generation fail"
Use when generating an MCP server from an OpenAPI spec with Speakeasy. Triggers on "generate MCP server", "MCP server", "Model Context Protocol", "AI assistant tools", "Claude tools", "speakeasy MCP", "mcp-typescript"
| name | prisma |
| description | Prisma schema conventions and migration workflow |
Source Cursor rule: .cursor/rules/prisma.mdc.
Original file scope: **/*.prisma.
Original Cursor alwaysApply: false.
Schema changes happen in packages/db, then regenerate types in each app.
# Schema files are in packages/db/prisma/schema/
packages/db/prisma/schema/
├── schema.prisma # Main schema with datasource
├── user.prisma # User models
├── task.prisma # Task models
└── ...
# Run from packages/db
cd packages/db
bunx prisma migrate dev --name your_migration_name
# Each app needs to regenerate Prisma client types
bun run -F apps/app db:generate
bun run -F apps/api db:generate
bun run -F apps/portal db:generate
# Or from root (if configured)
bun run prisma:generate
# 1. Make schema changes in packages/db
# 2. Create migration
cd packages/db && bunx prisma migrate dev --name add_user_role
# 3. Regenerate types in ALL apps that use the db
bun run -F apps/app db:generate
bun run -F apps/api db:generate
bun run -F apps/portal db:generate
# Don't edit schema in app directories
apps/app/prisma/schema.prisma # ❌ Wrong location
# Don't forget to regenerate types
bunx prisma migrate dev # ✅ Created migration
# ... forgot to run db:generate in apps # ❌ Types out of sync
Always use prefixed CUIDs for IDs using generate_prefixed_cuid.
model User {
id String @id @default(dbgenerated("generate_prefixed_cuid('usr'::text)"))
// ... other fields
}
model Task {
id String @id @default(dbgenerated("generate_prefixed_cuid('tsk'::text)"))
// ... other fields
}
model Organization {
id String @id @default(dbgenerated("generate_prefixed_cuid('org'::text)"))
// ... other fields
}
// Don't use UUID
model User {
id String @id @default(uuid())
}
// Don't use auto-increment
model User {
id Int @id @default(autoincrement())
}
// Don't forget ::text cast
model User {
id String @id @default(dbgenerated("generate_prefixed_cuid('usr')")) // ❌ Missing ::text
}
| Entity | Prefix | Example ID |
|---|---|---|
| User | usr | usr_BJRIZLgRPuWt8MvMjkSY82f1 |
| Organization | org | org_cK9xMnPqRs2tUvWx3yZa4b5c |
| Task | tsk | tsk_dE6fGhIj7kLmNoP8qRsT9uVw |
| Control | ctl | ctl_xY0zAaBb1cDdEe2fFgGh3iIj |
| Policy | pol | pol_kK4lLmMn5oOpPq6rRsSt7uUv |
::text in the function calldbgenerated()usr_ vs org_)After schema changes:
packages/db/prisma/schema/bunx prisma migrate devapps/app with db:generateapps/api with db:generateapps/portal with db:generate