Skip to content
cccskills
FreePublished on GitHub

prisma

Keep Prisma schema changes, database migrations, and generated client types in sync across applications. The guidance also sets conventions for readable, prefixed CUID IDs, including short unique prefixes and the required database function cast.

OriginalShow the original description

Prisma schema conventions and migration workflow

trycompai/comp2,058 stars(GitHub 2,058 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Updating a Prisma schema and creating its migration
  • Regenerating Prisma client types across apps
  • Choosing prefixed IDs for new data models

Files included (1)

  • SKILL.md3.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Source Cursor rule: .cursor/rules/prisma.mdc. Original file scope: **/*.prisma. Original Cursor alwaysApply: false.

Prisma Schema

Migration Workflow

Schema changes happen in packages/db, then regenerate types in each app.

Step 1: Edit Schema

# 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
└── ...

Step 2: Create Migration

# Run from packages/db
cd packages/db
bunx prisma migrate dev --name your_migration_name

Step 3: Regenerate Types in Apps

# 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

✅ Always Do This

# 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

❌ Never Do This

# 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

Core Rule

Always use prefixed CUIDs for IDs using generate_prefixed_cuid.

ID Pattern

✅ Always Do This

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
}

❌ Never Do This

// 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
}

Prefix Guidelines

EntityPrefixExample ID
Userusrusr_BJRIZLgRPuWt8MvMjkSY82f1
Organizationorgorg_cK9xMnPqRs2tUvWx3yZa4b5c
Tasktsktsk_dE6fGhIj7kLmNoP8qRsT9uVw
Controlctlctl_xY0zAaBb1cDdEe2fFgGh3iIj
Policypolpol_kK4lLmMn5oOpPq6rRsSt7uUv

Rules

  1. Short prefixes - Use 2-3 characters
  2. Unique prefixes - Each model gets its own prefix
  3. Always cast - Include ::text in the function call
  4. Use dbgenerated - Wrap the function call in dbgenerated()

Benefits

  • Human-readable IDs at a glance (usr_ vs org_)
  • Easy debugging in logs
  • Safe to expose in URLs
  • Unique across all tables

Checklist

After schema changes:

  • Schema edited in packages/db/prisma/schema/
  • Migration created with bunx prisma migrate dev
  • Types regenerated in apps/app with db:generate
  • Types regenerated in apps/api with db:generate
  • Types regenerated in apps/portal with db:generate
  • New models use prefixed CUID IDs

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Guide API endpoint changes so request DTOs, runtime validation, OpenAPI documentation, and MCP tool metadata stay aligned. It covers discoverability, authentication, uploads, long-running tasks, and response types that MCP tools cannot handle.

  • Adding an API endpoint with a request body
  • Updating DTO validation and OpenAPI metadata
  • Making an endpoint available as an MCP tool
trycompai/comp2.1KUpdated Oct 24, 2026

Review specified files for design system usage, replace legacy @trycompai/ui components and lucide-react icons with available @trycompai/design-system equivalents, and run the app type check to verify the migration.

  • Migrating legacy UI components
  • Replacing lucide-react icons with Carbon icons
  • Checking specified files for design system compliance
trycompai/comp2.1KUpdated Oct 24, 2026

audit-hooks

FreeSummary

Review specified files for outdated hook and API patterns, then replace them with the prescribed SWR hooks, API clients, or server API calls. The guidance covers data fetching, mutations, cache updates, and response handling, followed by a typecheck command.

  • Auditing files for disallowed API and hook patterns
  • Replacing raw fetch calls with the API client
  • Migrating server actions and database mutations to API hooks
trycompai/comp2.1KUpdated Oct 24, 2026

audit-rbac

FreeSummary

Review NestJS API endpoints and frontend components for role-based access control and audit log compliance. The skill lists permission, guard, route, and UI gating rules, then directs the agent to fix violations and run type checks.

  • Auditing API routes for permission decorators
  • Checking UI actions against user permissions
  • Fixing access control inconsistencies
trycompai/comp2.1KUpdated Oct 24, 2026

audit-tests

FreeSummary

Audit unit tests for components that use permissions. Add missing tests and fix failures, checking that administrators can use mutation controls, auditors cannot, and read-only content remains visible to both.

  • Adding permission tests for a component
  • Checking admin and auditor behavior
  • Fixing failing permission-related tests
trycompai/comp2.1KUpdated Oct 24, 2026

Set up Better Auth for TypeScript applications, including server and client configuration, database adapters, sessions, email and social sign-in, and plugins. The guide also highlights environment variables, schema generation, and security settings to review.

  • Configuring Better Auth in a TypeScript app
  • Connecting an ORM or database adapter
  • Setting up sessions and cookie storage
trycompai/comp2.1KUpdated Oct 24, 2026

See all skills by trycompai

Report a problem with this skill