prismaWrite efficient Prisma queries, design schemas, and avoid common ORM pitfalls.
Install via ClawdBot CLI:
clawdbot install ivangdavila/prisma@default(cuid()) over @default(uuid()) for IDs—shorter, URL-safe, still unique@updatedAt doesn't update on nested writes—must touch parent record explicitly@unique on nullable field allows multiple NULLs—intended behavior but often surprisingfindUniqueOrThrow / findFirstOrThrow—cleaner than null check after findUniquecreateMany skips hooks and returns count only—use create in loop if you need records backupsert requires unique field in where—can't upsert on non-unique compound conditionsconnectOrCreate in nested writes—avoids separate existence checkselect and include are mutually exclusive—can't mix; use nested select inside includeinclude everything you'll access—check logs for unexpected queriesfindMany + include better than loop of findUnique—single query vs N queries$transaction([]) array syntax rolls back all on any failure—use for atomic operations$transaction(async (tx) => {}) hold connection—keep short$transaction doesn't retry on conflict—implement retry logic for optimistic lockinginclude result type doesn't narrow—TypeScript thinks relations might be undefinedunknown[]—need manual type assertion or Prisma.$queryRawJsonValue—cast needed; consider using typed JSON librariesPrisma.validator for reusable query fragments with correct types$executeRaw is count—not the affected rowsprisma db push for prototyping—prisma migrate dev for version controldb push can drop data silently—never use in productionmigrate dev—needs create permission or separate DB@map to keep datafindMany without take can return millions—always paginatecount() scans table—expensive on large tables; consider approximate or cached countsinclude with large relations loads everything—use cursor pagination for big lists_count: { select: { posts: true } }—single query, not N+1orderBy on non-indexed field = slow—ensure indexes match sort patterns$queryRaw for reads, $executeRaw for writes—different return typesPrisma.sql template for safe interpolation—never string concatenation$queryRawUnsafe exists but name is a warning—use only for dynamic column names@map usedconnection_limit in URL?pool_timeout=0—prevents connection exhaustion$disconnect() in scripts and tests—lambda/serverless should manage differentlydelete, convert to update—but deleteMany needs handling$use captures all queries—but adds latency to every operationinclude in middleware—transform happens before middlewareawait—Prisma returns promises; queries don't execute without awaitupdate without where = error—unlike some ORMs, Prisma requires explicit where@relation names must match—cryptic error if they don'tprisma migrate deploy in CIGenerated Mar 1, 2026
Building an online marketplace with complex product catalogs, user orders, and inventory management. The skill helps design efficient schemas for product variants, user carts, and order histories while preventing N+1 queries in product listing pages and ensuring transactional consistency for checkout processes.
Creating a software-as-a-service platform where each customer has isolated data. This skill assists in implementing secure data partitioning, managing connection pools for multiple tenants, and optimizing queries with proper indexing to handle concurrent user access across different client organizations.
Developing systems for banking or payment processing that require absolute data integrity. The skill provides guidance on using Prisma transactions for atomic operations, implementing retry logic for conflicts, and managing decimal fields correctly for monetary calculations while maintaining audit trails through middleware.
Building a CMS for publishers or media companies with articles, media assets, and user permissions. This skill helps structure hierarchical content relationships, implement soft delete functionality via middleware, and optimize performance through proper pagination and relation counting for dashboard analytics.
Creating systems for healthcare providers to manage patient records, appointments, and medical histories. The skill ensures proper schema design for sensitive data, implements efficient query patterns for patient lookups, and handles complex migrations without downtime when adding new medical codes or categories.
Offering database-backed applications to businesses with monthly/annual subscriptions. This model benefits from Prisma's type safety for rapid feature development and efficient query patterns that reduce server costs at scale, directly impacting profit margins through optimized infrastructure usage.
Providing custom development services to clients building database-intensive applications. This model leverages Prisma expertise to deliver projects faster with fewer bugs, using transaction patterns for data integrity and migration strategies that minimize client downtime during updates.
Building large-scale internal platforms for corporations with complex data relationships. This model utilizes Prisma's performance optimization patterns to handle massive datasets, connection management for high-concurrency environments, and raw query capabilities for specialized reporting needs.
đź’¬ Integration Tip
Start with schema design best practices before writing queries, use Prisma's transaction patterns for data consistency, and implement connection pooling adjustments early for production readiness.
Use the @steipete/oracle CLI to bundle a prompt plus the right files and get a second-model review (API or browser) for debugging, refactors, design checks, or cross-validation.
Manage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database). Use when a user asks Clawdbot to add a task to Things, list inbox/today/upcoming, search tasks, or inspect projects/areas/tags.
Local search/indexing CLI (BM25 + vectors + rerank) with MCP mode.
Use when designing database schemas, writing migrations, optimizing SQL queries, fixing N+1 problems, creating indexes, setting up PostgreSQL, configuring EF Core, implementing caching, partitioning tables, or any database performance question.
Connect to Supabase for database operations, vector search, and storage. Use for storing data, running SQL queries, similarity search with pgvector, and managing tables. Triggers on requests involving databases, vector stores, embeddings, or Supabase specifically.
Query, design, migrate, and optimize SQL databases. Use when working with SQLite, PostgreSQL, or MySQL — schema design, writing queries, creating migrations, indexing, backup/restore, and debugging slow queries. No ORMs required.