prisma-database-architect

Designs and optimizes Prisma schemas, migrations, queries, and connection pooling for PostgreSQL.

1|Updated Aug 25, 2026
One-click install
npx skills add https://github.com/sabiscore/swarmxq --skill prisma-database-architect-sabiscore
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-database-architect
Source: https://github.com/sabiscore/swarmxq/tree/main/.ai/skills/prisma-database-architect
Command: npx skills add https://github.com/sabiscore/swarmxq --skill prisma-database-architect-sabiscore

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Prisma schemas and queries that work in development often fail in production: missing indexes cause slow queries, unsafe migrations lock live tables, N+1 patterns exhaust connection pools, and Float fields corrupt monetary values. This Skill applies production-grade rules to every Prisma decision so schemas, migrations, and queries are safe and performant on live PostgreSQL databases. ## Core Features & Use Cases - Schema Design: Enforces conventions like PascalCase models, cuid IDs, Decimal for money, soft deletes, and @@index on every foreign key and filtered field. - Safe Migrations: Applies the expand-migrate-contract pattern, CREATE INDEX CONCURRENTLY, and multi-deploy strategies for NOT NULL columns to avoid locking live tables. - Query Optimization: Diagnoses and fixes N+1 queries with include/select, implements cursor-based pagination, upserts, transactions, and EXPLAIN ANALYZE via raw SQL. - Connection Pooling: Configures Prisma Accelerate for serverless and sizes connection pools for long-running Fastify servers. - Use Case: A user's invoice listing endpoint times out in production. The Skill identifies an N+1 query, adds eager loading with select, adds a composite index on (status, dueAt), and switches offset pagination to cursor-based pagination. ## Quick Start Ask the assistant to audit your Prisma schema and slow queries, for example: "Review my schema.prisma and fix the slow invoice query using production-safe patterns."

Frequently Asked Questions about prisma-database-architect

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 queries in Prisma?

Fix N+1 queries in Prisma by replacing per-record findMany calls inside loops with a single query using include or nested select to eager-load relations. Detect them by enabling Prisma query logging or @prisma/instrumentation tracing.

How do I add an index to a large PostgreSQL table with Prisma?

Add indexes on large tables using CREATE INDEX CONCURRENTLY in raw SQL. Generate an empty migration with prisma migrate dev --create-only, edit the SQL to include CONCURRENTLY, then apply it so reads and writes are not blocked.

How do I safely add a NOT NULL column in a Prisma migration?

Add the column as nullable first, backfill existing rows, then add the NOT NULL constraint in a later deploy. On PostgreSQL 11+, you can do it in one migration by adding the column with a DEFAULT value.

Should I use Prisma Accelerate or PgBouncer for connection pooling?

Use Prisma Accelerate for serverless deployments like Next.js on Vercel, keeping DIRECT_URL for migrations. For long-running servers like Fastify, configure connection_limit and pool_timeout in the DATABASE_URL instead.

Why should money fields use Decimal instead of Float in Prisma?

Money fields must use Decimal with @db.Decimal(precision, scale) because Float arithmetic loses cents due to binary floating-point rounding. Decimal stores exact values, which is required for financial correctness.

Does Prisma support cursor-based pagination for large datasets?

Yes, Prisma supports cursor-based pagination using the cursor, take, and skip options, which stays O(1) regardless of page depth. Offset pagination with skip performs full scans and becomes slow at high offsets.