Backend · How to use a skill

set-up-prisma-orm

Sets up Prisma ORM in a Node or TypeScript app, or repairs an existing app's database connection, by detecting the Prisma version first - new apps on Prisma 8, existing Prisma 6 or 7 apps kept on their version. Use when the user wants to add Prisma, connect Postgres or MySQL with an ORM, fix a Prisma connection error, or set up prisma.config.ts.

Version 1.0 · Updated 2026-10-31

View raw SKILL.md

Install in Claude Code, Cursor or Codex (optional)

Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.

Claude Code (all your projects)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/raw' -o ~/'.claude/skills/set-up-prisma-orm/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/LICENSE.txt' -o ~/'.claude/skills/set-up-prisma-orm/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/references/prisma-7-postgresql.md' -o ~/'.claude/skills/set-up-prisma-orm/references/prisma-7-postgresql.md'

Cursor (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/raw' -o '.cursor/skills/set-up-prisma-orm/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/LICENSE.txt' -o '.cursor/skills/set-up-prisma-orm/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/references/prisma-7-postgresql.md' -o '.cursor/skills/set-up-prisma-orm/references/prisma-7-postgresql.md'

Codex and other Agent Skills tools (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/raw' -o '.agents/skills/set-up-prisma-orm/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/LICENSE.txt' -o '.agents/skills/set-up-prisma-orm/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/set-up-prisma-orm/files/references/prisma-7-postgresql.md' -o '.agents/skills/set-up-prisma-orm/references/prisma-7-postgresql.md'

Or connect the whole library over MCP

Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):

{
  "mcpServers": {
    "theskillvault": {
      "url": "https://theskillvault.ai/mcp"
    }
  }
}

Set up Prisma ORM

Prisma ORM lets your code talk to a database with typed queries. The big trap is versions: Prisma 6, 7 and 8 set up differently. This skill finds out which one you have first, then follows the right path.

When to use

  • Adding a database layer with Prisma to a new or existing app.
  • An existing Prisma app cannot connect to its database.
  • The AI is mixing up Prisma 6, 7 and 8 instructions.

Steps

  1. Detect the starting point. Read package.json, the lockfile, prisma/schema.prisma, any prisma.config.ts and the imports in app code. Note the ORM version, the database and the runtime. The CLI version alone is not enough: check @prisma/client (and @prisma/prisma7) too.
  • Already on Prisma 8: skip to step 4. Do not re-initialise.
  • New app, no version chosen: go to step 3 (Prisma 8).
  • On Prisma 6 or 7, or the user chose an earlier major: go to step 5.
  1. Upgrades are a separate task. Fixing a connection never needs a major upgrade. If the user asks for one, follow Prisma's official upgrade guide for that version and database.
  2. New app on Prisma 8. Check the release's supported databases and runtime requirements first. If the database is not supported, say so and offer an earlier version; never quietly switch databases. Pin an exact Prisma 8 CLI release (do not trust a floating latest), then run it with the project's package manager. For Postgres with the Prisma schema language:
   prisma orm init --yes --target postgres --authoring psl

Keep existing app files and connection settings. Do not let setup create a database the user did not ask for.

  1. Load the version's own guidance. Run prisma skills sync, then read the synced prisma-8/SKILL.md (for example .agents/skills/prisma-8/SKILL.md) and follow it. Syncing alone does not load it. If it cannot be loaded, report that as a blocker.
  2. Earlier versions. Pin every Prisma package to the same major.
  • Prisma 7 with Postgres: follow references/prisma-7-postgresql.md references/prisma-7-postgresql.md: driver adapter, prisma.config.ts, and the prisma-client generator with an output path.
  • Prisma 7 with MySQL, SQLite, SQL Server or CockroachDB: use the matching file in the upstream references folder.
  • Prisma 6: keep its generator, schema URL and client setup. Use the Prisma 6 docs. Do not paste Prisma 7 config or adapters into it.
  1. Connect and verify. Make sure the CLI and the app load the same environment file and point at the same database. Diagnose the connection before any schema-changing command. Run the project's checks and one read-only query through the app's client, such as a count().

Gotchas

  • Installing packages or syncing skills is not a finished setup. Only a working read-only query is.
  • The CLI and the app can read different .env files. A migration can then hit a different database than the app.
  • Each PrismaClient opens a pool of connections. Create one and reuse it, or serverless apps run out of connections.
  • Run prisma generate again after every schema change.

Safety

  • Keep DATABASE_URL and other credentials in a git-ignored .env or the host's secret settings. Never print them in logs or chat.
  • Never run migrate reset, db push --force-reset or similar on a database with real data without a backup and a clear yes.
  • For an existing app, keep its schema, migrations and generator config unless the task needs a change.

Works with other stacks

Prisma supports PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB and MongoDB, with npm, pnpm, yarn or bun. Using Drizzle or another ORM instead? The same rules apply: detect the version, keep secrets in env files, verify with a read-only query.

Done when

  • You can name the Prisma version in use and the database it connects to.
  • A read-only query through the app's client returns a result, and the project's checks pass.

Example prompt

"Add Prisma to my Next.js app and connect it to my Postgres database."

---

Adapted from "prisma-orm-setup" in prisma/skills by Prisma (MIT). See LICENSE.txt.

Adapted from Prisma (prisma/skills, 'prisma-orm-setup') (Copyright (c) 2025 Prisma), MIT License. Adapted by TheSkillVault: plain-language steps and a version decision list; PostgreSQL and client-setup references for Prisma 7 merged into one reference file; other providers linked upstream; added when-to-use, gotchas, safety, portability and done-when sections.

Licence: MIT License. Attribution when you reuse it: Based on work by Prisma (prisma/skills, 'prisma-orm-setup') (Copyright (c) 2025 Prisma, MIT License), https://github.com/prisma/skills/tree/8ea289b730c2e89f7ff1f518af128b113d842a92/prisma-orm-setup; adapted by TheSkillVault, https://theskillvault.ai