Prisma

by mindrally97184105b5daNo license269 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 5 weeks ago

Expert in Prisma ORM with type-safe database operations and schema design

Instructions onlySoftware Development
AI-generated overview

Guidance for using the Prisma ORM: schema design, type-safe client usage, errors, performance and testing.

What it does
This skill provides instructions and conventions for working with the Prisma ORM. It covers schema design such as model naming, relations, soft deletes and constraints, plus client usage including transactions, middleware, select/include queries and pagination. It also gives guidance on error handling, architecture patterns, performance tuning, testing and security practices. It produces no files or scripts; it is a set of coding conventions for an agent to follow.
When to use it
Use it when writing or reviewing code that uses Prisma for database access. It fits schema modelling, query construction, error handling and performance work in a Prisma-based project. It is also relevant when setting up testing or security practices around a Prisma client.
Requirements
No tools, packages or credentials are required beyond the agent; the skill is instructions only and ships no scripts. Applying it assumes a project that uses the Prisma ORM.

Prisma

You are an expert in Prisma ORM with deep knowledge of database schema design, type-safe operations, and performance optimization.

Core Principles

  • Always declare explicit types for variables and functions. Avoid using 'any'
  • Use PascalCase for classes/interfaces, camelCase for variables/functions, kebab-case for files
  • Write functions under 20 lines with single responsibility
  • Always use type-safe Prisma client operations

Schema Design

  • Employ domain-driven model naming conventions
  • Utilize decorators like @id, @unique, and @relation
  • Implement soft deletes using deletedAt timestamps
  • Maintain normalized, DRY schemas
  • Define proper relationships between models
  • Use appropriate field types and constraints

Client Usage

  • Leverage transactions for multi-step operations
  • Apply middleware for logging, soft deletes, and auditing
  • Handle optional relations explicitly
  • Use select and include for efficient queries
  • Implement pagination for large datasets

Error Management

  • Catch specific errors:
    • PrismaClientKnownRequestError
    • PrismaClientValidationError
  • Provide contextual, user-friendly messages
  • Log detailed debugging information
  • Handle unique constraint violations gracefully

Architecture

  • Separate data access from business logic
  • Implement repository patterns
  • Use dependency injection
  • Follow SOLID principles
  • Prefer composition over inheritance

Performance

  • Use select to fetch only needed fields
  • Implement proper indexing in schema
  • Use batch operations for bulk updates
  • Avoid N+1 queries with proper includes
  • Use connection pooling in production

Testing

  • Use in-memory databases for testing
  • Implement comprehensive scenario coverage
  • Mock Prisma client for unit tests
  • Use database transactions for test isolation

Security

  • Implement input validation
  • Use Row Level Security patterns
  • Rely on Prisma's built-in SQL injection protection
  • Validate data at both schema and application level

Source and attribution

Source:mindrally/skillsinprismaat commit9718410

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal