plugins/smedjen/skills/prisma-patterns/SKILL.md
Prisma schema design, migrations, relations, raw queries, seeding, and performance optimization. Covers schema modeling decisions, migration workflow, query patterns, transactions, and common anti-patterns.
npx skillsauth add hjemmesidekongen/ai prisma-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Model the domain first, then let Prisma reflect it. Schema decisions made carelessly early become expensive migrations later.
Define relations explicitly with @relation. Always add @@index on fields used in where, orderBy, or as FK targets. Use @@map and @map to decouple Prisma names from database names — keeps the schema clean while the DB follows conventions.
Enums in Prisma map to DB enums. Prefer them for stable, bounded sets. For extensible value sets, use a string field with application-level validation instead.
prisma migrate dev — development: generates + applies + regenerates client. Use this locally.prisma migrate deploy — production: applies pending migrations only. Never generates. CI/CD safe.migrate diff + migrate resolve --applied before introducing Prisma to a legacy schema.Default rule: select only what you need. Use select to project specific fields rather than pulling full records. Use include only for relations actually rendered. Avoid findMany inside loops — batch with include or a single query with where: { id: { in: ids } }.
Add take and skip on any unbounded findMany. Paginate by cursor (cursor + take) for large datasets — offset pagination degrades at scale.
Use $queryRaw for reads that require DB-specific syntax (window functions, CTEs, full-text search). Use $executeRaw for writes. Always use tagged template literals — never string interpolation — to prevent SQL injection. Raw results are not typed by default; cast with Prisma.sql and validate output shape.
Use $transaction([...]) for sequential operations that must succeed together. Use the interactive transaction ($transaction(async (tx) => { ... }) for conditional logic mid-transaction. Keep transactions short — long-running transactions cause lock contention.
See references/process.md for schema patterns, seeding, Prisma Client extensions, middleware, soft deletes, multi-tenancy, and anti-patterns with fixes.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.