prisma-harness

Configure and validate the Prisma 7 client, migrations, and Vitest test database harness.

Updated Jan 12, 2026
One-click install
npx skills add https://github.com/brandonarbini/arbini.family --skill prisma-harness-brandonarbini
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-harness
Source: https://github.com/brandonarbini/arbini.family/tree/main/.agents/skills/prisma-harness
Command: npx skills add https://github.com/brandonarbini/arbini.family --skill prisma-harness-brandonarbini

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires prisma, @prisma/client, @prisma/adapter-pg, pg, @types/pg, dotenv-cli.

What problem does it solve? Prisma projects break in non-obvious ways: the generated client goes missing on Vercel builds, duplicate pg copies make new PrismaPg(config) fail typechecking, tests silently run against the development database, and rows leak between tests. This Skill encodes the canonical Prisma 7 setup — generator output, pinned driver stack, per-worker test databases, and cleanup hooks — so these failure modes are caught and fixed before they ship. ## Core Features & Use Cases - Canonical client setup: Enforces the prisma-client generator with output = "../generated/prisma", root-mapped @/* paths, and prisma generate first in both postinstall and build so fresh clones and cached Vercel builds always have a client. - Pinned driver stack: Keeps prisma, @prisma/client, @prisma/adapter-pg, pg, and @types/pg on tilde pins with pnpm overrides, preventing duplicate pg copies that break PoolConfig assignability. - Test database harness: Documents the owned Vitest files (test/db.ts, vitest.global-setup.ts, vitest.env-setup.ts) that build a template database, clone it per worker, and enforce truncateAllTables / disconnectAppPrisma cleanup hooks. - Use Case: After editing prisma/schema.prisma, you run pnpm exec prisma migrate dev --name add_orders, commit the migration, and the Skill's contract ensures .env.test, test:env, and the Vitest setup point every suite at an isolated test database instead of development data. ## Quick Start Load this skill before editing prisma/schema.prisma or running a migration so the generated client, pinned driver versions, and Vitest test database wiring stay consistent.

Frequently Asked Questions about prisma-harness

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

FAQPage Schema
How do I fix "@prisma/client did not initialize yet" on Vercel?▼

Put `prisma generate` first in both `postinstall` and `build` scripts. Vercel restores node_modules from the previous build cache and skips lifecycle scripts, so only `build` regenerates the gitignored client in the repo-root `generated/` directory.

How do I create a Prisma migration after editing schema.prisma?▼

Run `pnpm exec prisma migrate dev --name <name>` inside the devcontainer. It only writes a new migration and never edits existing ones; commit the migration directory together with the schema change, and never hand-edit a migration already applied anywhere.

Why does new PrismaPg(config) fail typechecking while tests pass?▼

The dependency tree carries two copies of `pg` because `@prisma/adapter-pg` declares its own ranges, and types are nominal per copy. Set `overrides.pg` and `overrides["@types/pg"]` in pnpm-workspace.yaml so one copy exists and `PoolConfig` stays assignable.

Why is my Vitest suite running against the development database?▼

The `test:env` script must be exactly `dotenv -e .env -e .env.test -o --` so `.env.test` overrides `.env`. A duplicate `DATABASE_URL` line below the canonical one silently wins, and the env setup only rewrites database names it recognises.

Should I use cuid() or database-generated UUIDs for Prisma model ids?▼

Use `String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid` with `@db.Uuid` on every foreign key pointing at one. Managed schemas standardise on database-generated UUIDs, so `cuid()` or `uuid()` defaults are treated as drift.

How do I rename a column in Prisma without losing data?▼

Do not rely on `migrate dev`, which renders a rename as DROP plus CREATE and destroys the data. Hand-write the migration instead; the companion `prisma-rename-migrations` skill covers that workflow for databases already holding rows.