Skip to main content
skill CX Codex

zenstack-migrate-from-prisma — Claude Code skill for Prisma migration

The zenstack-migrate-from-prisma Claude Code skill guides a project migration from Prisma to ZenStack V3. It covers schema, client, generation, and migration updates.

MIT 520 installs ★ 3 updated 2026-10-28

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add zenstackhq/skills --skill zenstack-migrate-from-prisma -a claude-code
Open on GitHub

What zenstack-migrate-from-prisma does

The skill guides the move from Prisma to ZenStack V3. It replaces schema.prisma with zenstack/schema.zmodel, switches PrismaClient to ZenStackClient, and updates generation and migration scripts. Existing findMany, create, and update calls remain compatible with the ORM API. It also covers Prisma custom generators and client extensions.

A database driver is required: pg, mysql2, or better-sqlite3. ZenStack migration commands wrap Prisma Migrate, and the existing migration history moves from prisma/migrations to zenstack/migrations. Multi-file schemas can be combined with ZModel import statements.

What it helps with

  • convert schema.prisma to ZModel
  • replace PrismaClient with ZenStackClient
  • revise generation and migration scripts
  • preserve Prisma Migrate history
  • map custom generators and client extensions

Example prompts for the agent

  • Migrate this Prisma project to ZenStack V3.
  • Replace PrismaClient with ZenStackClient and update the scripts.
  • Move the migration history from prisma/migrations to ZenStack.

How to install zenstack-migrate-from-prisma

1Skills CLI (Vercel)

npx skills add zenstackhq/skills --skill zenstack-migrate-from-prisma -a claude-code

2Manually: put the files in place

~/.claude/skills/zenstack-migrate-from-prisma/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/zenstack-migrate-from-prisma/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about zenstack-migrate-from-prisma

How do I install zenstack-migrate-from-prisma in Claude Code?

Run npx skills add zenstackhq/skills --skill zenstack-migrate-from-prisma -a claude-code. The skill file is placed at ~/.claude/skills/zenstack-migrate-from-prisma/SKILL.md.

What does zenstack-migrate-from-prisma do?

It guides a Prisma-to-ZenStack V3 migration, covering schema conversion, the client swap, and script changes. It also maps Prisma custom generators and client extensions.

What does zenstack-migrate-from-prisma need to work?

The project needs a database driver: pg for PostgreSQL, mysql2 for MySQL, or better-sqlite3 for SQLite. ZenStack migration commands use Prisma Migrate.

Source text

SKILL.md · MIT
---
name: zenstack-migrate-from-prisma
description: Migrate an existing Prisma project to ZenStack V3. Use when replacing Prisma/@prisma/client with ZenStack, converting schema.prisma to ZModel, swapping PrismaClient for ZenStackClient, updating generate/migrate scripts, mapping Prisma custom generators and client extensions, or keeping Prisma migrate tooling working.
---

# Migrating from Prisma to ZenStack V3

ZenStack V3 is designed as a drop-in upgrade path for Prisma: it keeps a Prisma-compatible query API
and a schema language (ZModel) that is a superset of the Prisma schema. Most apps migrate with
mechanical changes and no query rewrites. Supported databases: **PostgreSQL, MySQL, SQLite**.

For general setup/CLI details see `zenstack-project-setup`; for the client/dialect see
`zenstack-querying`; for schema syntax see `zenstack-schema-modeling`.

## At a glance

| Prisma | ZenStack V3 |
| ------ | ----------- |
| `prisma`, `@prisma/client` | `@zenstackhq/cli` (dev), `@zenstackhq/schema`, `@zenstackhq/orm` |
| `schema.prisma` | `zenstack/schema.zmodel` (Prisma schema is valid ZModel) |
| `prisma generate` | `zen generate` |
| `prisma db push` / `migrate dev` / `migrate deploy` | `zen db push` / `zen migrate dev` / `zen migrate deploy` |
| `new PrismaClient()` | `new ZenStackClient(schema, { dialect })` |
| bundled DB engine | you install a DB driver (`pg` / `mysql2` / `better-sqlite3`) |

## Step 1 — Swap dependencies

```bash
npm uninstall prisma @prisma/client
npm install @zenstackhq/schema @zenstackhq/orm
npm install --save-dev @zenstackhq/cli
```

ZenStack does **not** bundle a database engine — install the driver for your database:

| Database   | Install |
| ---------- | ------- |
| PostgreSQL | `npm install pg` + `npm install -D @types/pg` |
| MySQL      | `npm install mysql2` |
| SQLite     | `npm install better-sqlite3` + `npm install -D @types/better-sqlite3` |

> `@zenstackhq/cli` has a peer dependency on `prisma`, which is installed automatically when needed
> for migration commands (ZenStack's migrate commands wrap Prisma Migrate).

## Step 2 — Move and rename the schema

Move `schema.prisma` → `zenstack/schema.zmodel`. **No edits are required** — every valid Prisma
schema is valid ZModel. Optional cleanup:

- Drop the `generator client { ... }` block (no effect in ZenStack — code gen is driven by
  `zen generate`).
- The `datasource` block is kept; its `url` is used by the migration engine (the ORM runtime gets
  its connection from the driver/dialect instead).
- If you used Prisma's multi-file/multi-schema feature, merge files using ZModel `import`
  statements.

Run **`zen check`** to confirm the converted schema is valid (syntax + semantics) before moving on.

Once moved, you can start adding ZenStack-only features that Prisma lacks — access policies
(`zenstack-access-control`), `@@delegate` polymorphism, typed JSON, mixins, computed fields
(`zenstack-schema-modeling`).

## Step 3 — Update the generate script

```json
{ "scripts": { "generate": "zen generate" } }
```

Run `zen generate` after every schema change, before using the client.

## Step 4 — Replace the client

Swap `new PrismaClient()` for `new ZenStackClient(schema, { dialect })`, supplying a Kysely dialect
for your driver (see `zenstack-querying` for all dialects). PostgreSQL example:

```ts
import { ZenStackClient } from '@zenstackhq/orm';
import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres';
import { schema } from './zenstack/schema';
import { Pool } from 'pg';

export const db = new ZenStackClient(schema, {
    dialect: new PostgresDialect({
        pool: new Pool({ connectionString: process.env.DATABASE_URL }),
    }),
});
```

Your existing `findMany`/`create`/`update`/etc. calls keep working — the ORM API is
Prisma-compatible.

## Step 5 — Update type references

- Model types (e.g. `User`) — import from the generated `models`.
- Input/argument types (e.g. `UserCreateArgs`) — import from the generated `input`.

Most code relies on inferred types and needs no explicit imports.

## Step 6 — Update migration scripts

```json
{
  "scripts": {
    "db:push": "zen db push",
    "migrate:dev": "zen migrate dev",
    "migrate:deploy": "zen migrate deploy"
  }
}
```

Move your existing migration history from `prisma/migrations` to `zenstack/migrations` (ZenStack's
default location, next to `zenstack/schema.zmodel`). It continues to work unchanged since ZenStack
migrate wraps Prisma Migrate. See the `zenstack-db-migration` skill for the full migration workflow.

## Special case — Prisma custom generators

If you depend on Prisma custom generators (e.g. zod, ERD, type generators) that read a
`schema.prisma`, keep emitting one with the `@core/prisma` plugin and chain the commands:

```zmodel
plugin prisma {
    provider = '@core/prisma'
    output = './schema.prisma'
}
```

```json
{ "scripts": { "generate": "zen generate && prisma generate --schema=zenstack/schema.prisma" } }
```

## Mapping Prisma Client extensions

| Prisma extension | ZenStack equivalent |
| ---------------- | ------------------- |
| **Query** extension (intercept calls) | A runtime plugin via `db.$use(...)` with an `onQuery` hook |
| **Result** extension (computed fields) | `@computed` field in ZModel + the `computedFields` option on `ZenStackClient` (see `zenstack-schema-modeling`) |

## After migrating

Verify with: `zen generate` → typecheck → run your test suite / app. Then incrementally adopt
ZenStack's value-add features (access control, query builder escape hatch, auto CRUD APIs via
`zenstack-crud-server`).

> Already on **ZenStack V2**? Start here (V2 was Prisma-based), then apply the V2→V3 deltas in
> `zenstack-project-setup` (package renames, policy plugin, `post-update`/`before()`, types+mixins,
> grouped hooks).

## Reference docs

Full ZenStack documentation for this topic is bundled under [`references/`](references/):

- [migrate-prisma.md](references/migrate-prisma.md) — official "Migrating from Prisma" guide

© zenstackhq · MIT · zenstackhq/skills

Similar skills

All skills for Data and databases →

From the same set9

zenstack-access-control The zenstack-access-control Claude Code skill helps define access policies in a ZenStack V3 schema. It activates for @@allow, @@deny, auth(), and post-update rules. CX Codex +1 556installs zenstack-db-migration The zenstack-db-migration Claude Code skill manages database schema migrations in ZenStack V3. It activates for migration work, schema prototyping, or introspecting an existing database. CX Codex +1 551installs zenstack-crud-server zenstack-crud-server — a skill for Claude Code that turns ZenStack V3 models into REST or RPC CRUD APIs. It covers server routes, per-request access control, OpenAPI specs, and client calls. CX Codex +1 548installs zenstack-plugin-dev The zenstack-plugin-dev Claude Code skill guides development of ZenStack V3 plugins. It applies to ZModel extensions, CLI code generation, and ORM client plugins. CX Codex +1 521installs zenstack-migrate-from-v2 The zenstack-migrate-from-v2 skill for Claude Code guides a ZenStack project upgrade from V2 to V3. It covers schema, access policies, server adapters, and client hooks. CX Codex +1 515installs zenstack-project-setup The zenstack-project-setup Claude Code skill sets up ZenStack V3 projects, scaffolds new ones, and runs zen CLI tasks. It activates for ZenStack installation, project creation, or CLI use. CX Codex +1 510installs zenstack-querying The zenstack-querying Claude Code skill explains how to query and change data with the ZenStack V3 client. It covers ORM operations, relations, and SQL-shaped queries built with Kysely. CX Codex +1 494installs zenstack-schema-modeling The zenstack-schema-modeling Claude Code skill helps write and revise ZModel schemas for ZenStack V3. It activates for work on models, fields, relations, enums, and typed JSON fields. CX Codex +1 470installs

Project sponsors

Companies that keep this analytics open