# Prisma Documentation - Full Content Feed This file contains the current Prisma documentation in machine-readable format. Legacy Prisma ORM v6 content is not included here; fetch any v6 page directly by appending `.md` to its URL (for example, https://www.prisma.io/docs/orm/v6/....md). For the documentation index, see https://www.prisma.io/docs/llms.txt. --- # Deploy the full Prisma stack (/docs/full-stack-tutorial) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. A single tutorial from empty directory to live URL, with Prisma Composer, Prisma ORM, and Prisma Postgres. Location: Deploy the full Prisma stack This tutorial takes you through the whole recommended stack in one sitting. [Prisma Composer](https://www.prisma.io/docs/composer) declares your app: its services, its databases, and how they connect. [Prisma ORM](https://www.prisma.io/docs/orm) types your data. [Prisma Postgres](https://www.prisma.io/docs/postgres) stores it, locally while you develop and on the platform when you deploy. One declaration drives everything: the same `module.ts` runs the app on your machine and deploys it to [Prisma Compute](https://www.prisma.io/docs/compute). Plan on about 15 minutes. It uses the `hono` template so you get a small API you can verify with curl at every step. The same journey works for the other templates; the [framework guides](https://www.prisma.io/docs/guides) cover each one. ## Prerequisites [#prerequisites] * Node.js 22.18 or newer (on the 24 line, 24.11 or newer; 24 recommended), or Bun * A [Prisma Data Platform account](https://pris.ly/pdp) for the deploy step, free to create * No database needed: local runs provision a local Prisma Postgres, and deploys provision a real one, both from your Composer declaration ## Use with your agent [#use-with-your-agent] If you would rather hand the work to a coding agent, this prompt runs the same journey as the one on the [getting started page](https://www.prisma.io/docs), with the `hono` template chosen for you: The prompt uses npm and Node.js. On Bun, replace `npm create prisma@latest --` with `bun create prisma@latest`, `npx` with `bunx`, and `npm run` with `bun run`. ```text Create a new Hono API composed with Prisma Composer and Prisma ORM, run it locally, and deploy it to Prisma Compute. 1. Scaffold: `npm create prisma@latest -- my-app --template hono --provider postgres --yes`. Then run `npx prisma@latest init` in `my-app` to confirm the Prisma agent skills the scaffold installed are current, and use them. 2. Read `module.ts` and `service.ts` first: the Composer module provisions the database and the service, and it is what `dev` and `deploy` operate on. 3. Build and run locally: `npm run build`, then `npx prisma@latest dev module.ts`. This provisions a local Prisma Postgres database and applies the contract; no DATABASE_URL is needed. Sample users are seeded on the app's first query. Verify the local URL that `dev` prints: its /users endpoint returns the seeded users. 4. Deploy: check `npx prisma@latest auth whoami`; if I am not signed in, stop and ask me to run `npx prisma@latest auth login` (it opens a browser). Capture the baseline migration first with `npx prisma@latest migration plan --name init` and note the migration directory it writes. Then run `npx prisma@latest deploy module.ts` and verify the live URL's /users endpoint with curl. The deploy creates the project and provisions the database from the module declaration; do not pass a DATABASE_URL. 5. Evolve the schema: add `role String @default("member")` to the User model in `src/prisma/contract.prisma`, run `npx prisma@latest contract emit`, add `"role"` to the typed select and the returned object in `src/prisma/users.ts`, and plan the migration with `npx prisma@latest migration plan --name add-user-role --from `. Then run `npm run build` and `npx prisma@latest deploy module.ts` again, and verify the live /users now returns `role: "member"` with the same createdAt values as before. ``` ## 1. Scaffold the app [#1-scaffold-the-app] One command creates a Composer-declared app with Prisma ORM wired in: #### bun ```bash bun create prisma@latest my-app --template hono --provider postgres ``` #### pnpm ```bash pnpm create prisma@latest my-app --template hono --provider postgres ``` #### yarn ```bash yarn create prisma@latest my-app --template hono --provider postgres ``` #### npm ```bash npm create prisma@latest -- my-app --template hono --provider postgres ``` Answer the prompts for contract authoring style and package manager, or pass the `--authoring` and `--package-manager` flags to skip them (see the [create-prisma reference](https://www.prisma.io/docs/prisma-orm/create-prisma); Deno projects cannot deploy to Prisma Compute yet, so this tutorial uses Node.js or Bun). Then enter the project: #### bun ```bash cd my-app ``` #### pnpm ```bash cd my-app ``` #### yarn ```bash cd my-app ``` #### npm ```bash cd my-app ``` If you work with a coding agent, run [`npx prisma@latest init`](https://www.prisma.io/docs/cli/init) once. The scaffold ran it already, so on a fresh project `init` confirms the setup and reports each step as already done: the [Prisma agent skills](https://www.prisma.io/docs/ai/tools/skills) that ship inside the Prisma packages are synced, and `package.json` has a `postinstall` hook (`prisma skills sync || exit 0`) that resyncs them on every install, plus a `skills:sync` script for refreshing them by hand. Running `init` again is what repairs the setup after you upgrade a Prisma package. See [`skills`](https://www.prisma.io/docs/cli/skills). ## 2. The Composer app [#2-the-composer-app] Start with the declaration, because it is what every later command operates on. The scaffold declares the whole app in two files. `module.ts` is the app: it provisions a Prisma Postgres database and the service, and wires one to the other: ```ts title="module.ts" import { module } from "@prisma/composer"; import { postgres } from "@prisma/composer-prisma-cloud/orm"; import { appContract } from "./src/prisma/composer.ts"; import app from "./service.ts"; export default module("my-app", ({ provision }) => { const database = provision( postgres({ name: "database", contract: appContract, config: "./prisma.config.ts", }), { id: "database" }, ); provision(app, { deps: { database } }); }); ``` `service.ts` declares the service itself: its name, its dependency on the database, and how it is built: ```ts title="service.ts" import node from "@prisma/composer/node"; import { compute } from "@prisma/composer-prisma-cloud"; import { postgres } from "@prisma/composer-prisma-cloud/orm"; import { appContract } from "./src/prisma/composer.ts"; export default compute({ name: "app", deps: { database: postgres(appContract), }, build: node({ module: import.meta.url, entry: "./dist/server.mjs" }), }); ``` Notice there is no connection string anywhere. The database is a declared dependency, typed by your contract, and Composer injects the connection wherever the app runs. The declaration is ordinary TypeScript: `npx tsc --noEmit` checks the wiring, and mistakes fail the compile instead of a deploy. [Composer](https://www.prisma.io/docs/composer) covers the model in full: modules, services, dependencies, and the first-party building blocks. ## 3. The Prisma ORM data model [#3-the-prisma-orm-data-model] The data side lives under `src/prisma/`. Your schema is the starter contract in `src/prisma/contract.prisma`; `npm run contract:emit` compiles it into the contract artifacts your queries are type-checked against, and `src/prisma/db.ts` is the typed client the route handlers import. The `/users` route in `src/index.ts` is ordinary Hono code calling an ordinary Prisma ORM query. Change the contract when you are ready to model your own data, re-emit it, and the compiler walks you through every query the change touches. The [fundamentals](https://www.prisma.io/docs/orm/fundamentals/reading-data) cover the query patterns. ## 4. Run it locally on Prisma Postgres [#4-run-it-locally-on-prisma-postgres] Build the server, then bring the whole declaration up on your machine: #### bun ```bash bun run build bunx prisma@latest dev module.ts ``` #### pnpm ```bash pnpm run build pnpm dlx prisma@latest dev module.ts ``` #### yarn ```bash yarn build yarn dlx prisma@latest dev module.ts ``` #### npm ```bash npm run build npx prisma@latest dev module.ts ``` `dev` provisions a local Prisma Postgres database, applies the contract to it, starts the service, and prints the app's local URL when everything is ready. No account, credentials, or connection string are involved; see [Local development](https://www.prisma.io/docs/local-development) for how the local platform works. Sample users are seeded automatically the first time the app queries the database. Confirm the API serves the seeded rows. `dev` picks a free port and prints the URL, so use the one it printed if it differs from the `3000` shown here: ```bash curl http://localhost:3000/users ``` ```json no-copy [ { "id": "1", "email": "alice@prisma.io", "username": "alice", "name": "Alice", "createdAt": "2026-08-24T13:51:34.797Z" }, { "id": "2", "email": "bob@prisma.io", "username": "bob", "name": "Bob", "createdAt": "2026-08-24T13:51:34.803Z" }, { "id": "3", "email": "carol@prisma.io", "username": "carol", "name": "Carol", "createdAt": "2026-08-24T13:51:34.804Z" } ] ``` If you prefer the framework's own dev server, `npm run dev` runs it directly. Composer does not manage that mode, so the app needs a database of your own in `DATABASE_URL`. Create one inside your project with the CLI: #### bun ```bash bunx prisma@latest auth login bunx prisma@latest project create my-app bunx prisma@latest postgres create mydb ``` #### pnpm ```bash pnpm dlx prisma@latest auth login pnpm dlx prisma@latest project create my-app pnpm dlx prisma@latest postgres create mydb ``` #### yarn ```bash yarn dlx prisma@latest auth login yarn dlx prisma@latest project create my-app yarn dlx prisma@latest postgres create mydb ``` #### npm ```bash npx prisma@latest auth login npx prisma@latest project create my-app npx prisma@latest postgres create mydb ``` `postgres create` prints the connection string once; export it as `DATABASE_URL`, and mint another later with `npx prisma@latest postgres connection create mydb` if you need one. The `db:*` scripts in `package.json` initialize and verify that database. See [`postgres`](https://www.prisma.io/docs/cli/postgres). ## 5. Deploy app and database to Prisma Compute [#5-deploy-app-and-database-to-prisma-compute] Sign in once (it opens your browser): #### bun ```bash bunx prisma@latest auth login ``` #### pnpm ```bash pnpm dlx prisma@latest auth login ``` #### yarn ```bash yarn dlx prisma@latest auth login ``` #### npm ```bash npx prisma@latest auth login ``` Before the first deploy, capture your schema as the first checked-in migration. Deployed databases evolve through the migrations you commit, so the baseline must be one: #### bun ```bash bunx prisma@latest migration plan --name init ``` #### pnpm ```bash pnpm dlx prisma@latest migration plan --name init ``` #### yarn ```bash yarn dlx prisma@latest migration plan --name init ``` #### npm ```bash npx prisma@latest migration plan --name init ``` The plan writes `migrations/app/_init`; commit it with your code. You will chain the next migration from it in [step 7](#7-evolve-the-data-model). Build and deploy the same declaration: #### bun ```bash bun run build bunx prisma@latest deploy module.ts ``` #### pnpm ```bash pnpm run build pnpm dlx prisma@latest deploy module.ts ``` #### yarn ```bash yarn build yarn dlx prisma@latest deploy module.ts ``` #### npm ```bash npm run build npx prisma@latest deploy module.ts ``` Composer creates a project named after your module, provisions the Prisma Postgres database declared in `module.ts`, wires it to the service, and starts the app. There is nothing to configure and no environment file to pass, because the deployed database comes from the declaration exactly as the local one did. When everything is up, the deploy prints what it made, each part of your app next to the platform resource it became, along with the public URL: ```text no-copy my-app ├─ database postgres-database db_abc123 └─ app compute-service cps_abc123 https://xyz.ewr.prisma.build ``` > [!WARNING] > The module name must be unique in your workspace > > `deploy` looks the module name up in your workspace and reuses the project this module deployed before rather than creating another. If a `my-app` project exists whose hosted state the CLI cannot verify (one deployed from a different checkout, for example), the deploy stops with `HostedStateBootstrapError` and names a project id you did not choose. Deploy under a different name with [`--name`](https://www.prisma.io/docs/cli/deploy#flags), or rename the module in `module.ts`: > > > > > #### bun > ```bash > bunx prisma@latest deploy module.ts --name my-app-tutorial > ``` > > > #### pnpm > ```bash > pnpm dlx prisma@latest deploy module.ts --name my-app-tutorial > ``` > > > #### yarn > ```bash > yarn dlx prisma@latest deploy module.ts --name my-app-tutorial > ``` > > > #### npm > ```bash > npx prisma@latest deploy module.ts --name my-app-tutorial > ``` > > ## 6. Verify the live URL [#6-verify-the-live-url] ```bash curl https://xyz.ewr.prisma.build/users ``` The same three users come back, now served from production next to your database, seeded on the deployed app's first query. Re-deploying is idempotent: build again, deploy again, and the platform applies only the difference. That includes removals, because your module is the source of truth: delete a provision from `module.ts`, deploy again, and the resource disappears from the platform. See [Removing resources](https://www.prisma.io/docs/composer/deploying#removing-resources). ## 7. Evolve the data model [#7-evolve-the-data-model] Live apps outgrow their starter schema, so give users a role. Add one line to the contract: ```prisma title="src/prisma/contract.prisma" // use prisma-8 model User { id Int @id @default(autoincrement()) email String @unique username String? name String? role String @default("member") posts Post[] createdAt TimestamptzString @default(now()) updatedAt temporal.updatedAtString() } ``` Re-emit the contract, then plan the migration that carries the change, chaining from the baseline migration you created in [step 5](#5-deploy-app-and-database-to-prisma-compute): #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest migration plan --name add-user-role --from _init ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest migration plan --name add-user-role --from _init ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest migration plan --name add-user-role --from _init ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest migration plan --name add-user-role --from _init ``` `--from` names the migration you are building on, and here it is required: a Composer deploy never sets the `db` ref that `migration plan` chains from by default, so a plan without it would describe every table again. The [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) and [`migration ref`](https://www.prisma.io/docs/cli/migration-ref) references cover the default, the ref, and how to keep plans chaining on their own. The plan is your change and nothing else. Review it like any other diff, with [`migration show`](https://www.prisma.io/docs/cli/migration-show) or by reading the generated package: ```text no-copy ALTER TABLE "public"."user" ADD COLUMN "role" text DEFAULT 'member' NOT NULL ``` Emitting also updated the query types, so surface the new field in the route's typed select in `src/prisma/users.ts`, adding `"role"` to the `.select(...)` list and `role: user.role` to the returned object: ```ts title="src/prisma/users.ts" const users = await db.orm.public.User.select("id", "email", "username", "name", "role", "createdAt").limit(limit).all(); ``` This is the Prisma ORM loop: the contract is the source of truth, the emit step regenerates the types, and the compiler points at every query the change touches. If you want to see the change on your machine first, run `npm run build` and `npx prisma@latest dev module.ts` again; the local database applies the new migration on start and `/users` returns the role there too. Then build and deploy again: #### bun ```bash bun run build bunx prisma@latest deploy module.ts ``` #### pnpm ```bash pnpm run build pnpm dlx prisma@latest deploy module.ts ``` #### yarn ```bash yarn build yarn dlx prisma@latest deploy module.ts ``` #### npm ```bash npm run build npx prisma@latest deploy module.ts ``` The deploy applies the committed migration to the deployed database in place. The same users come back with `role: "member"`, backfilled by the column default, and their `createdAt` timestamps unchanged; nothing was dropped or recreated: ```bash curl https://xyz.ewr.prisma.build/users ``` ```json no-copy [ { "id": "1", "email": "alice@prisma.io", "username": "alice", "name": "Alice", "role": "member", "createdAt": "2026-08-24T18:40:06.375Z" } ] ``` ## 8. Clean up (optional) [#8-clean-up-optional] The project keeps running until you remove it. Deleting it removes the service and the database, so the command asks you to repeat the project id (find it with `npx prisma@latest project list`): #### bun ```bash bunx prisma@latest project delete --confirm ``` #### pnpm ```bash pnpm dlx prisma@latest project delete --confirm ``` #### yarn ```bash yarn dlx prisma@latest project delete --confirm ``` #### npm ```bash npx prisma@latest project delete --confirm ``` ## Next steps [#next-steps] * [Learn Composer](https://www.prisma.io/docs/composer/getting-started): typed contracts between services, databases, storage, and scheduled jobs. * [Pick your framework](https://www.prisma.io/docs/guides): the same journey for Next.js, Nuxt, Astro, NestJS, TanStack Start, and more. * [Branching and previews](https://www.prisma.io/docs/compute/branching): every Git branch gets an isolated deployment. * [Learn the fundamentals](https://www.prisma.io/docs/orm/fundamentals/reading-data): reading, writing, relations, and transactions. * [Deploy on push](https://www.prisma.io/docs/compute/deploy-on-push): connect GitHub so every commit deploys itself, with a preview environment per branch. ## Related pages - [`Choose a Prisma ORM setup path`](https://www.prisma.io/docs/getting-started): Choose the fastest path to try Prisma ORM in a new or existing project. - [`Console`](https://www.prisma.io/docs/console): Learn how to use the Console to manage and integrate Prisma products into your application. - [`Introduction to Prisma ORM`](https://www.prisma.io/docs/prisma-orm): Prisma ORM 8 is the current release. - [`Local development`](https://www.prisma.io/docs/local-development): Run the whole Prisma stack on your machine, with your app on Bun, a local Prisma Postgres database, and local object storage. - [`Overview`](https://www.prisma.io/docs/cli): Prisma CLI reference # Choose a Prisma ORM setup path (/docs/getting-started) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Choose the fastest path to try Prisma ORM in a new or existing project. Location: Choose a Prisma ORM setup path Start with a quickstart if you want [Prisma ORM](https://www.prisma.io/docs/orm) to create the app. Use the existing-project path if you already have an app and database. Coming from an earlier version? [Coming from Prisma ORM 7](https://www.prisma.io/docs/orm/coming-from-prisma-orm-7) maps every Prisma ORM 7 API to its Prisma ORM 8 form, and [Release status](https://www.prisma.io/docs/orm/release-status) says where Prisma ORM 8 stands today. ## Start a new project [#start-a-new-project] #### bun ```bash bun create prisma@latest ``` #### pnpm ```bash pnpm create prisma@latest ``` #### yarn ```bash yarn create prisma@latest ``` #### npm ```bash npm create prisma@latest ``` The [create-prisma reference](https://www.prisma.io/docs/prisma-orm/create-prisma) lists every template and flag. - [Deploy the full Prisma stack](https://www.prisma.io/docs/full-stack-tutorial): The whole journey in one sitting: scaffold, Prisma Postgres, first query, and a Prisma Compute deploy. - [Quickstart with PostgreSQL](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql): Create the app, run it against a local Prisma Postgres from Composer or your own PostgreSQL, and run the first query. - [Quickstart with MongoDB](https://www.prisma.io/docs/prisma-orm/quickstart/mongodb): Create the app, connect a MongoDB deployment, apply the first migration, and run the first query. ```text Create a new [framework] application with Prisma ORM, seed it, and run it locally. If I have not told you which framework, stop and ask before scaffolding. Valid --template values: minimal (the default), next, hono, nuxt, astro, nest, svelte, tanstack-start, elysia. 1. Scaffold the app: `npm create prisma@latest -- my-app --template [framework] --provider postgres --yes`. 2. Get a database connection string: use the one I give you, or create a Prisma Postgres database with `npx create-db@latest` and show me the claim URL it prints. Export it as `DATABASE_URL` in the shell; the generated scripts read the environment variable, not `.env`. 3. From the project directory, apply the starter contract: `npm run db:init`. Sample users are seeded automatically on the app's first query; there is no separate seed script. 4. Edit the starter contract under `src/prisma/` into a small schema for my use case, then run `npm run contract:emit` and plan and apply the migration: `npx prisma@latest migration plan`, then `npx prisma@latest db migrate --yes`. Migration planning diffs the emitted contract, so the emit step is required. 5. Update the seed script under `src/prisma/` and the app routes to query the new schema, start `npm run dev` in the background (with `DATABASE_URL` exported), and verify with a request against the running app. For the `nest` template, if routes return 500s with `reading 'findAll'` in the logs, add explicit `@Inject()` tokens as shown in https://www.prisma.io/docs/guides/frameworks/nestjs.md. Use the installed Prisma ORM skills and the current Prisma docs: https://www.prisma.io/docs/llms.txt (append `.md` to any docs URL for a markdown version). ``` ## Add to an existing project [#add-to-an-existing-project] #### bun ```bash bunx prisma@latest orm init ``` #### pnpm ```bash pnpm dlx prisma@latest orm init ``` #### yarn ```bash yarn dlx prisma@latest orm init ``` #### npm ```bash npx prisma@latest orm init ``` - [Add to PostgreSQL](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/postgresql): Add Prisma ORM to an existing PostgreSQL app and infer a starter contract from the live schema. - [Add to MongoDB](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/mongodb): Add Prisma ORM to an existing MongoDB app and model the collections you want to query first. ```text Add Prisma ORM to this existing project. This flow is for PostgreSQL. If the project uses MongoDB, follow https://www.prisma.io/docs/prisma-orm/add-to-existing-project/mongodb.md instead; for other databases, stop and tell me. 1. Run `npx prisma@latest orm init --yes --target postgres --authoring psl` (the flags are required when the CLI cannot prompt). It writes `prisma.config.ts`, a starter contract and `db.ts` under `src/prisma/`, and installs dependencies. Then run `npx prisma@latest skills sync` to install the Prisma ORM skills. 2. Set `DATABASE_URL` in `.env` to my database. If I did not give you one, create a Prisma Postgres database with `npx create-db@latest`, put its connection string in `.env`, and show me the claim URL it prints so I can keep the database. 3. If the database already has tables, infer the contract from it: `npx prisma@latest contract infer`, then `npx prisma@latest contract emit`, then sign it with `npx prisma@latest db sign`. If the database is empty, keep the starter contract and run `npx prisma@latest db init`. 4. Write one query with the generated `db` client in an existing code path, run it, and show me the returned rows. Follow https://www.prisma.io/docs/prisma-orm/add-to-existing-project/postgresql.md and the installed Prisma ORM skills. ``` ## After setup [#after-setup] * Use the generated app scripts for the first run. * Open `prisma-8.md` or the installed Prisma ORM skills when you want agent-ready guidance inside the project. * Change the starter contract when you are ready to model your own data. * Open the [Prisma ORM overview](https://www.prisma.io/docs/orm) when you want the concepts behind the setup. ## Related pages - [`Console`](https://www.prisma.io/docs/console): Learn how to use the Console to manage and integrate Prisma products into your application. - [`Deploy the full Prisma stack`](https://www.prisma.io/docs/full-stack-tutorial): A single tutorial from empty directory to live URL, with Prisma Composer, Prisma ORM, and Prisma Postgres. - [`Introduction to Prisma ORM`](https://www.prisma.io/docs/prisma-orm): Prisma ORM 8 is the current release. - [`Local development`](https://www.prisma.io/docs/local-development): Run the whole Prisma stack on your machine, with your app on Bun, a local Prisma Postgres database, and local object storage. - [`Overview`](https://www.prisma.io/docs/cli): Prisma CLI reference # Get started with Prisma (/docs) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Prisma is a complete TypeScript stack with one workflow: **build** your app and run all of it on your machine, then **deploy** it to the Prisma platform with one command. Check out the [full-stack tutorial](https://www.prisma.io/docs/full-stack-tutorial). Here for the ORM? Jump straight to [Prisma ORM 7](https://www.prisma.io/docs/orm/v7) or [Prisma ORM 8](https://www.prisma.io/docs/orm), or check the [release status](https://www.prisma.io/docs/orm/release-status) first. ## Build Define the app in TypeScript and run everything locally before you ship. - **[Local development](https://www.prisma.io/docs/local-development)**: One command runs your whole app on your machine, with your services on Bun wired to local Postgres and local storage, and no cloud credentials. - **[Composer](https://www.prisma.io/docs/composer)** (Early Access): Declare your services and the resources they depend on: databases, jobs, buckets, secrets. - **[ORM](https://www.prisma.io/docs/orm)**: Model your data and query it with type safety, end to end. ## Deploy One deploy provisions everything on the Prisma platform and connects it. - **[Compute](https://www.prisma.io/docs/compute)**: Hosting for your services, next to your data. - **[Storage](https://www.prisma.io/docs/storage)**: S3-compatible object storage inside your project. - **[Postgres](https://www.prisma.io/docs/postgres)**: Managed PostgreSQL, provisioned during setup. - **[Deploy](https://www.prisma.io/docs/prisma-compute/deploy)**: Ship from a git push, the Console, or Composer. Every branch gets its own environment. One CLI serves the whole stack: `npx prisma@latest` drives the ORM and the Prisma platform, from migrations and local dev to deploys, databases, and buckets, for you and your coding agent. See the [CLI reference](https://www.prisma.io/docs/cli). ## Pick your framework Every guide runs the same journey with the same commands: scaffold, connect Prisma Postgres, run a real query, and deploy. SvelteKit and Deno don't deploy to Compute yet; their guides stop at a verified local run. - [Next.js](https://www.prisma.io/docs/guides/frameworks/nextjs) - [Hono](https://www.prisma.io/docs/guides/frameworks/hono) - [TanStack Start](https://www.prisma.io/docs/guides/frameworks/tanstack-start) - [NestJS](https://www.prisma.io/docs/guides/frameworks/nestjs) - [Astro](https://www.prisma.io/docs/guides/frameworks/astro) - [Nuxt](https://www.prisma.io/docs/guides/frameworks/nuxt) - [SvelteKit](https://www.prisma.io/docs/guides/frameworks/sveltekit) - [Bun](https://www.prisma.io/docs/guides/runtimes/bun) - [Elysia](https://www.prisma.io/docs/guides/frameworks/elysia) - [Deno](https://www.prisma.io/docs/guides/runtimes/deno) If you're using Express or another Node.js server, follow the [existing-project path](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/postgresql) instead. ## Prisma ORM 7 Prisma ORM 7 remains fully supported. Scaffold it with `npx create-prisma@stable`, or add it to an existing project with `npx prisma@prev init`. It pairs with Prisma Postgres and Prisma Compute the same way. When you're ready, Prisma ORM 8 is the upgrade path. - [Prisma ORM 7 setup paths](https://www.prisma.io/docs/v7/getting-started): All database quickstarts, plus the agent prompt - [Prisma ORM 7 quickstart](https://www.prisma.io/docs/v7/prisma-orm/quickstart/prisma-postgres): With Prisma Postgres, 5 min ## Other setups If you already have an app or a database, or need a single Prisma product on its own, each path below has a guide to follow and a prompt to hand to your agent. **Existing project, your own database, or a single product on its own** ### Add Prisma to an existing project Follow the guide: [PostgreSQL guide](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/postgresql) ```text Add Prisma ORM to this existing project. This flow is for PostgreSQL. If the project uses MongoDB, follow https://www.prisma.io/docs/prisma-orm/add-to-existing-project/mongodb.md instead; for other databases, stop and tell me. 1. Run `npx prisma@latest orm init --yes --target postgres --authoring psl` (the flags are required when the CLI cannot prompt). It writes `prisma.config.ts`, a starter contract and `db.ts` under `src/prisma/`, and installs dependencies. Then run `npx prisma@latest skills sync` to install the Prisma ORM skills. 2. Set `DATABASE_URL` in `.env` to my database. If I did not give you one, create a Prisma Postgres database with `npx create-db@latest`, put its connection string in `.env`, and show me the claim URL it prints so I can keep the database. 3. If the database already has tables, infer the contract from it: `npx prisma@latest contract infer`, then `npx prisma@latest contract emit`, then sign it with `npx prisma@latest db sign`. If the database is empty, keep the starter contract and run `npx prisma@latest db init`. 4. Write one query with the generated `db` client in an existing code path, run it, and show me the returned rows. Follow https://www.prisma.io/docs/prisma-orm/add-to-existing-project/postgresql.md and the installed Prisma ORM skills. ``` ### Prisma ORM with your own PostgreSQL database Follow the guide: [Quickstart](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql) ```text Create a new [framework] application with Prisma ORM against my existing PostgreSQL database. If I have not given you a connection string, stop and ask; do not invent one. Valid --template values: minimal (the default), next, hono, nuxt, astro, nest, svelte, tanstack-start, elysia. 1. Scaffold: `npm create prisma@latest -- my-app --template [framework] --provider postgres --yes`. 2. Export my connection string as `DATABASE_URL` in the shell; the generated scripts read the environment variable, not `.env`. From the project directory: `npm run db:init`, then start `npm run dev` in the background and verify the sample query returns data. Sample users are seeded automatically on the app's first query; there is no separate seed script. 3. Evolve the starter contract under `src/prisma/` into my schema, then run `npm run contract:emit`, `npx prisma@latest migration plan`, and `npx prisma@latest db migrate --yes`. Do not provision any hosted database. Use the installed Prisma ORM skills and https://www.prisma.io/docs/llms.txt for current docs. ``` ### Prisma ORM only (Prisma ORM 7) Follow the guide: [Quickstart](https://www.prisma.io/docs/v7/prisma-postgres/quickstart/prisma-orm) ```text Add Prisma ORM 7 to this project with my existing database. If I have not given you a database connection string and none exists in the project, stop and ask. 1. Run `npx prisma@prev init` (Prisma ORM 7). For an existing database, set DATABASE_URL in `.env` and introspect it with `npx prisma@prev db pull`; for a new schema, define models in `prisma/schema.prisma` and run `npx prisma@prev migrate dev --name init`. If migrate dev asks to reset the database, stop and ask me first. 2. Install the driver adapter for the database (Prisma ORM 7 requires one), e.g. `npm install @prisma/adapter-pg` for PostgreSQL, and pass it to `new PrismaClient({ adapter })`. Generate the client with `npx prisma@prev generate` and write one query in an existing code path. 3. Run the query (e.g. with `npx tsx`) and show me the output, the schema, and the query you added. Current docs: https://www.prisma.io/docs/orm/v7.md and https://www.prisma.io/docs/llms.txt. ``` ### Prisma Postgres only Follow the guide: [create-db guide](https://www.prisma.io/docs/postgres/npx-create-db) ```text Create a Prisma Postgres database for this project. 1. Run `npx create-db@latest`. It creates a temporary Prisma Postgres database without an account and prints a connection string plus a claim URL. 2. Put the connection string in `.env` as DATABASE_URL and wire it into whichever of Prisma ORM, Kysely, Drizzle, TypeORM, or node-postgres the project already uses (detect it from package.json; if none, ask me). Verify the connection with one trivial query such as `select 1`. 3. Remind me to open the claim URL to keep the database in my Prisma workspace. Current docs: https://www.prisma.io/docs/postgres.md. ``` ### Prisma Compute only Follow the guide: [Deploy guide](https://www.prisma.io/docs/prisma-compute/deploy) ```text Deploy this app to Prisma Compute using `npx prisma@latest`. Compute runs apps declared with Prisma Composer: your server code plus a small TypeScript declaration. Port the app following https://www.prisma.io/docs/composer/porting-an-app.md. SvelteKit and Deno are not supported yet; if the app is one of those, stop and tell me. 1. Install `@prisma/composer` and `@prisma/composer-prisma-cloud`, and pin `effect` in package.json to the exact version in `node_modules/@prisma/composer/package.json` (`"overrides": { "effect": "" }`). Then install the Composer skill with `npx prisma@latest skills sync`, and use it. 2. Declare the app: a `service.ts` with `compute({ name, deps, build })`, a `module.ts` that provisions it, and a `prisma-composer.config.ts`. Read the port from `service.port()` and bind 0.0.0.0. Replace other `process.env` reads with the service input schema, binding credentials like DATABASE_URL with `envSecret`. Composer does not build: produce one self-contained entry file per service (for example `esbuild --bundle --platform=node --format=esm --outfile=dist/server.mjs`), or use the framework build adapter (Next.js needs the `nextjs` adapter and `output: "standalone"`). 3. Verify locally: run the build, then `npx prisma@latest dev module.ts`, and curl the printed local URL. 4. Confirm I am signed in with `npx prisma@latest auth whoami`; if not, stop and ask me to run `npx prisma@latest auth login` (it opens a browser). 5. Deploy: run the build, then `npx prisma@latest deploy module.ts` with the app's env values (like DATABASE_URL) exported in the shell; the first deploy copies input values up to the deployment. Verify the printed public URL with curl. Current docs: https://www.prisma.io/docs/composer/porting-an-app.md and https://www.prisma.io/docs/prisma-compute/deploy.md. ``` If you're using MongoDB, follow the [MongoDB quickstart](https://www.prisma.io/docs/prisma-orm/quickstart/mongodb) or [add Prisma ORM to an existing MongoDB app](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/mongodb). If you work with [Kysely](https://www.prisma.io/docs/prisma-postgres/quickstart/kysely), [Drizzle](https://www.prisma.io/docs/prisma-postgres/quickstart/drizzle-orm), or [TypeORM](https://www.prisma.io/docs/prisma-postgres/quickstart/typeorm), follow the Prisma Postgres quickstart for that tool. ## Browse the docs This page hides the full navigation to keep the first run focused. These links open the full docs for each product. - [Prisma ORM](https://www.prisma.io/docs/orm): Prisma ORM 8, with Prisma ORM 7 docs - [Prisma Postgres](https://www.prisma.io/docs/postgres): The managed database - [Prisma Compute](https://www.prisma.io/docs/compute): Hosting and branching - [CLI reference](https://www.prisma.io/docs/cli): Every command and flag - [Guides](https://www.prisma.io/docs/guides): Frameworks and workflows - [AI tools](https://www.prisma.io/docs/ai): Skills, MCP, and prompts # Prisma with AI coding tools (/docs/ai) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Use Prisma with AI coding tools like Cursor, Codex, and ChatGPT Location: Prisma with AI coding tools Prisma ORM and Prisma Postgres work with AI coding agents through installable skills, an MCP server, and editor integrations. This page collects the setup guides, prompts, and tutorials for using them together. ## Get started [#get-started] Run the following command to bootstrap your database with a prompt: #### bun ```bash bunx --bun prisma@prev init --prompt "Create a habit tracker application" ``` #### pnpm ```bash pnpm dlx prisma@prev init --prompt "Create a habit tracker application" ``` #### yarn ```bash yarn dlx prisma@prev init --prompt "Create a habit tracker application" ``` #### npm ```bash npx prisma@prev init --prompt "Create a habit tracker application" ``` ## AI Coding Tools [#ai-coding-tools] Each guide covers setup and prompts for using Prisma in a specific AI editor or agent. * [Cursor](https://www.prisma.io/docs/ai/tools/cursor) - Define project-specific rules and use your schema as context to generate accurate queries and code. * [Codex](https://www.prisma.io/docs/ai/tools/codex) - Install the Prisma Codex plugin with Prisma ORM skills and the remote Prisma MCP server. * [Windsurf](https://www.prisma.io/docs/ai/tools/windsurf) - Automate your database workflows by generating schemas, queries, and seed data in this AI-powered editor. * [Github Copilot](https://www.prisma.io/docs/ai/tools/github-copilot) - Get Prisma-aware code suggestions, run CLI commands from chat, and query the Prisma docs. * [ChatGPT](https://www.prisma.io/docs/ai/tools/chatgpt) - Learn how to connect the Prisma MCP server to ChatGPT to manage your databases with natural language. ## Agent Skills [#agent-skills] AI agents often generate outdated Prisma v6 code. Install Prisma Skills to give your agent accurate, up-to-date v7 knowledge: CLI commands, Client API, upgrade guides, database setup, and Prisma Postgres workflows. #### bun ```bash bunx skills add prisma/skills ``` #### pnpm ```bash pnpm dlx skills add prisma/skills ``` #### yarn ```bash yarn dlx skills add prisma/skills ``` #### npm ```bash npx skills add prisma/skills ``` * [Available skills and setup](https://www.prisma.io/docs/ai/tools/skills) - See all available skills and learn how to install them. ## MCP server [#mcp-server] With Prisma's MCP server, your AI tool can take database actions on your behalf, such as provisioning a new Prisma Postgres instance, creating database backups, and executing SQL queries. ```json title="Integrate in AI tool" { "mcpServers": { "Prisma": { "url": "https://mcp.prisma.io/mcp" } } } ``` * [Capabilities and tools](https://www.prisma.io/docs/ai/tools/mcp-server#tools) - The full list of tools the Prisma MCP server exposes. * [Integrating in AI tools](https://www.prisma.io/docs/ai/tools/mcp-server#integrating-in-ai-tools) - Configuration for Cursor, Claude, Warp, and other AI tools. * [How we built it](https://www.prisma.io/blog/about-mcp-servers-and-how-we-built-one-for-prisma) - How the MCP protocol works and how the Prisma MCP server was built. ## Vibe Coding Tutorials [#vibe-coding-tutorials] Tutorials that build a full application from scratch with an AI coding assistant. * [Build a Linktree Clone SaaS](https://www.prisma.io/docs/ai/tutorials/linktree-clone) - Build a Linktree clone SaaS with Next.js, Prisma Postgres, and Clerk auth using AI assistance. ## Resources [#resources] * [Vibe Coding with Limits](https://www.prisma.io/blog/vibe-coding-with-limits-how-to-build-apps-in-the-age-of-ai) - How to Build Apps in the Age of AI * [Vibe Coding an E-commerce App](https://www.prisma.io/blog/vibe-coding-with-prisma-mcp-and-nextjs) - with Prisma MCP and Next.js * [Integrating the Vercel AI SDK](https://www.prisma.io/docs/guides/integrations/ai-sdk) - in a Next.js application ## Integrations [#integrations] * [Automate with Pipedream](https://pipedream.com/apps/prisma-management-api) - Connect Prisma Postgres to 2,800+ apps in automated workflows * [Firebase Studio](https://www.prisma.io/docs/guides/postgres/idx) - Prompt your application with Firebase Studio & Prisma Postgres ## Related pages - [`Choose a Prisma ORM setup path`](https://www.prisma.io/docs/getting-started): Choose the fastest path to try Prisma ORM in a new or existing project. - [`Console`](https://www.prisma.io/docs/console): Learn how to use the Console to manage and integrate Prisma products into your application. - [`Deploy the full Prisma stack`](https://www.prisma.io/docs/full-stack-tutorial): A single tutorial from empty directory to live URL, with Prisma Composer, Prisma ORM, and Prisma Postgres. - [`Introduction to Prisma ORM`](https://www.prisma.io/docs/prisma-orm): Prisma ORM 8 is the current release. - [`Local development`](https://www.prisma.io/docs/local-development): Run the whole Prisma stack on your machine, with your app on Bun, a local Prisma Postgres database, and local object storage. # auth (/docs/cli/auth) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. Location: CLI > auth Use `auth` commands to manage authentication for the platform commands. Signing in opens a browser flow and stores a session. Every platform command in that environment reuses that session. ## Usage [#usage] #### bun ```bash bunx prisma@latest auth login bunx prisma@latest auth whoami ``` #### pnpm ```bash pnpm dlx prisma@latest auth login pnpm dlx prisma@latest auth whoami ``` #### yarn ```bash yarn dlx prisma@latest auth login yarn dlx prisma@latest auth whoami ``` #### npm ```bash npx prisma@latest auth login npx prisma@latest auth whoami ``` ## Commands [#commands] | Command | Description | | ------------------------------------ | ----------------------------------------------------- | | `auth login` | Log in to your Prisma platform account (browser flow) | | `auth logout` | Clear stored authentication credentials | | `auth whoami` | Show the authenticated user and accessible workspace | | `auth workspace list` | List your workspace sessions | | `auth workspace use [id-or-name]` | Make one of your workspace sessions current | | `auth workspace logout ` | End one workspace session | `auth login` signs you in through the browser. Afterward, anything running in that environment inherits the session, including coding agents. For CI, set [`PRISMA_SERVICE_TOKEN`](https://www.prisma.io/docs/cli/environment-variables) instead. ## Related pages - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. - [`contract infer`](https://www.prisma.io/docs/cli/contract-infer): Infer a starter contract from an existing database. # branch (/docs/cli/branch) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. List platform branches for a project. Location: CLI > branch Use `branch` commands to inspect the platform branches of a project. The commands do not create anything on the platform. See [Branching](https://www.prisma.io/docs/compute/branching) for how platform branches work. ## Usage [#usage] #### bun ```bash bunx prisma@latest branch list ``` #### pnpm ```bash pnpm dlx prisma@latest branch list ``` #### yarn ```bash yarn dlx prisma@latest branch list ``` #### npm ```bash npx prisma@latest branch list ``` ## Commands [#commands] | Command | Description | | ------------- | --------------------------------------------- | | `branch list` | List platform branches for the linked project | ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. - [`contract infer`](https://www.prisma.io/docs/cli/contract-infer): Infer a starter contract from an existing database. # bucket (/docs/cli/bucket) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Create and manage object-store buckets. Location: CLI > bucket Use `bucket` commands to manage object-store buckets in a project. ## Usage [#usage] #### bun ```bash bunx prisma@latest bucket list bunx prisma@latest bucket create --name my-bucket ``` #### pnpm ```bash pnpm dlx prisma@latest bucket list pnpm dlx prisma@latest bucket create --name my-bucket ``` #### yarn ```bash yarn dlx prisma@latest bucket list yarn dlx prisma@latest bucket create --name my-bucket ``` #### npm ```bash npx prisma@latest bucket list npx prisma@latest bucket create --name my-bucket ``` ## Commands [#commands] | Command | Description | | ---------------------------------------- | ------------------------------------------------------------------------------------------------ | | `bucket list` | List object-store buckets | | `bucket create` | Create an object-store bucket (`--name ` sets the display name, auto-generated if omitted) | | `bucket delete ` | Delete a bucket and all its access keys | | `bucket key list ` | List access keys for a bucket | | `bucket key create ` | Create a bucket access key and print its one-time credentials | | `bucket key delete ` | Revoke and delete a bucket access key | ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. - [`contract infer`](https://www.prisma.io/docs/cli/contract-infer): Infer a starter contract from an existing database. # Configuration (/docs/cli/configuration) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Configure Prisma ORM CLI commands with prisma.config.ts and global flags. Location: CLI > Configuration Prisma ORM CLI commands read `prisma.config.ts` in your project root. The file has one section per part of the CLI. The Prisma ORM data commands read the `orm` section; the [agent skills commands](https://www.prisma.io/docs/cli/skills) read the `skills` section. ## Config file [#config-file] The outer `definePrismaConfig` comes from `prisma/config` and marks the file as a Prisma ORM 8 CLI config. A Prisma ORM 7 `prisma.config.ts` without that marker is rejected rather than misread. The import resolves from your project's `node_modules`, so `prisma` must be a local dependency. The `orm` section uses the config helper for your database. For PostgreSQL: ```typescript title="prisma.config.ts" import "dotenv/config"; import { definePrismaConfig } from "prisma/config"; import { defineConfig as ormConfig } from "@prisma/orm-postgres/config"; export default definePrismaConfig({ orm: ormConfig({ contract: "./prisma/contract.prisma", db: { connection: process.env["DATABASE_URL"]!, }, }), }); ``` For MongoDB projects, import the section helper from `@prisma/orm-mongo/config` instead. `defineConfig` from `@prisma/cli-engine` is the former name of `definePrismaConfig` and still works, so configs scaffolded by earlier release candidates keep evaluating. [`orm init`](https://www.prisma.io/docs/cli/orm-init) writes this file for you. Pass `--config` when your config file is not at `./prisma.config.ts`: #### bun ```bash bunx prisma@latest contract emit --config ./config/prisma.config.ts ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit --config ./config/prisma.config.ts ``` #### yarn ```bash yarn dlx prisma@latest contract emit --config ./config/prisma.config.ts ``` #### npm ```bash npx prisma@latest contract emit --config ./config/prisma.config.ts ``` ## Emit-only config [#emit-only-config] `contract emit` does not connect to a database, so the `orm` section can omit `db.connection`: ```typescript title="prisma.config.ts" import { definePrismaConfig } from "prisma/config"; import { defineConfig as ormConfig } from "@prisma/orm-postgres/config"; export default definePrismaConfig({ orm: ormConfig({ contract: "./prisma/contract.prisma", }), }); ``` Add `db.connection` before running commands such as `db verify`, `db sign`, `db init`, `db update`, `db schema`, `contract infer`, or `db migrate`. ## Extension packs [#extension-packs] Add extension control descriptors to the `orm` section when your contract uses extension-provided types: ```typescript title="prisma.config.ts" import { definePrismaConfig } from "prisma/config"; import { defineConfig as ormConfig } from "@prisma/orm-postgres/config"; import pgvector from "@prisma/orm-extension-pgvector/control"; export default definePrismaConfig({ orm: ormConfig({ contract: "./prisma/contract.prisma", extensions: [pgvector], db: { connection: process.env["DATABASE_URL"]!, }, }), }); ``` Re-run `contract emit` after changing extension packs, then update the matching runtime client. ## Agent skills [#agent-skills] The `skills` section controls the [agent skills commands](https://www.prisma.io/docs/cli/skills) and the staleness check: ```typescript title="prisma.config.ts" import { definePrismaConfig } from "prisma/config"; export default definePrismaConfig({ skills: { agents: ["claude", "cursor"], check: true, }, }); ``` | Field | What it does | | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `agents` | The agent harnesses `skills sync` writes and `skills list` reports: `claude`, `cursor`, `agents`, `devin`. An empty array records that no agent skills are wanted, and the next `skills sync` removes the copies already on disk. Default: all of them. | | `check` | Set `false` to stop commands reporting out-of-date skills, for everyone working in the project. Default: `true`. | [`init`](https://www.prisma.io/docs/cli/init) scaffolds this section for you. ## Database URLs [#database-urls] Database commands accept `--db `. If you omit it, Prisma ORM uses the database connection from `prisma.config.ts`. #### bun ```bash bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db verify --db "$DATABASE_URL" ``` ## Environment variables [#environment-variables] The variables the CLI reads, such as `PRISMA_DISABLE_TELEMETRY`, `PRISMA_SKILLS_CHECK`, and the `PRISMA_SERVICE_TOKEN` pair for CI, are listed on [Environment variables](https://www.prisma.io/docs/cli/environment-variables). `DATABASE_URL` is not one of them: your config file reads it, as in the example above. ## Output modes [#output-modes] Use the default text output when running commands locally. Use `--json` in CI or automation: #### bun ```bash bunx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### pnpm ```bash pnpm dlx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### yarn ```bash yarn dlx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### npm ```bash npx prisma@latest db verify --db "$DATABASE_URL" --json ``` For an AI agent that reads the output as text rather than parsing JSON, use `--format markdown`; see [Global flags](https://www.prisma.io/docs/cli/global-flags#output-formats). Use `--no-interactive` for scripts that must never pause for user input. Use `--confirm ` to grant a consent prompt non-interactively. For example, [`db update`](https://www.prisma.io/docs/cli/db-update) asks for the database name before a destructive change. ## JSON output [#json-output] In `--json` mode, commands emit newline-delimited JSON events. Progress events have `kind: "step-finished"`. The final event has `kind: "result"` and carries the `envelope` object your script branches on: * `envelope.ok`: `true` or `false`. * `envelope.result`: the command's data, when `ok` is `true`. * `envelope.error.code`: a dotted `NAMESPACE.SUBCODE`, for example `PROJECT.NOT_FOUND` or `SERVICE.PROJECT_SETUP_REQUIRED`. * `envelope.error.summary` and `envelope.error.why`: what failed and why it was rejected. * `envelope.nextActions`: machine-readable follow-up commands, so agents can drive the CLI. Branch on `envelope.error.code`, not the message text: codes are a stable contract, while message wording can change between releases. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. - [`contract infer`](https://www.prisma.io/docs/cli/contract-infer): Infer a starter contract from an existing database. # contract emit (/docs/cli/contract-emit) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Emit Prisma ORM contract artifacts. Location: CLI > contract emit `contract emit` reads your contract source (TypeScript or Prisma schema) and writes the generated artifacts used by the runtime, verification, and migration tooling. The command is offline. It does not need a database connection. ## Usage [#usage] #### bun ```bash bunx prisma@latest contract emit ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit ``` #### yarn ```bash yarn dlx prisma@latest contract emit ``` #### npm ```bash npx prisma@latest contract emit ``` ## Options [#options] | Option | What it does | | --------------------- | --------------------------------------------------------------------- | | `--output-path ` | Writes `contract.json` and `contract.d.ts` into a specific directory. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## What it creates [#what-it-creates] The command emits: * `contract.json`, the canonical machine-readable contract * `contract.d.ts`, the generated TypeScript contract declarations Do not edit these files by hand. Re-run `contract emit` after changing the contract source or extension pack list. ## Examples [#examples] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest contract emit --output-path ./generated bunx prisma@latest contract emit --json ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest contract emit --output-path ./generated pnpm dlx prisma@latest contract emit --json ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest contract emit --output-path ./generated yarn dlx prisma@latest contract emit --json ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest contract emit --output-path ./generated npx prisma@latest contract emit --json ``` ## Next steps [#next-steps] After emitting, choose the database workflow: * use [`db init`](https://www.prisma.io/docs/cli/db-init) for first-time bootstrap * use [`db update`](https://www.prisma.io/docs/cli/db-update) for direct reconciliation * use [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) for checked-in migrations * use [`db verify`](https://www.prisma.io/docs/cli/db-verify) to check drift ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract infer`](https://www.prisma.io/docs/cli/contract-infer): Infer a starter contract from an existing database. # contract infer (/docs/cli/contract-infer) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Infer a starter contract from an existing database. Location: CLI > contract infer `contract infer` inspects a live database and writes a starter PSL contract. An existing file at the output path is overwritten, with a warning. Use it when you are adding Prisma ORM to an existing database and want an initial contract to review and edit. ## Usage [#usage] #### bun ```bash bunx prisma@latest contract infer [--db "$DATABASE_URL"] ``` #### pnpm ```bash pnpm dlx prisma@latest contract infer [--db "$DATABASE_URL"] ``` #### yarn ```bash yarn dlx prisma@latest contract infer [--db "$DATABASE_URL"] ``` #### npm ```bash npx prisma@latest contract infer [--db "$DATABASE_URL"] ``` ## Options [#options] | Option | What it does | | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `--db ` | Connects to the database. Optional: without it the command uses `db.connection` from `prisma.config.ts`, and fails only when neither is set. | | `--output ` | Writes the inferred PSL contract to a specific path. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Examples [#examples] #### bun ```bash bunx prisma@latest contract infer --db "$DATABASE_URL" bunx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma bunx prisma@latest contract infer --db "$DATABASE_URL" --json ``` #### pnpm ```bash pnpm dlx prisma@latest contract infer --db "$DATABASE_URL" pnpm dlx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma pnpm dlx prisma@latest contract infer --db "$DATABASE_URL" --json ``` #### yarn ```bash yarn dlx prisma@latest contract infer --db "$DATABASE_URL" yarn dlx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma yarn dlx prisma@latest contract infer --db "$DATABASE_URL" --json ``` #### npm ```bash npx prisma@latest contract infer --db "$DATABASE_URL" npx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma npx prisma@latest contract infer --db "$DATABASE_URL" --json ``` ## What to review [#what-to-review] Inference gives you a starting point, not a finished design. Review: * model and field names * relation names * mapped database names * defaults, indexes, and constraints * extension-backed column types The command stops at `contract.prisma`. Follow it with the emit and sign steps: #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest db sign --db "$DATABASE_URL" bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db sign --db "$DATABASE_URL" pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest db sign --db "$DATABASE_URL" yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest db sign --db "$DATABASE_URL" npx prisma@latest db verify --db "$DATABASE_URL" ``` `db sign` is the handoff point where you record that the existing database matches the reviewed contract. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db init (/docs/cli/db-init) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Initialize a database from the current Prisma ORM contract. Location: CLI > db init `db init` bootstraps a database to match the current emitted contract and signs it. It creates everything the contract declares and the database does not have yet, using additive operations only. Structures already in place and compatible are left alone. A conflict that would need a destructive change stops the run. ## Usage [#usage] #### bun ```bash bunx prisma@latest db init --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db init --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db init --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db init --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--db ` | Connects to the database. | | `--dry-run` | Shows planned operations without applying them. | | `--advance-ref ` | Advances the named [ref](https://www.prisma.io/docs/cli/migration-ref) to the post-command contract hash. Without it, `db init` advances `db` when `--db` is omitted, and advances nothing when `--db` is passed. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Behavior [#behavior] `db init` is intended for bootstrap work. It creates missing structures needed by the contract and writes the contract marker after the database matches. ### How the db ref moves [#how-the-db-ref-moves] Run without `--db`, `db init` takes the connection from `db.connection` in `prisma.config.ts` and advances the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` to the contract it just applied. Pass `--db` and that advancement is suppressed, even when the URL is the same one the config holds. Pass `--advance-ref db` alongside `--db` to get it back. The `db` ref is what [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) uses as its starting point when you do not pass `--from`. Passing `--db` only suppresses the advancement; it never removes a `db` ref that already exists. So a loop that always passes `--db` without `--advance-ref db` leaves the ref wherever it was last set, and the next `migration plan` starts from that stale contract. If the ref was never created, `migration plan` plans from an empty database while `migrations/app/` is empty, and refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` once migrations exist on disk. Run a dry run first when you are not working with a disposable local database: #### bun ```bash bunx prisma@latest db init --db "$DATABASE_URL" --dry-run ``` #### pnpm ```bash pnpm dlx prisma@latest db init --db "$DATABASE_URL" --dry-run ``` #### yarn ```bash yarn dlx prisma@latest db init --db "$DATABASE_URL" --dry-run ``` #### npm ```bash npx prisma@latest db init --db "$DATABASE_URL" --dry-run ``` ## Examples [#examples] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest db init --db "$DATABASE_URL" --advance-ref db bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db init --db "$DATABASE_URL" --advance-ref db pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest db init --db "$DATABASE_URL" --advance-ref db yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest db init --db "$DATABASE_URL" --advance-ref db npx prisma@latest db verify --db "$DATABASE_URL" ``` #### bun ```bash bunx prisma@latest db init --db "$DATABASE_URL" --dry-run --json ``` #### pnpm ```bash pnpm dlx prisma@latest db init --db "$DATABASE_URL" --dry-run --json ``` #### yarn ```bash yarn dlx prisma@latest db init --db "$DATABASE_URL" --dry-run --json ``` #### npm ```bash npx prisma@latest db init --db "$DATABASE_URL" --dry-run --json ``` ## When to use db update instead [#when-to-use-db-update-instead] Use [`db update`](https://www.prisma.io/docs/cli/db-update) when the database already exists and you want Prisma ORM to reconcile it with a changed contract. Use [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) when you want a reviewable migration package in version control. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db migrate (/docs/cli/db-migrate) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Apply pending Prisma ORM migrations. Location: CLI > db migrate `db migrate` applies pending on-disk migrations to advance the database. It walks every contract space (app and extensions) and applies migrations in canonical order: extensions alphabetically, then the app. It applies only the migrations that exist on disk and never generates new operations. Use it from a controlled deployment step after reviewing migration packages. ## Usage [#usage] #### bun ```bash bunx prisma@latest db migrate --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db migrate --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db migrate --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--db ` | Connects to the database. | | `--to ` | Applies migrations up to a target contract (hash, prefix, ref name, migration directory name, `^`, or `./path`). | | `--advance-ref ` | Advances the named [ref](https://www.prisma.io/docs/cli/migration-ref) to the post-apply marker after success. | | `--show` | Previews the migration route without applying (read-only). | | `--from ` | Sets the from-state for the `--show` preview: `@contract` (the emitted contract), `@db` (the database's current marker), a hash, a ref name, or a migration directory. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Recommended flow [#recommended-flow] #### bun ```bash bunx prisma@latest migration status --db "$DATABASE_URL" bunx prisma@latest db migrate --db "$DATABASE_URL" bunx prisma@latest migration status --db "$DATABASE_URL" bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest migration status --db "$DATABASE_URL" pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" pnpm dlx prisma@latest migration status --db "$DATABASE_URL" pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest migration status --db "$DATABASE_URL" yarn dlx prisma@latest db migrate --db "$DATABASE_URL" yarn dlx prisma@latest migration status --db "$DATABASE_URL" yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest migration status --db "$DATABASE_URL" npx prisma@latest db migrate --db "$DATABASE_URL" npx prisma@latest migration status --db "$DATABASE_URL" npx prisma@latest db verify --db "$DATABASE_URL" ``` Run `migration status` before and after applying migrations to see what changed. ## Previewing the route [#previewing-the-route] `--show` prints the route `db migrate` would take without touching the database: #### bun ```bash bunx prisma@latest db migrate --show bunx prisma@latest db migrate --show --from @contract --to production ``` #### pnpm ```bash pnpm dlx prisma@latest db migrate --show pnpm dlx prisma@latest db migrate --show --from @contract --to production ``` #### yarn ```bash yarn dlx prisma@latest db migrate --show yarn dlx prisma@latest db migrate --show --from @contract --to production ``` #### npm ```bash npx prisma@latest db migrate --show npx prisma@latest db migrate --show --from @contract --to production ``` ## Applying to a target [#applying-to-a-target] If your project uses named [refs](https://www.prisma.io/docs/cli/migration-ref), apply up to a target ref: #### bun ```bash bunx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### pnpm ```bash pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### yarn ```bash yarn dlx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### npm ```bash npx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` Manage refs with [`migration ref`](https://www.prisma.io/docs/cli/migration-ref). ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db schema (/docs/cli/db-schema) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Inspect a live database schema. Location: CLI > db schema `db schema` reads the live database schema and prints it as a tree, or as the result document with `--json`. The command is always read-only: it never writes a file and never changes the database. Use it when you need to inspect what Prisma ORM sees in the database before inferring, signing, updating, or debugging drift. ## Usage [#usage] #### bun ```bash bunx prisma@latest db schema --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db schema --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db schema --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db schema --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ----------------- | ------------------------------------------------------ | | `--db ` | Connects to the database. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints machine-readable schema output. | ## Examples [#examples] #### bun ```bash bunx prisma@latest db schema --db "$DATABASE_URL" bunx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json ``` #### pnpm ```bash pnpm dlx prisma@latest db schema --db "$DATABASE_URL" pnpm dlx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json ``` #### yarn ```bash yarn dlx prisma@latest db schema --db "$DATABASE_URL" yarn dlx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json ``` #### npm ```bash npx prisma@latest db schema --db "$DATABASE_URL" npx prisma@latest db schema --db "$DATABASE_URL" --json > schema.json ``` ## Related commands [#related-commands] Use [`contract infer`](https://www.prisma.io/docs/cli/contract-infer) when you want to turn a live schema into a starter PSL contract. Use [`db verify`](https://www.prisma.io/docs/cli/db-verify) when you want to compare the live schema with the emitted contract. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db sign (/docs/cli/db-sign) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Sign a database with the current Prisma ORM contract. Location: CLI > db sign `db sign` verifies that the live database satisfies the emitted contract and, if so, writes or updates the database signature. The signature records that this database instance matches a specific contract version. It is idempotent and safe to run in CI or a deployment pipeline. Use it after importing or inferring an existing schema, or after a deployment flow that already applied the required database changes. After a successful signature, `db sign` also stores the signed contract as a snapshot and points the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` at it, so the next [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) starts from the state you just signed instead of from an empty database. Unlike `db init` and `db update`, passing `--db` does not turn this off, because you normally sign the real database. Pass `--no-advance-ref` when you do not want the command to write a ref or a snapshot, for example in a deployment pipeline. ## Usage [#usage] #### bun ```bash bunx prisma@latest db sign --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db sign --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db sign --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db sign --db "$DATABASE_URL" ``` ## Options [#options] | Argument or option | What it does | | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | `[contract]` | Signs against a specific contract reference (hash, prefix, ref name, or migration directory name) instead of the emitted contract. | | `--db ` | Connects to the database. | | `--contract ` | The contract reference as a flag. Also accepts the `^` and `./path` forms that the positional argument does not. | | `--advance-ref ` | Advances this ref instead of `db` after a successful signature. | | `--no-advance-ref` | Signs without writing any ref or snapshot. Cannot be combined with `--advance-ref`. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. It includes `advancedRef` with the ref name and contract hash, or `null` when no ref was written. | ## Exit codes [#exit-codes] | Code | Meaning | | ---- | --------------------------------------------------------------------------------------------------------- | | `0` | The database was signed. | | `2` | The command could not run: unresolvable contract reference, no emitted contract, or unreachable database. | | `4` | Schema verification failed and no signature was written. | ## Example [#example] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest db sign --db "$DATABASE_URL" bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db sign --db "$DATABASE_URL" pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest db sign --db "$DATABASE_URL" yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest db sign --db "$DATABASE_URL" npx prisma@latest db verify --db "$DATABASE_URL" ``` ## Adopting an existing database [#adopting-an-existing-database] After [`contract infer`](https://www.prisma.io/docs/cli/contract-infer) and `contract emit`, one `db sign` is enough to hand the database over to Prisma ORM: #### bun ```bash bunx prisma@latest db sign --db "$DATABASE_URL" bunx prisma@latest migration plan --name add-users-bio ``` #### pnpm ```bash pnpm dlx prisma@latest db sign --db "$DATABASE_URL" pnpm dlx prisma@latest migration plan --name add-users-bio ``` #### yarn ```bash yarn dlx prisma@latest db sign --db "$DATABASE_URL" yarn dlx prisma@latest migration plan --name add-users-bio ``` #### npm ```bash npx prisma@latest db sign --db "$DATABASE_URL" npx prisma@latest migration plan --name add-users-bio ``` The plan starts from the signed contract, so it contains only the change you made after signing. Because `migrations/app/` is still empty, that first plan also writes a baseline package that records the schema you adopted; see [the automatic baseline](https://www.prisma.io/docs/cli/migration-plan#the-automatic-baseline). ## When to use it [#when-to-use-it] Use `db sign` only after you believe the live database already matches the emitted contract. It is common after: * `contract infer` for a brownfield database * a manually reviewed migration flow * a database restore that you need to mark as matching the current contract Do not use `db sign` to hide drift. If verification fails, fix the contract or database first. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db update (/docs/cli/db-update) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Update a database to match the current Prisma ORM contract. Location: CLI > db update `db update` compares the live database with the emitted contract and applies the changes that close the gap, whether or not the database was bootstrapped with `db init`. Use it for direct reconciliation when you do not need a checked-in migration package. ## Usage [#usage] #### bun ```bash bunx prisma@latest db update --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db update --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db update --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db update --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--db ` | Connects to the database. | | `--dry-run` | Shows planned operations without applying them. | | `--to ` | Updates to a specific contract (hash, prefix, ref name, migration directory name, or `./path`). | | `--advance-ref ` | Advances the named [ref](https://www.prisma.io/docs/cli/migration-ref) to the post-command contract hash. Without it, `db update` advances `db` when `--db` is omitted, and advances nothing when `--db` is passed. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## How the db ref moves [#how-the-db-ref-moves] Run without `--db`, `db update` takes the connection from `db.connection` in `prisma.config.ts` and advances the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` to the contract it just applied. Pass `--db` and that advancement is suppressed, even when the URL is the same one the config holds. Pass `--advance-ref db` alongside `--db` to get it back. The `db` ref is what [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) uses as its starting point when you do not pass `--from`. Passing `--db` only suppresses the advancement; it never removes a `db` ref that already exists. So a loop that always passes `--db` without `--advance-ref db` leaves the ref wherever it was last set, and the next `migration plan` starts from that stale contract. If the ref was never created, `migration plan` plans from an empty database while `migrations/app/` is empty, and refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` once migrations exist on disk. ## Destructive changes need consent [#destructive-changes-need-consent] An operation that would destroy data is applied only with your consent: the command asks you to type the database name. In a CI job or a run with `--no-interactive`, where the command cannot ask, pass the consent as `--confirm ` instead: #### bun ```bash bunx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb ``` #### pnpm ```bash pnpm dlx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb ``` #### yarn ```bash yarn dlx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb ``` #### npm ```bash npx prisma@latest db update --db "$DATABASE_URL" --no-interactive --confirm appdb ``` ## Recommended flow [#recommended-flow] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest db update --db "$DATABASE_URL" --dry-run bunx prisma@latest db update --db "$DATABASE_URL" --advance-ref db bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db update --db "$DATABASE_URL" --dry-run pnpm dlx prisma@latest db update --db "$DATABASE_URL" --advance-ref db pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest db update --db "$DATABASE_URL" --dry-run yarn dlx prisma@latest db update --db "$DATABASE_URL" --advance-ref db yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest db update --db "$DATABASE_URL" --dry-run npx prisma@latest db update --db "$DATABASE_URL" --advance-ref db npx prisma@latest db verify --db "$DATABASE_URL" ``` Use `--dry-run` before applying changes in shared environments. ## When to use migrations instead [#when-to-use-migrations-instead] For reviewable database changes in version control, use [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) and [`db migrate`](https://www.prisma.io/docs/cli/db-migrate). Use `db update` for local development, preview environments, and workflows where direct reconciliation is acceptable. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # db verify (/docs/cli/db-verify) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Verify a database against the current Prisma ORM contract. Location: CLI > db verify `db verify` checks whether the database marker and live schema match your emitted contract. It verifies the marker first, then checks the schema. Use it in CI and deployment checks before application code that depends on a contract reaches users. ## Usage [#usage] #### bun ```bash bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db verify --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ----------------- | --------------------------------------------------------------------------- | | `--db ` | Connects to the database. | | `--marker-only` | Checks only the database marker. | | `--schema-only` | Checks only whether the live schema satisfies the contract. | | `--strict` | Fails if the database includes schema elements not present in the contract. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints machine-readable output. | ## Exit codes [#exit-codes] | Code | Meaning | | ---- | ---------------------------------------------------------------------------------------------- | | `0` | The database matches the contract. | | `2` | The check could not run: conflicting mode flags, no emitted contract, or unreachable database. | | `4` | Drift or a marker finding. | ## Examples [#examples] #### bun ```bash bunx prisma@latest db verify --db "$DATABASE_URL" bunx prisma@latest db verify --db "$DATABASE_URL" --strict bunx prisma@latest db verify --db "$DATABASE_URL" --schema-only bunx prisma@latest db verify --db "$DATABASE_URL" --marker-only ``` #### pnpm ```bash pnpm dlx prisma@latest db verify --db "$DATABASE_URL" pnpm dlx prisma@latest db verify --db "$DATABASE_URL" --strict pnpm dlx prisma@latest db verify --db "$DATABASE_URL" --schema-only pnpm dlx prisma@latest db verify --db "$DATABASE_URL" --marker-only ``` #### yarn ```bash yarn dlx prisma@latest db verify --db "$DATABASE_URL" yarn dlx prisma@latest db verify --db "$DATABASE_URL" --strict yarn dlx prisma@latest db verify --db "$DATABASE_URL" --schema-only yarn dlx prisma@latest db verify --db "$DATABASE_URL" --marker-only ``` #### npm ```bash npx prisma@latest db verify --db "$DATABASE_URL" npx prisma@latest db verify --db "$DATABASE_URL" --strict npx prisma@latest db verify --db "$DATABASE_URL" --schema-only npx prisma@latest db verify --db "$DATABASE_URL" --marker-only ``` Use JSON output in automation: #### bun ```bash bunx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### pnpm ```bash pnpm dlx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### yarn ```bash yarn dlx prisma@latest db verify --db "$DATABASE_URL" --json ``` #### npm ```bash npx prisma@latest db verify --db "$DATABASE_URL" --json ``` ## What failures mean [#what-failures-mean] | Failure | Meaning | | ------------------ | -------------------------------------------------------------------------------------------- | | Marker mismatch | The database was not signed for the emitted contract, or the contract changed after signing. | | Schema mismatch | The live database does not satisfy the emitted contract. | | Strict mismatch | The database has extra schema elements not present in the contract. | | Extension mismatch | The contract requires an extension that is not wired in the config. | Fix the database or contract, emit again if needed, then verify again. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # deploy (/docs/cli/deploy) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Deploy a Composer application to Prisma Compute, to production or an isolated stage. Location: CLI > deploy `deploy` deploys a [Prisma Composer](https://www.prisma.io/docs/composer) application to [Prisma Compute](https://www.prisma.io/docs/compute). It takes an `` argument: the module whose default export is the application root, typically `module.ts`. The command streams the deploy pipeline's own output to the terminal. `deploy` and [`dev`](https://www.prisma.io/docs/cli/dev) are root-level commands of the unified Prisma CLI. There is no `composer` command group. By default, the command uses the credentials from your existing `auth login` session. In CI or other headless environments, set `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` instead. See [Deploying](https://www.prisma.io/docs/composer/deploying#credentials) for details. The first deploy of an app creates its project in your workspace, and a new project needs a region. Set it once, either as `prismaCloud({ region: 'us-east-1' })` in your deploy config or as the `PRISMA_REGION` environment variable; without one, the deploy stops with `project "" does not exist yet and no deploy region is configured`. A project that already exists keeps its region and needs neither. The region ids are listed under [Limitations](https://www.prisma.io/docs/compute/limitations). The `deploy` command does not build your application. Run your build command before deploying. ## Usage [#usage] #### bun ```bash bunx prisma@latest deploy module.ts bunx prisma@latest deploy module.ts --stage feat-auth ``` #### pnpm ```bash pnpm dlx prisma@latest deploy module.ts pnpm dlx prisma@latest deploy module.ts --stage feat-auth ``` #### yarn ```bash yarn dlx prisma@latest deploy module.ts yarn dlx prisma@latest deploy module.ts --stage feat-auth ``` #### npm ```bash npx prisma@latest deploy module.ts npx prisma@latest deploy module.ts --stage feat-auth ``` ## Flags [#flags] | Flag | Description | | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--name ` | Override the application name for this deploy. It defaults to the name of the exported application, and that name selects the project in your workspace: a project this module deployed before is reused, and a same-name project whose hosted state cannot be verified stops the deploy with `HostedStateBootstrapError`, so pass `--name` when the default would land in a project you did not mean to deploy into | | `--stage ` | Deploy scope to target; omit for production | | `--report ` | Write the deploy's outcome as JSON to this path: resources, preview URLs, and the failure cause. Also settable as `PRISMA_COMPOSER_REPORT_FILE` | | `--build-id ` | Join the deploy record your CI already created rather than letting the target create one | ## Global flags [#global-flags] The Prisma CLI's global flags also apply: `--format`, `--json`, `--log-level`, `--verbose`, `--quiet`, `--yes`, `--confirm`, `--interactive`, `--color`, and `--config`. ## Environment variables [#environment-variables] | Variable | Description | | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `PRISMA_SERVICE_TOKEN` | A workspace service token from the [Prisma Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=cli), for CI and other headless environments. When unset, the command uses your stored `auth login` session | | `PRISMA_WORKSPACE_ID` | The workspace ID from the workspace's settings; pair it with the service token | | `PRISMA_REGION` | The region for a project this deploy creates; `prismaCloud({ region })` in the deploy config wins when both are set. Ignored once the project exists | | `PRISMA_COMPOSER_REPORT_FILE` | Path to write the deploy's JSON outcome report; the `--report` flag wins when both are set | ## Tearing down and log tailing [#tearing-down-and-log-tailing] The unified CLI has no `destroy` or `log` command. Both operations are available in-process through the control API below: `destroy` takes an explicit target (`{ kind: 'production' }` or `{ kind: 'stage', stage }`), and `log` tails a locally running application. ## The control API [#the-control-api] Everything the CLI does is also callable in-process, from `@prisma/composer/control`: typed `deploy`, `destroy`, `dev`, and `log` operations that return structured results instead of printing and exiting: ```ts import { deploy } from '@prisma/composer/control'; const result = await deploy({ entry: 'module.ts', stage: 'pr-42' }); if (!result.ok) console.error(result.failure.message); ``` Operations return `{ ok: true, value }` or `{ ok: false, failure }`. Failures come back as structured errors with a dotted `failure.code` and the same fix-naming `message` the CLI renders. The deploy engine's live output still streams to your process's stdio; the operations do not capture it. The operations authenticate with `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` only. They do not read the session stored by `auth login`, so a script that runs fine next to the CLI's `deploy` fails under the control API with `environment variable PRISMA_WORKSPACE_ID is required` until both variables are exported. ## Next steps [#next-steps] * [`dev`](https://www.prisma.io/docs/cli/dev): run the same application locally, with no credentials. * [Getting started](https://www.prisma.io/docs/composer/getting-started): the commands in a working flow. * [Deploying](https://www.prisma.io/docs/composer/deploying): stages, CI, and what a deploy prints. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # dev (/docs/cli/dev) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Bring a Composer application up entirely on this machine, with no cloud credentials. Location: CLI > dev `dev` brings a [Prisma Composer](https://www.prisma.io/docs/composer) application up entirely on this machine. It takes an `` argument: the module whose default export is the application root, typically `module.ts`. The command runs credential-free against local emulators standing in for Prisma Compute and Prisma Postgres, watches the built output, and restarts a service when its build changes. See [Local development](https://www.prisma.io/docs/composer/local-development). `dev` and [`deploy`](https://www.prisma.io/docs/cli/deploy) are root-level commands of the unified Prisma CLI. There is no `composer` command group. Like `deploy`, `dev` runs your *built* output, so build first. ## Usage [#usage] #### bun ```bash bunx prisma@latest dev module.ts bunx prisma@latest dev module.ts --fresh ``` #### pnpm ```bash pnpm dlx prisma@latest dev module.ts pnpm dlx prisma@latest dev module.ts --fresh ``` #### yarn ```bash yarn dlx prisma@latest dev module.ts yarn dlx prisma@latest dev module.ts --fresh ``` #### npm ```bash npx prisma@latest dev module.ts npx prisma@latest dev module.ts --fresh ``` ## Flags [#flags] | Flag | Description | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `--name ` | Override the application name for the local dev instance | | `--fresh` | Destroy the dev stack and wipe the dev state directory before starting. In this release the flag fails for apps with a database; see [Local development](https://www.prisma.io/docs/composer/local-development#whats-local-vs-whats-real) for the manual reset | `dev` needs no credentials or environment variables; local runs never talk to the platform. To tail the running application's merged logs, use the `log` operation of the [control API](https://www.prisma.io/docs/cli/deploy#the-control-api); the unified CLI has no `log` command. ## Next steps [#next-steps] * [Local development](https://www.prisma.io/docs/composer/local-development): warm restarts, `--fresh`, and what persists. * [`deploy`](https://www.prisma.io/docs/cli/deploy): the same application, on Prisma Compute. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # Environment variables (/docs/cli/environment-variables) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. The environment variables the Prisma CLI reads, what each one does, and the release that added it. Location: CLI > Environment variables The `prisma` command reads these environment variables. Set them in your shell profile or in your CI configuration. For one command, put the variable in front of it, as in this [`contract emit`](https://www.prisma.io/docs/cli/contract-emit) run: ```bash title="Terminal" PRISMA_DISABLE_TELEMETRY=1 npx prisma@latest contract emit ``` In PowerShell, set it for the session: ```powershell title="PowerShell" $env:PRISMA_DISABLE_TELEMETRY = "1" npx prisma@latest contract emit ``` The CLI does not read `.env` files or `DATABASE_URL` itself. Your `prisma.config.ts` does that, and the one [`orm init`](https://www.prisma.io/docs/cli/orm-init) writes already loads `.env`; see [Configuration](https://www.prisma.io/docs/cli/configuration#config-file). > [!NOTE] > If you used the > > `prisma-next` > > preview command > > The `prisma` command ignores every `PRISMA_NEXT_*` variable, including `PRISMA_NEXT_DISABLE_TELEMETRY`. Drop the `NEXT_` part in shell profiles and CI: `PRISMA_NEXT_DISABLE_TELEMETRY` becomes `PRISMA_DISABLE_TELEMETRY`. > > Your `prisma-next` telemetry opt-out does not carry over either, so the one-time telemetry notice prints again. Run `prisma telemetry disable` to opt out. The `prisma` command stores that choice in `~/.config/prisma/config.json` (Windows: `%APPDATA%\prisma\config.json`). "Since" is the first `prisma` release that reads the variable. | Variable | What it does | Since | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | | `PRISMA_DISABLE_TELEMETRY` | Set to `1` to turn off anonymous [CLI telemetry](https://www.prisma.io/docs/cli/telemetry). Empty, `0`, and `false` leave it on. | 8.0.0-rc.1 | | `DO_NOT_TRACK` | Set to `1` to turn off telemetry. Other values do nothing. | 8.0.0-rc.1 | | `PRISMA_DEBUG` | Set to `1` to print the CLI's debug output to stderr. | 8.0.0-rc.1 | | `PRISMA_SKILLS_CHECK` | Set to `0` to silence the notice that your project's [agent skills](https://www.prisma.io/docs/cli/skills) are out of date. | 8.0.0-rc.9 | | `PRISMA_SERVICE_TOKEN` | A service token for a Prisma Platform workspace, created in the [Prisma Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=cli). Only the [Platform commands](https://www.prisma.io/docs/cli#platform-commands) such as `auth`, `project`, and `deploy` use it, in place of a browser login, even if you are also logged in. | 8.0.0-rc.1 | | `PRISMA_WORKSPACE_ID` | The ID of the workspace the service token belongs to, from the workspace's settings in the Prisma Console. Set it alongside the token. | 8.0.0-rc.1 | | `NO_COLOR` | Set to any value to turn off colored output. The [`--color` and `--no-color` flags](https://www.prisma.io/docs/cli/global-flags) override it. | 8.0.0-rc.1 | | `CI` | Set to any value except `false` to mark the run as CI: no telemetry, no skills notice, and no interactive prompts. `CI=false` forces the non-CI behavior even when a CI system set it. | 8.0.0-rc.1 | Agent skills are files in your project, in `.claude/skills` and similar folders, that teach AI coding agents about Prisma. Silencing the notice does not update them; `prisma skills sync` does. You rarely need to set `CI` yourself: the CLI also detects the variables that CI providers such as GitHub Actions and GitLab CI set. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # Error reference (/docs/cli/error-reference) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Every structured error code the unified Prisma CLI can emit, by namespace, with the condition that raises it. Location: CLI > Error reference Every user-facing error the unified Prisma CLI emits is a structured envelope identified by a dotted `NAMESPACE.SUBCODE` code (see [Error Conventions](https://github.com/prisma/prisma-cli/blob/main/docs/product/error-conventions.md) and [ADR 0003](https://github.com/prisma/prisma-cli/blob/main/docs/architecture/adrs/0003-structured-output-and-errors.md)). This page lists every published code. Each code anchors as `#` — the fragment an emitted error's `docsUrl` resolves to. This page is generated from the canonical registry in the `prisma/prisma-cli` repository, whose CI requires every code in production source to be documented before it ships. Recognize an error programmatically by running with `--json` and matching on `error.code` in the emitted envelope — never on message text. Envelopes carry `message`, and optionally `why`, `fix`, `where`, `meta`, `cause`, `nextActions`, and `docsUrl`. Most codes on this page are expected failures. Some are warn-severity diagnostics that ride a successful run: the command completes and exits `0`, and the diagnostic carries the code (the entry says so where it applies). The process exit-code contract is in [Error Conventions](https://github.com/prisma/prisma-cli/blob/main/docs/product/error-conventions.md). Every code on this page is assigned where the error is raised, and this page lists every code the CLI can emit. No boundary invents a code from a server response or rewrites one on the way out, so an error's code never depends on which command you reached the failure through. When a REST API request fails, the CLI raises the domain's registered `*.API_ERROR` code and carries the API's own code and HTTP status in `meta.apiCode` and `meta.status`, where they are data you can read rather than a code you have to guess at. Namespaces: | Namespace | Covers | | ---------- | -------------------------------------------------------------------------------------------------- | | `AUTH` | Workspace authentication and sessions (`prisma auth`, credential resolution) | | `BRANCH` | Branch listing (`prisma branch`) | | `BUCKET` | Bucket and bucket-key management (`prisma bucket`) | | `CLI` | Engine-level invocation: arguments, config loading, prompts, consent, credentials, child processes | | `FEEDBACK` | Sending product feedback (`prisma feedback`) | | `GIT` | Git repository connections (`prisma git`) | | `INIT` | Project initialization diagnostics (`prisma init`) | | `POSTGRES` | Database management (`prisma postgres`) | | `PROJECT` | Project and environment management (`prisma project`) | | `SERVICE` | Deployed service management (`prisma service`) | | `SKILLS` | Agent-skill delivery (`prisma skills`) | ## AUTH [#auth] ### AUTH.CREDENTIAL_WORKSPACE_MISMATCH [#AUTH.CREDENTIAL_WORKSPACE_MISMATCH] A credential's `workspace_id` claim disagrees with the workspace it is being stored under — raised by every CredentialManager (the CLI's file-backed manager and the engine's in-memory one) both when `createSession` receives a token claiming a different workspace and when a rotated token written back during refresh would re-scope an existing session. The fix is to run `prisma auth login` again and pick the intended workspace. Meta: none. ### AUTH.LOGIN_WORKSPACE_UNKNOWN [#AUTH.LOGIN_WORKSPACE_UNKNOWN] `prisma auth login` completed the browser sign-in but the minted credential carries no `workspace_id` claim, so no workspace session can be keyed by it. The fix is to sign in again and pick a workspace in the browser. Meta: none. ### AUTH.LOGIN_DENIED [#AUTH.LOGIN_DENIED] The OAuth callback reported `access_denied`. Authorization was not granted; this is an expected refusal, not a CLI crash. No session is created or cleared. Run `prisma auth login` again only to grant access intentionally. The callback description is not echoed. Meta: none. ### AUTH.NO_SESSION_FOR_WORKSPACE [#AUTH.NO_SESSION_FOR_WORKSPACE] A workspace reference matched none of the stored workspace sessions — raised by the command-side ref resolver behind `prisma auth workspace use` and `prisma auth workspace logout` (exact id match first, then case-insensitive name match), and by the credential managers when a session operation names a workspace with no stored record. Sessions are created only by `prisma auth login`, so the suggested fix is to sign in and pick that workspace in the browser; the workspace reference appears in the message, not in meta. Meta: none. ### AUTH.NO_WORKSPACE_SESSIONS [#AUTH.NO_WORKSPACE_SESSIONS] `prisma auth workspace use` was run with zero stored workspace sessions, so there is nothing to select among — the command only selects, it never creates a session or opens a browser. The fix is to run `prisma auth login` first. Meta: none. ### AUTH.SERVICE_TOKEN_EMPTY [#AUTH.SERVICE_TOKEN_EMPTY] The `PRISMA_SERVICE_TOKEN` environment variable is set but blank; a blank token authenticates nothing while still overriding stored workspace sessions, so the CLI surfaces it instead of silently ignoring it. It is raised identically wherever the environment credential is read — `activeCredential()`, the command needs check, and the engine's request path, including at the start of `prisma auth login` before a browser opens. The suggested actions are to unset the variable or set it to a valid service token. Meta: none. ### AUTH.SERVICE_TOKEN_REJECTED [#AUTH.SERVICE_TOKEN_REJECTED] The management API rejected (401) the service token supplied through `PRISMA_SERVICE_TOKEN`; such a token carries no refresh token and can never be renewed, and nothing stored is cleared. Built only through the shared `credentialRejectedError` dispatcher in the engine's API request path — the one place wording differs by credential origin (a stored session with the same failure gets `CLI.CREDENTIALS_REQUIRED` instead). The suggested action is to replace the variable with a valid service token or unset it to fall back to stored sessions. Meta: none. ### AUTH.SESSIONS_UNSUPPORTED [#AUTH.SESSIONS_UNSUPPORTED] A session mutation (`createSession`, `selectSession`, `endSession`, `endAllSessions`) was attempted on a host that uses the environment-only credential manager, whose sole credential source is `PRISMA_SERVICE_TOKEN` (plus `PRISMA_WORKSPACE_ID`) — such hosts, like composer's rebuilt CLI, hold no stored sessions, so there is nothing to create, select, or end. The suggested action is to set or change the environment variable instead. Meta: none. ### AUTH.USAGE_ERROR [#AUTH.USAGE_ERROR] A command that needs an active workspace found an authenticated credential that names no workspace — raised by the resource commands' `resolveActiveWorkspace` and the service commands' `requireWorkspace`, which read the engine's pinned credential; an environment token whose claims carry no workspace id is the usual cause. The suggested fix is to run `prisma auth login` and choose a workspace. Meta: none. ### AUTH.WORKSPACE_AMBIGUOUS [#AUTH.WORKSPACE_AMBIGUOUS] A user-typed workspace name matched more than one workspace, from two raise sites with different meta: the session-ref resolver behind `prisma auth workspace use`/`logout` when several stored sessions share the name (meta carries `workspaceIds`), and `prisma project transfer` when a `--to-workspace` reference matches several authenticated workspaces (meta carries `workspaceRef` and `matches`, each match holding `id`, `name`, `credentialWorkspaceId`). Both point the user at `prisma auth workspace list` to retry with an exact workspace id. Meta: `workspaceIds` (workspace commands) or `workspaceRef`, `matches` (project transfer). ### AUTH.WORKSPACE_NOT_AUTHENTICATED [#AUTH.WORKSPACE_NOT_AUTHENTICATED] `prisma project transfer` could not resolve the transfer recipient: the `--to-workspace` reference matched no stored OAuth session, or the matched recipient session proved invalid. The suggested fix is to run `prisma auth login` and authorize that workspace, after checking `prisma auth workspace list`. Meta: `workspaceRef`. ## BRANCH [#branch] ### BRANCH.API_ERROR [#BRANCH.API_ERROR] A REST API call made by `prisma branch list` failed. The `why` carries the API's message or, failing that, the HTTP status, and the fix suggests rerunning with `--log-level verbose` for the response details. Meta: `status`, `apiCode` (the API's own error code, when the response supplied one). ## BUCKET [#bucket] ### BUCKET.API_ERROR [#BUCKET.API_ERROR] A bucket REST API request (listing, creating, or deleting buckets or bucket keys) failed — raised by the provider (`lib/bucket/provider.ts`). The `why` carries the API's message or HTTP status, and the fix is the API's hint when it sent one. An HTTP 401 or 403 raises this code too, with a `why` saying the API rejected the request as unauthorized and a `prisma auth login` next action. Meta: `status`, `apiCode` (the API's own error code, when the response supplied one). ### BUCKET.KEY_SECRET_MISSING [#BUCKET.KEY_SECRET_MISSING] `prisma bucket key create` created the key, but the REST API response omitted part of the one-time credential payload (secret access key, access key id, endpoint, or bucket name), so the CLI cannot show credentials it will never see again. The fix is to create another key and store the returned credentials immediately. Meta: none. ### BUCKET.USAGE_ERROR [#BUCKET.USAGE_ERROR] A bucket subcommand was called without its required id argument: `bucket delete` and `bucket key create`/`bucket key list` need a bucket id, and `bucket key delete` needs both a bucket id and a key id. The nextActions point at `bucket list` (or `bucket key list`) to find the ids. Meta: none. ## CLI [#cli] ### CLI.ABORTED [#CLI.ABORTED] The run's abort signal fired before the command completed — a thrown abort error is recognized in settlement and reported as this code rather than as a bug. When the abort came from a delivered SIGINT/SIGTERM the run exits 130/143; an abort with no recorded signal (an engine-internal abort) exits 3. Meta: none. ### CLI.AUTH_SERVICE_ERROR [#CLI.AUTH_SERVICE_ERROR] The authentication service failed transiently while refreshing a stored OAuth session; the stored credentials are left untouched, and the guidance is to retry rather than sign in again, because the credentials themselves were not rejected. Meta: none. ### CLI.BROWSER_WAIT_TIMEOUT [#CLI.BROWSER_WAIT_TIMEOUT] A `ctx.prompt.browserWait` flow (the command opened a URL and polled for the user to finish there) reached its timeout before the poll succeeded. `prisma git connect` catches this code from its GitHub-app install wait and rethrows a command-specific error, so consumers usually see it from other browserWait flows. Meta: `url`, `timeoutMs`. ### CLI.CHILD_PROCESS_FAILED [#CLI.CHILD_PROCESS_FAILED] Emitted only as a json-mode error envelope when a command that handed the terminal to a child process (`exitWithChildStatus`) saw that child exit non-zero or die on a signal; the run's exit code is the child's own status verbatim, not the CLI's usual 2. Meta: `exitCode`, `signal`. ### CLI.COMMAND_MOVED [#CLI.COMMAND_MOVED] The user typed a retired command path, or a retired flag on a surviving command, that the redirect table claims; instead of failing as unknown, the run names the replacement invocation as a run-command next action, with the retirement reason in `why` when one is recorded. Exits 2. Meta: none. ### CLI.CONFIG_MISSING_MARKER [#CLI.CONFIG_MISSING_MARKER] The evaluated `prisma.config.ts` default export carries no `$prismaConfig` version marker — most likely a Prisma ORM 7 config, which uses the same filename — so the loader stops rather than misread it; the fix is to wrap the exported object in `definePrismaConfig`. Raised by the config loader for any command with a `needs.config` section. The file's absolute path is in `where.path`. Meta: none. ### CLI.CONFIG_NOT_FOUND [#CLI.CONFIG_NOT_FOUND] The file `--config` named does not exist. Only an explicitly named file is an error — an absent `prisma.config.ts` found by discovery is fine, because section validators own absence and supply defaults. The path is in `where.path`. Meta: none. ### CLI.CONFIG_SECTION_INVALID [#CLI.CONFIG_SECTION_INVALID] The config section a command declared in `needs.config` failed its validator; the individual problems travel as accompanying diagnostics on the envelope, and the summary names the section and the config file actually read (respecting `--config`). Raised by the engine's needs check before the handler runs. Meta: none. ### CLI.CONFIG_UNKNOWN_SECTION [#CLI.CONFIG_UNKNOWN_SECTION] The config file has a top-level key that is not a section any mounted command or command family declares; the set of section names is closed, so an unrecognized key is a typo or leftover the CLI refuses to silently ignore. The `why` lists the recognized section names, and the file path is in `where.path`. Raised by the engine's needs check, deliberately outside the host-replaceable loader. Meta: none. ### CLI.CONFIG_UNREADABLE [#CLI.CONFIG_UNREADABLE] Evaluating `prisma.config.ts` threw. Two variants share the code: when the error chain shows the `prisma/config` entry point could not be resolved (the prisma package missing from the project, or too old), the guidance is to install the prisma package matching the CLI's version; otherwise the summary carries the first line of the evaluation error and the fix is to repair the file. The path is in `where.path`. Meta: none. ### CLI.CONFIG_VERSION_UNSUPPORTED [#CLI.CONFIG_VERSION_UNSUPPORTED] The config file's `$prismaConfig` marker declares a version other than the one this CLI supports; the fix is to regenerate the config with a matching `definePrismaConfig` or update the CLI. The path is in `where.path`. Meta: none. ### CLI.CONSENT_REQUIRED [#CLI.CONSENT_REQUIRED] A consent prompt was reached under `--yes` or in a non-interactive session. Consent has no default answer and `--yes` does not grant it, so there is nothing for the run to assume. When the consent declares a token, the message and next action say to pass `--confirm `, and the token travels in meta; without a token, the only path is running the command interactively. Meta: `consentToken` (only when the consent declares a token). ### CLI.CREDENTIALS_LOCKED [#CLI.CREDENTIALS_LOCKED] The advisory lock on the stored-credentials file was held by another prisma process for longer than the wait timeout, so this run's credential mutation gave up; the fix is to wait for the other command and retry. Raised by the auth state file's lock helper in `packages/cli`. Meta: none. ### CLI.CREDENTIALS_REQUIRED [#CLI.CREDENTIALS_REQUIRED] The command needs a signed-in credential and none is usable. One constructor covers five reasons: not signed in at all, an expired session, a session expiring too soon for a command that hands credentials to a child process (which cannot refresh them), a workspace session that ended mid-run, and workspace sessions held with none selected as current. Raised identically by the engine's needs check, `ctx.activeCredential`, and the request path; next actions point at signing in or `prisma auth workspace use`. Meta: none. ### CLI.CREDENTIALS_UNREADABLE [#CLI.CREDENTIALS_UNREADABLE] The stored-credentials file exists but could not be read (any read failure other than the file being absent, which yields empty state instead); the guidance is to check the file's permissions. The underlying error is attached as `cause`. Meta: none. ### CLI.INTERACTION_REQUIRED [#CLI.INTERACTION_REQUIRED] The session is not interactive (no TTY stdin, CI, or `--no-interactive`) and the command cannot proceed without a person. Two raise sites: the engine's needs check for a command declaring `needs.interaction`, and `ctx.prompt.browserWait`, which refuses to start a browser wait it could never finish — in that case the URL travels in the error so the user can finish there manually. Meta: `url` (browserWait raise only; none from the needs check). ### CLI.INTERNAL_ERROR [#CLI.INTERNAL_ERROR] A bug, not a user error: a non-structured throw from a handler, an engine invariant violation (undocumented exit code, malformed result), or a stricli internal failure that never settled. The summary is the first line of the underlying error message. Exits 1, the taxonomy's bug code, rather than the usual 2. Meta: none. ### CLI.INVALID_ARGUMENTS [#CLI.INVALID_ARGUMENTS] The invocation's arguments did not parse or contradict each other. Raise sites: stricli's argument-parse failure mapped at the adapter boundary (its usage text becomes summary and `why`), `--config=` given an empty value, `prisma init --skills` given `none` combined with agent names or an unknown agent name, and `prisma skills sync` given both `--disable` and `--enable`. Exits 2 as a usage error. Meta: none. ### CLI.MISSING_DEPENDENCY [#CLI.MISSING_DEPENDENCY] A command declared an optional peer dependency in `needs.dependencies` that does not resolve from the project; the engine probes with `require.resolve` and phrases the install command for the package manager it detected. Meta: `specifier`, `installCommand`. ### CLI.PACKAGE_MANAGER_FAILED [#CLI.PACKAGE_MANAGER_FAILED] A `ctx.packages` operation (an install, or running a package through the manager) exited non-zero — or nothing ran at all because the host wires no package-manager runner, recorded in `meta.reason`. The redacted command line is offered as a run-command next action so the user can run it themselves. Meta: `form`, `manager`, `command`, `exitCode`, `stderrTail`, `reason` (only when the runner is unavailable). ### CLI.PROMPT_CANCELLED [#CLI.PROMPT_CANCELLED] The user cancelled a prompt: EOF on stdin at a line-rendered prompt, a clack cancel (Ctrl-C at the prompt UI), an abort during a browserWait poll, or — via the service commands' `userCancelledError` — consent declined interactively. Settles with exit 3, the cancellation code, instead of 2. Meta: none. ### CLI.PROMPT_INVALID [#CLI.PROMPT_INVALID] An answer could not be interpreted: not a yes/no for a confirm, not one of a select's options with no default to fall back to, or a consent token typed wrong where re-prompting is impossible (scripted answers or piped stdin — the interactive clack renderer re-prompts instead). Meta: `consentToken` (token-mismatch raise only). ### CLI.PROMPT_REQUIRED [#CLI.PROMPT_REQUIRED] A prompt with no declared default was reached where it cannot be shown — under `--yes` or in a non-interactive session — so the run halts; the fix is to run from an interactive terminal or pass a flag that answers the prompt. Meta: none. ### CLI.SPAWN_FAILED [#CLI.SPAWN_FAILED] `ctx.spawn` could not start the requested program, or the child's lifecycle promise rejected; the first line of the underlying failure is in `why`, and the guidance is to check the program is installed and on PATH. Meta: `command`. ### CLI.TELEMETRY_PREFERENCE_UNAVAILABLE [#CLI.TELEMETRY_PREFERENCE_UNAVAILABLE] The `prisma telemetry status|enable|disable` commands could not resolve the user-level config directory because none of XDG_CONFIG_HOME, HOME, APPDATA, or USERPROFILE is set; unreachable in production, where HOME or USERPROFILE is always set. Meta: none. ### CLI.UNKNOWN_COMMAND [#CLI.UNKNOWN_COMMAND] The typed path routed to no command (stricli's route failure, mapped at the adapter boundary) and no redirect claims it; next actions carry up to three "did you mean" suggestions ranked by edit distance over command paths and their prefixes, plus a pointer to `--help`. Exits 2. Meta: none. ## FEEDBACK [#feedback] ### FEEDBACK.EMAIL_INVALID [#FEEDBACK.EMAIL_INVALID] `prisma feedback --email` was given a value that fails the CLI's local check (a basic address pattern, at most 320 characters), which mirrors the feedback service's own limit so the refusal happens before any network round trip. The suggested actions are to pass a valid address or drop the flag to send anonymously. Meta: none. ### FEEDBACK.MESSAGE_REQUIRED [#FEEDBACK.MESSAGE_REQUIRED] `prisma feedback` was run with a message that is empty after trimming. The fix is to pass a non-empty message. Meta: none. ### FEEDBACK.MESSAGE_TOO_LONG [#FEEDBACK.MESSAGE_TOO_LONG] The `prisma feedback` message exceeds 4000 characters, the feedback service's limit, checked locally before the network round trip; the actual length and the limit are stated in `why`. The fix is to shorten the message. Meta: none. ### FEEDBACK.SEND_FAILED [#FEEDBACK.SEND_FAILED] `prisma feedback` could not deliver the submission: the feedback endpoint was unreachable (or timed out), the service answered a non-OK HTTP status (the status and any service-supplied error message go into `why`), or the response body could not be read; a body that arrived but was not JSON is treated as success, and a user cancellation is rethrown rather than wrapped. The suggested action is to check the network and rerun. Meta: none. ## GIT [#git] ### GIT.REPO_ALREADY_CONNECTED [#GIT.REPO_ALREADY_CONNECTED] `prisma git connect` found the resolved project already connected to a different GitHub repository than the one requested (reconnecting the same repository is idempotent and succeeds). The fix is to run `prisma git disconnect` first. Meta: `repository`. ### GIT.REPO_CONNECTION_FAILED [#GIT.REPO_CONNECTION_FAILED] A management API call in the `prisma git connect`/`disconnect` flow failed — creating the install intent, listing installations or repositories, reading or writing the source-repository connection, or a pagination cursor that stopped advancing; the API's message and hint, when present, become `why` and the suggested fix, and a 401/403 is routed to the auth error path instead. Meta: `status`, `apiCode` (when the API supplied one). ### GIT.REPO_INSTALLATION_REQUIRED [#GIT.REPO_INSTALLATION_REQUIRED] `prisma git connect` waited for a GitHub App installation but the wait ended (timeout or final poll) with the workspace still holding no inspectable installation that could link the repository. The fix is to finish installing the GitHub App at the install URL, then rerun `prisma git connect`; the URL is also offered as an open-url next action. Meta: `repository`, `installUrl`. ### GIT.REPO_NOT_ACCESSIBLE [#GIT.REPO_NOT_ACCESSIBLE] `prisma git connect` waited for repository access but the wait ended with the workspace's existing GitHub App installations still not exposing the requested repository — the same install wait as `GIT.REPO_INSTALLATION_REQUIRED`, distinguished by at least one inspectable installation existing. The fix is to grant the App access to this repository at the install URL, then rerun `prisma git connect`. Meta: `repository`, `installUrl`. ### GIT.REPO_NOT_CONNECTED [#GIT.REPO_NOT_CONNECTED] `prisma git disconnect` found no active GitHub repository connection on the resolved project, so there is nothing to disconnect. The fix is to run `prisma git connect` first. Meta: none. ### GIT.REPO_PROVIDER_UNSUPPORTED [#GIT.REPO_PROVIDER_UNSUPPORTED] The URL given to `prisma git connect` (or read from the local `origin` remote) did not parse as a GitHub repository URL; repository connection supports GitHub only. The fix is to pass a GitHub repository URL. Meta: none. ### GIT.USAGE_ERROR [#GIT.USAGE_ERROR] `prisma git connect` was run with no repository URL argument and the local repository has no `origin` remote to fall back on. The fix is to pass a GitHub repository URL or add a GitHub `origin` remote and rerun. Meta: none. ## INIT [#init] ### INIT.CONFIG_KEPT [#INIT.CONFIG_KEPT] A warn diagnostic from `prisma init`: a `prisma.config.ts` already exists that does not configure `skills.agents`, and init never edits an existing config, so it was left untouched. The nextAction carries the exact `skills: { agents: [...] }` snippet to add to the `definePrismaConfig` call; a config that already sets `skills.agents` produces no diagnostic at all. Meta: none. ### INIT.CONFIG_UNWRITABLE [#INIT.CONFIG_UNWRITABLE] A warn diagnostic from `prisma init`: writing the scaffolded `prisma.config.ts` failed, so the config step was skipped. The nextAction asks the user to create the file themselves with the intended `skills: { agents: [...] }` section. Meta: none. ### INIT.DEV_DEPENDENCIES_NOT_AN_OBJECT [#INIT.DEV_DEPENDENCIES_NOT_AN_OBJECT] A warn diagnostic from `prisma init`: the `devDependencies` field in package.json is not an object, so init did not add the `prisma` dev dependency (the postinstall-hook edit still proceeds when its own field is fine). The nextAction is to fix the field, add `"prisma": ""` by hand, and run the package manager's install. Meta: none. ### INIT.NO_PACKAGE_JSON [#INIT.NO_PACKAGE_JSON] A warn diagnostic from `prisma init`: there is no package.json in the current directory, so neither the skills-sync postinstall hook nor the `prisma` dev dependency was added. The nextActions are to rerun init from the directory that holds package.json, or to add the dependency by hand. Meta: none. ### INIT.PACKAGE_JSON_UNREADABLE [#INIT.PACKAGE_JSON_UNREADABLE] A warn diagnostic from `prisma init`: package.json exists but could not be parsed as JSON, so the postinstall hook and the `prisma` dev dependency were not added. The nextActions give the exact postinstall script and dependency entry to add by hand. Meta: none. ### INIT.PACKAGE_JSON_UNWRITABLE [#INIT.PACKAGE_JSON_UNWRITABLE] A warn diagnostic from `prisma init`: the manifest edit was prepared but writing package.json back failed, so the file was left unchanged. The nextActions cover only what the failed write would have added — the postinstall script, the dev dependency, or both. Meta: none. ### INIT.POSTINSTALL_KEPT [#INIT.POSTINSTALL_KEPT] A warn diagnostic from `prisma init`: package.json already has a postinstall script that is not the CLI's own, and init never overwrites a user's script, so it was left alone. The nextAction is to append `prisma skills sync || exit 0` to the existing script yourself so skills resync on every install. Meta: none. ### INIT.SCRIPTS_NOT_AN_OBJECT [#INIT.SCRIPTS_NOT_AN_OBJECT] A warn diagnostic from `prisma init`: the `scripts` field in package.json is not an object, so init left the manifest untouched instead of adding the postinstall hook (which also skips adding the dev dependency, since the manifest is not edited at all). The nextAction gives the postinstall script to add by hand. Meta: none. ### INIT.SKILLS_SYNC_FAILED [#INIT.SKILLS_SYNC_FAILED] A warn diagnostic from `prisma init`: the final step, syncing the agent skills from installed Prisma packages, threw; the cause's message is appended to the summary. The nextAction is to retry with `prisma skills sync` on its own. Meta: none. ## POSTGRES [#postgres] ### POSTGRES.AMBIGUOUS [#POSTGRES.AMBIGUOUS] A database name passed to a `prisma postgres` subcommand matched more than one database in the resolved project — raised by the shared database resolver (`controllers/database.ts`). The fix is to pass the database id, or `--branch ` to narrow the match; the candidates are carried in meta as `matches`, each with `id`, `name`, and `branchName`. Meta: `matches`. ### POSTGRES.API_ERROR [#POSTGRES.API_ERROR] A database REST API request failed without a more specific code — the generic fallback for every `prisma postgres` operation, raised by the provider (`lib/database/provider.ts`), and also when a database response omits its project id. The `why` carries the API's message or HTTP status, and the fix is the API's hint when it sent one. An HTTP 401 or 403 raises this code too, with a `why` saying the API rejected the request as unauthorized and a `prisma auth login` next action. Meta: `status`, `apiCode` (the API's own error code, when the response supplied one). ### POSTGRES.BACKUP_NOT_FOUND [#POSTGRES.BACKUP_NOT_FOUND] `prisma postgres backup restore` got a 404 from the restore endpoint; the source and target databases are resolved before the call, so the 404 identifies the backup id. The fix is to pass a backup id from `prisma postgres backup list `. Meta: none. ### POSTGRES.BACKUPS_UNSUPPORTED [#POSTGRES.BACKUPS_UNSUPPORTED] Listing backups returned a 422 because the platform does not manage backups for this database — for example a remote/BYO database (raised by `prisma postgres backup list`). The fix is to use your own backup tooling for externally managed databases. Meta: none. ### POSTGRES.CONNECTION_MISSING [#POSTGRES.CONNECTION_MISSING] `prisma postgres create` created the database, but the API response did not include the first one-time connection payload. The fix is to create a connection explicitly with `prisma postgres connection create `. Meta: none. ### POSTGRES.CONNECTION_STRING_MISSING [#POSTGRES.CONNECTION_STRING_MISSING] A connection create or rotate succeeded, but the API response did not include the one-time connection string the CLI would show exactly once (raised by `prisma postgres create`, `postgres connection create`, and `postgres connection rotate`). The fix is to rerun the operation, or create a replacement connection and store the returned URL immediately. Meta: none. ### POSTGRES.NOT_FOUND [#POSTGRES.NOT_FOUND] The database a `prisma postgres` subcommand targets could not be resolved: either no database matched the given id or name in the project (and optional `--branch`) scope, or a database that was just listed returned 404 on read because it was removed while the command ran (raised by the shared resolver in `controllers/database.ts`). The fix is to pass an id or name from `prisma postgres list`. Meta: none. ### POSTGRES.PLAN_LIMIT_REACHED [#POSTGRES.PLAN_LIMIT_REACHED] A database operation was blocked because the workspace has used up the operations included in its plan — the API's structured plan-limit discriminator, detected on any `prisma postgres` REST API call; this is a workspace plan restriction, not a Prisma outage. The one nextAction is to upgrade the workspace plan, with the upgrade URL and current plan name when the workspace subscription could be read. Meta: `workspaceId`, `blockedFeature`, `planName`, `usageBlocked`, `upgradeUrl` (each `null` when unavailable). ### POSTGRES.RESTORE_CONFLICT [#POSTGRES.RESTORE_CONFLICT] `prisma postgres backup restore` got a 409 because the target database is provisioning or already recovering. The fix is to wait for the database to become ready — check with `prisma postgres show ` — then retry. Meta: none. ### POSTGRES.USAGE_ERROR [#POSTGRES.USAGE_ERROR] A `prisma postgres` subcommand was called with missing or invalid arguments: `create` without a name, `connection delete`/`connection rotate` without a connection id, `backup restore` without `--backup`, or `usage` with `--from` later than `--to`. The nextActions show the corrected command form. Meta: none. ## PROJECT [#project] ### PROJECT.AMBIGUOUS [#PROJECT.AMBIGUOUS] Project resolution matched more than one project: an explicit project reference (matched by id first, then by name) hit several projects, or the implicit directory context did — raised by any command that resolves a project, including `branch list`. The fix is to pass `--project `, and the next actions include `prisma project link ` with the first match's id verbatim so the user can copy an exact disambiguating reference. Meta: `matches`. ### PROJECT.API_ERROR [#PROJECT.API_ERROR] A REST API project operation (list, rename, delete, or transfer) failed. Listing projects deliberately throws this rather than returning an empty list, so a rejected request is distinguishable from a workspace that genuinely has no projects. The `why` carries the API's message or HTTP status, and the API's own error code, when it sent one, is in `meta.apiCode`. Meta: `status`, `apiCode` (each present only when the response supplied it). ### PROJECT.CREATE_FAILED [#PROJECT.CREATE_FAILED] The platform rejected creating a project — raised by `prisma project create` and by the create-a-new-project path of `prisma project link`. An HTTP 401/403 gets a permissions-focused fix; any other failure surfaces the underlying error message as the `why`. Meta: none. ### PROJECT.DELETE_BLOCKED [#PROJECT.DELETE_BLOCKED] The REST API answered `prisma project delete` with HTTP 400, which typically means the project still has active deployments; the fix is to delete the project's services first (`prisma service delete --service `) and retry. The API's own message replaces the default `why` when present. Meta: none. ### PROJECT.ENV_API_ERROR [#PROJECT.ENV_API_ERROR] A REST API call made by the `prisma project env` commands (reading, writing, or deleting variables, or resolving and creating branches for a scope) failed. The summary names the call that failed, for example "Failed to add STRIPE_KEY". An HTTP 401 or 403 raises this code too, with a `why` saying the API rejected the request as unauthorized and a `prisma auth login` next action. Meta: `status`, `apiCode` (the API's own error code, when the response supplied one). ### PROJECT.ENV_BRANCH_CREATE_REQUIRES_DEFAULT_BRANCH [#PROJECT.ENV_BRANCH_CREATE_REQUIRES_DEFAULT_BRANCH] `prisma project env add --branch ` will create a missing preview branch, but the project has no default branch yet, and creating the first branch would make it the default while branch env overrides are preview-only. The fix is to create or deploy the default branch first, for example via `prisma git connect`. Meta: none. ### PROJECT.ENV_BRANCH_NOT_FOUND [#PROJECT.ENV_BRANCH_NOT_FOUND] A `prisma project env` update, list, or delete named a branch scope (`--branch `) that does not exist — only `env add` creates missing branches. The fix is to create the branch by deploying it, or to use `project env add --branch` to create its first override. Meta: none. ### PROJECT.ENV_BRANCH_SCOPE_IS_PRODUCTION [#PROJECT.ENV_BRANCH_SCOPE_IS_PRODUCTION] A `prisma project env` command's `--branch` flag resolved to the project's production branch; production variables are project-level only, and branch overrides apply to preview branches. The fix is to use `--role production` instead. Meta: none. ### PROJECT.ENV_FILE_APPLY_FAILED [#PROJECT.ENV_FILE_APPLY_FAILED] `prisma project env add --file` or `update --file` failed while writing one of the file's keys, after zero or more earlier keys were already written. The `why` names the keys written before the failure and the underlying cause, and the next actions include a retry command scoped to a file of the remaining keys. Meta: `file`, `failedKey`, `writtenKeys`. ### PROJECT.ENV_PREVIEW_DEFAULT_MISSING [#PROJECT.ENV_PREVIEW_DEFAULT_MISSING] Not an error: a warn diagnostic emitted on a successful `prisma project env add` to a branch scope (single key or `--file`) for each key that has no preview-level default, meaning the variable will exist only on that branch. Meta: none. ### PROJECT.ENV_VARIABLE_ALREADY_EXISTS [#PROJECT.ENV_VARIABLE_ALREADY_EXISTS] `prisma project env add` targeted a key (or, in `--file` mode, one or more keys) that already exists in the targeted scope. The single-key fix is to use `prisma project env update`; the file-mode fix is to split the input file and update existing keys separately from adding new ones. Meta: `keys` (file mode only; the single-key form carries no meta). ### PROJECT.ENV_VARIABLE_NOT_FOUND [#PROJECT.ENV_VARIABLE_NOT_FOUND] `prisma project env update` or `env delete` targeted a key (or, in update's `--file` mode, one or more keys) that does not exist in the targeted scope. The fix for update is to create the variable with `env add` (or split a mixed file); for delete it is to list the scope's variables first. Meta: `keys` (file-mode update only; the single-key forms carry no meta). ### PROJECT.LOCAL_STATE_STALE [#PROJECT.LOCAL_STATE_STALE] The local project binding in `.prisma/local.json` is unusable: the pinned project is no longer in the selected workspace's project list, or the pin file is invalid JSON or has an invalid shape — raised by any command that resolves the project implicitly through the pin. The fix is to delete the pin file and choose a project explicitly. Meta: `pinPath`. ### PROJECT.LOCAL_STATE_WRITE_FAILED [#PROJECT.LOCAL_STATE_WRITE_FAILED] `prisma project link` or `project create` could not save the local binding: writing `.prisma/local.json` failed, or updating `.gitignore` to keep the binding out of git failed — the fix is to check directory permissions and retry. The same code is also emitted as a warn diagnostic (not an error) by `project delete` and `project transfer` when the operation itself succeeded but the now-stale local pin could not be removed or rewritten. Meta: `pinPath` or `gitignorePath`, plus `operation` (the error form; the diagnostic form carries none). ### PROJECT.LOCAL_WORKSPACE_MISMATCH [#PROJECT.LOCAL_WORKSPACE_MISMATCH] `.prisma/local.json` links the directory to a project in one workspace, but the CLI session's active workspace is a different one — raised by any command that resolves the project through the pin. The fix is to switch to the pinned workspace (`prisma auth workspace use `) or relink the directory to a project in the current workspace. Meta: `pinPath`, `pinnedWorkspaceId`, `pinnedProjectId`, `activeWorkspaceId`, `activeWorkspaceName`. ### PROJECT.NOT_FOUND [#PROJECT.NOT_FOUND] An explicit project reference matched no project in the active workspace, either because it does not exist or because the credential cannot see it — raised during project resolution for any command that accepts one, including `branch list` and the `project link`/`transfer`/`delete` target lookup. The fix is to pass an id or name from `prisma project list`. Service commands raise the same code one step later, when the services API answers "Resource Not Found" for a project that did resolve — the directory binding points at a project that no longer exists or is no longer accessible — and their next actions point at `project show` to inspect the binding and `project link` to fix it. Meta: none. ### PROJECT.RENAME_FAILED [#PROJECT.RENAME_FAILED] The REST API answered `prisma project rename` with HTTP 400 or 422, meaning the platform rejected the new name; the API's message and hint replace the default `why` and fix when present, and the fallback fix is to retry with a different name. Meta: none. ### PROJECT.SETUP_REQUIRED [#PROJECT.SETUP_REQUIRED] A command needed a project but the directory is not linked and no `--project` flag was given; the CLI deliberately refuses to pick a project from package or directory names, treating them as suggestions only. The meta carries the inferred name suggestion and any matching candidate projects, and the next actions walk through choosing between linking an existing project (`prisma project link`) and creating a new one. Meta: `suggestedProjectName`, `suggestedProjectNameSource`, `candidates`, `recoveryCommands`. ### PROJECT.TRANSFER_RECIPIENT_REQUIRED [#PROJECT.TRANSFER_RECIPIENT_REQUIRED] `prisma project transfer` was invoked without naming a receiving workspace: neither `--to-workspace ` (for a locally authenticated workspace) nor `--recipient-token ` (for a cross-account transfer) was passed. Meta: none. ### PROJECT.TRANSFER_RECIPIENT_UNAVAILABLE [#PROJECT.TRANSFER_RECIPIENT_UNAVAILABLE] `prisma project transfer --to-workspace` needs to resolve locally stored OAuth workspace sessions, but `PRISMA_SERVICE_TOKEN` is set and service-token mode does not read them. The fix is to pass `--recipient-token ` for the receiving workspace, or to unset the service token. Meta: none. ### PROJECT.TRANSFER_REJECTED [#PROJECT.TRANSFER_REJECTED] The REST API answered `prisma project transfer` with HTTP 400 — for example because the recipient token is invalid or expired; the API's message replaces the default `why` when present, and the fix is to check the recipient session or token and retry. Meta: none. ### PROJECT.USAGE_ERROR [#PROJECT.USAGE_ERROR] A `project` or `branch` group command was invoked with unusable arguments — for example a `project env` write without an explicit `--role` or `--branch` scope, `project transfer` with both recipient flags at once, `project create` with an empty name, or an interactive `project link` whose selection was cancelled. Usage errors exit 2. Meta: none. ## SERVICE [#service] ### SERVICE.BRANCH_INVALID [#SERVICE.BRANCH_INVALID] A `--branch` flag was passed with an empty or whitespace-only value to a service command; the check runs before any resolution because a blank value must never fall through to the default-branch behavior of omitting the flag. The fix is to pass a non-empty branch name, or omit `--branch` to target the default branch. Meta: none. ### SERVICE.BRANCH_NOT_DEPLOYABLE [#SERVICE.BRANCH_NOT_DEPLOYABLE] A `service domain` command was pointed at a non-production branch, which the domain-target resolver refuses because custom domains on preview branches are not supported in Public Beta. The fix is to use `--branch production`, or attach the domain after promoting to the production branch. Meta: none. ### SERVICE.DELETE_FAILED [#SERVICE.DELETE_FAILED] `service delete` called the platform's app-teardown API and it rejected; the underlying error's message becomes `why` and the original error is carried in `cause`. Next actions point at `service show` and `service version list` for the service. Meta: none. ### SERVICE.DEPLOY_FAILED [#SERVICE.DEPLOY_FAILED] The general "REST API call failed" wrapper for the `service` command family — despite the name there is no deploy command here: it wraps failures to create a service, list services or versions, show/promote/roll back/delete/start/stop a version, resolve a service URL, and unrecognized custom-domain API failures. The underlying error's message becomes `why` and the original error is carried in `cause`; each raise site attaches its own next actions. On the domain fallback path only, a `DomainApiError` adds debug meta. Meta: `status`, `apiCode`, `hint` (domain fallback path only; otherwise none). ### SERVICE.DOMAIN_ALREADY_REGISTERED [#SERVICE.DOMAIN_ALREADY_REGISTERED] `service domain add` got HTTP 409 from the domain API because the hostname is already registered, to this or another service. The fix is to delete the domain on the service that owns it, or contact Prisma support if that service is not accessible. Meta: `status`, `apiCode`, `hint`. ### SERVICE.DOMAIN_DNS_NOT_CONFIGURED [#SERVICE.DOMAIN_DNS_NOT_CONFIGURED] `service domain add` got HTTP 400 or 422 whose message the CLI recognizes as a DNS problem (no CNAME, DNS verification failed, and similar). When the API's text names a `*.prisma.build` target, the CLI composes the exact CNAME record to add and carries it in `meta.dnsRecord` and in the advice action; without a target it advises rerunning with `--log-level verbose` to see the API response. Meta: `status`, `apiCode`, `hint`, `dnsRecord` (when the DNS target could be extracted). ### SERVICE.DOMAIN_HOSTNAME_INVALID [#SERVICE.DOMAIN_HOSTNAME_INVALID] The hostname given to a `service domain` command is not a usable custom domain — raised either by local validation before any API call (protocol, path, port, wildcard, single label, or bad DNS labels) or when `service domain add` gets a plain HTTP 400 rejection from the domain API. The fix is to pass a bare hostname such as `shop.acme.com`. Meta: `status`, `apiCode`, `hint` (API-rejection path only; none for local validation). ### SERVICE.DOMAIN_NOT_FOUND [#SERVICE.DOMAIN_NOT_FOUND] A `service domain` command targeted a hostname that is not attached to the resolved service — raised when the service's domain listing has no matching hostname, or when a show/delete/retry/wait call gets HTTP 404. The fix is to check the hostname and service, or add the domain first. Meta: none. ### SERVICE.DOMAIN_QUOTA_EXCEEDED [#SERVICE.DOMAIN_QUOTA_EXCEEDED] `service domain add` was refused because the custom-domain quota is reached — HTTP 429, or a 409 whose text mentions a quota, maximum, or limit. The fix is to delete an existing custom domain before adding another. Meta: `status`, `apiCode`, `hint`. ### SERVICE.DOMAIN_RETRY_NOT_ELIGIBLE [#SERVICE.DOMAIN_RETRY_NOT_ELIGIBLE] `service domain retry` got HTTP 409: the domain is not in a state that can be retried, typically because a verification or TLS step is still in progress. The fix is to wait for the current step to finish and retry only if the domain then fails. Meta: `status`, `apiCode`, `hint`. ### SERVICE.DOMAIN_VERIFICATION_FAILED [#SERVICE.DOMAIN_VERIFICATION_FAILED] `service domain wait` observed the domain reach the terminal `failed` status; `why` carries the platform's failure category and reason when reported, and a failure-specific fix line is attached when the CLI can derive one from the domain record. Next actions point at `service domain show` and `service domain retry`. Meta: none. ### SERVICE.DOMAIN_VERIFICATION_TIMEOUT [#SERVICE.DOMAIN_VERIFICATION_TIMEOUT] `service domain wait` ran out of time (default 15m, or `--timeout 0` for a single check) before the domain became active; `why` reports the status the domain was last seen in. The fix is to inspect the domain with `service domain show` or rerun the wait with a longer `--timeout`. Meta: none. ### SERVICE.FEATURE_UNAVAILABLE [#SERVICE.FEATURE_UNAVAILABLE] `service open` found a live version but the provider does not expose a stable live service URL for this service yet, so there is nothing to open. The next action is to inspect the service state with `service show`. Meta: none. ### SERVICE.LIVE_VERSION_UNKNOWN [#SERVICE.LIVE_VERSION_UNKNOWN] `service version rollback` without `--to` needs to know which version is live, because the default rollback target is defined relative to it, and the service record names no live version — the CLI refuses rather than guess what production is serving. The fix is to pass `--to ` explicitly. Meta: none. ### SERVICE.LOGS_FAILED [#SERVICE.LOGS_FAILED] `service logs` could not read the log — either the logs endpoint answered with a non-OK HTTP status (other than 404, which becomes SERVICE.VERSION_NOT_FOUND), or a page's closing terminal record reported `kind: "error"`, meaning the platform itself says the log read failed. The meta differs by path: the HTTP path carries `status`; the terminal-record path carries the platform's error `code`, `retryable`, and the resume `cursor` when present (in `--follow` mode one retryable terminal error is retried once before this settles the run). Meta: `status` (HTTP path) or `code`, `retryable`, `cursor` (stream path). ### SERVICE.LOGS_INCOMPLETE [#SERVICE.LOGS_INCOMPLETE] A `service logs` response body ended without the terminal record that closes a page, so the read was truncated and the lines already printed may be only part of the page; the run must not settle as if it had read the whole page. Distinct from SERVICE.LOGS_NO_CURSOR, which is a properly closed page with nothing to resume from. The fix is to rerun the command. Meta: none. ### SERVICE.LOGS_NO_CURSOR [#SERVICE.LOGS_NO_CURSOR] `service logs --follow` needs a resume cursor from each page to fetch the next one, and the page ended without one — continuing would re-request the default tail and silently print the same lines every interval, so the run stops and says why. It settles as an error rather than a clean end because `--follow` has no successful ending. The fix is to rerun without `--follow`, or retry if the version is still starting. Meta: none. ### SERVICE.LOGS_RANGE_CONFLICT [#SERVICE.LOGS_RANGE_CONFLICT] `service logs` was invoked with both `--tail` and `--from-start`, which ask for opposite ends of the log; the run is refused before any work. The fix is to pass `--tail ` for the last n lines or `--from-start` for the whole log, not both. Meta: none. ### SERVICE.NAME_REQUIRED [#SERVICE.NAME_REQUIRED] `service create` received an empty or whitespace-only name positional; the check runs before any resolution. The fix is to pass a name, as in `service create my-service`. Meta: none. ### SERVICE.NO_PREVIOUS_VERSION [#SERVICE.NO_PREVIOUS_VERSION] `service version rollback` without `--to` found no earlier version to switch back to — the service has no versions at all, or every version is the live one. The fix is to deploy a second version first, or pass `--to ` for a specific version. Meta: none. ### SERVICE.NO_VERSIONS [#SERVICE.NO_VERSIONS] The resolved service has no usable version for the command — raised by `service open` when the service has no versions, by `service logs` when it has no live version, and by `service domain add` when the API answers 422 because the production service has no promoted version that can receive a custom domain. The fix on the domain path is to promote a version on the production branch first, then add the domain again. Meta: `status`, `apiCode`, `hint` (domain-add path only; otherwise none). ### SERVICE.SELECTION_INVALID [#SERVICE.SELECTION_INVALID] The named service could not be found among the resolved project branch's services — the match tries the stable platform id first, then the name. The fix is to pass the id or name of an existing service; the suggested command is `service list`, deliberately not `service version list`, which itself has to resolve a service and would fail the same way. Meta: none. ### SERVICE.TARGET_REQUIRED [#SERVICE.TARGET_REQUIRED] A service command that acts on an existing service was run without naming one; service commands act only on an explicitly named target — nothing is inferred, remembered, or prompted for. The fix is to pass the service id or name as the first argument, with `service list` to find one. Meta: none. ### SERVICE.TIMEOUT_INVALID [#SERVICE.TIMEOUT_INVALID] The `--timeout` value passed to `service domain wait` is not a duration the parser accepts (`0`, or an integer with `ms`/`s`/`m`/`h`, such as `30s` or `15m`). Meta: none. ### SERVICE.VERSION_ALREADY_LIVE [#SERVICE.VERSION_ALREADY_LIVE] Not an error: a warn-severity diagnostic attached by `service version promote` and `service version rollback` when the selected version is already live for the service — the command skips the promote call, still reports the result, and exits 0. Meta: none. ### SERVICE.VERSION_ALREADY_RUNNING [#SERVICE.VERSION_ALREADY_RUNNING] Not an error: a warn-severity diagnostic attached by `service version start` when the selected version already reports `running` status — the start call is skipped, the result carries `alreadyInState: true`, and the run exits 0. Meta: none. ### SERVICE.VERSION_ALREADY_STOPPED [#SERVICE.VERSION_ALREADY_STOPPED] Not an error: a warn-severity diagnostic attached by `service version stop` when the selected version already reports `stopped` status — the stop call is skipped, the result carries `alreadyInState: true`, and the run exits 0. Meta: none. ### SERVICE.VERSION_DETACHED [#SERVICE.VERSION_DETACHED] A version was resolved by its globally-unique id but the REST API returned it without an owning service, so there is nothing to report or act on it as. The next action shows the version with `service version show`. Meta: none. ### SERVICE.VERSION_NOT_FOUND [#SERVICE.VERSION_NOT_FOUND] The requested service version does not exist or is not available — raised when resolving a version by its globally-unique id finds nothing (including a 404 from the logs endpoint), and, in the "for service" variant used by rollback and logs `--version-id`, when the id exists but does not belong to the resolved service. The fix is to pick an id from `service version list`. Meta: none. ### SERVICE.WORKSPACE_REQUIRED [#SERVICE.WORKSPACE_REQUIRED] A service command ran without a credential that names a workspace — either no authenticated session, or an environment token whose claims carry no workspace, which cannot scope these commands and is treated the same as having no credential. The fix is `auth login`. Meta: none. ## SKILLS [#skills] ### SKILLS.CONFIG_INVALID [#SKILLS.CONFIG_INVALID] An error diagnostic from validating the `skills` section of `prisma.config.ts`, surfaced by the commands that consume it (`init`, `skills sync`, `skills list`): the section is not an object, `skills.check` is not a boolean, `skills.agents` is not an array of strings, or an agent name is one this CLI does not know. Each variant's nextAction says what to write instead; code that reads the config outside a command handler (the staleness check, the post-login tip) treats an invalid config as absent and falls back to the default agent set rather than silencing the check. Meta: none. ### SKILLS.UNMANAGED_DIRECTORY [#SKILLS.UNMANAGED_DIRECTORY] A warn diagnostic from the skills sync (`skills sync`, and the sync step of `init`): a target agent skill directory already holds a skill this CLI does not manage, so sync left it untouched instead of installing the packaged skill there. The nextAction is to move or remove the unmanaged directory and rerun `skills sync`. Meta: none. ### SKILLS.VERSION_CONFLICT [#SKILLS.VERSION_CONFLICT] A warn diagnostic from the skills sync (`skills sync`, and the sync step of `init`): workspace members install different versions of the same skill-bearing Prisma package, so the skills for the highest version were installed and the members pinning a lower version get a skill describing a version they did not install. The nextAction is to pin one version of the package across the workspace. Meta: none. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # feedback (/docs/cli/feedback) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Send feedback to the Prisma CLI team. Location: CLI > feedback `feedback` sends feedback to the Prisma CLI team, straight from the terminal. ## Usage [#usage] #### bun ```bash bunx prisma@latest feedback "The service logs command saved my afternoon" ``` #### pnpm ```bash pnpm dlx prisma@latest feedback "The service logs command saved my afternoon" ``` #### yarn ```bash yarn dlx prisma@latest feedback "The service logs command saved my afternoon" ``` #### npm ```bash npx prisma@latest feedback "The service logs command saved my afternoon" ``` The message can be up to 4000 characters. Feedback is anonymous unless you add `--email
` so the team can reply. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # git (/docs/cli/git) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Connect a GitHub repository for push-to-deploy. Location: CLI > git Use `git` commands to manage the GitHub repository connection. Connecting enables the OIDC credential exchange for GitHub Actions deploys and the branch lifecycle automation. See [GitHub integration](https://www.prisma.io/docs/compute/github) and [Deploy on push](https://www.prisma.io/docs/compute/deploy-on-push). ## Usage [#usage] #### bun ```bash bunx prisma@latest git connect ``` #### pnpm ```bash pnpm dlx prisma@latest git connect ``` #### yarn ```bash yarn dlx prisma@latest git connect ``` #### npm ```bash npx prisma@latest git connect ``` Run it from a [linked](https://www.prisma.io/docs/cli/project) project directory. The command needs an interactive terminal: it opens the browser to install the GitHub App when needed and waits for the install. With `--no-interactive` it fails with `CLI.INTERACTION_REQUIRED`. Connecting from the CLI does not add a deploy workflow to the repository. [Add it yourself](https://www.prisma.io/docs/compute/deploy-on-push#4-add-the-deploy-workflow), or connect through the [Console](https://pris.ly/pdp), which opens a pull request with the workflow. ## Commands [#commands] | Command | Description | | ----------------------- | ----------------------------------------------------------------------------------------------- | | `git connect [git-url]` | Connect the linked project to a GitHub repository. Starts the GitHub App install flow if needed | | `git disconnect` | Stop the credential exchange and branch automation. Keeps the project and existing branches | ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # Global flags (/docs/cli/global-flags) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Flags accepted by every command in the unified Prisma CLI. Location: CLI > Global flags All commands in the unified Prisma CLI accept these flags. | Flag | What it does | | ------------------------------------ | ------------------------------------------------------------------------------------------------------ | | `--json` | Print machine-readable output (shorthand for `--format json`). Use this in CI and scripts. | | `--format ` | Output format: `human`, `json`, or `markdown`. | | `--log-level ` | Commentary verbosity: `error`, `warn`, `info`, or `verbose`. | | `-q`, `--quiet` | Suppress nonessential output (shorthand for `--log-level error`). | | `-v`, `--verbose` | Print more detail (shorthand for `--log-level verbose`). | | `--color` / `--no-color` | Force colored output on or off. | | `--interactive` / `--no-interactive` | Force prompts on or off. | | `-y`, `--yes` | Accept prompt defaults without asking. | | `--confirm ` | Grant a consent prompt non-interactively by typing its token (repeatable). | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `-h`, `--help` | Print the manual for a command: what it does, its options, a workflow where one applies, and examples. | | `--version` | Print the CLI version and exit. | ## Output formats [#output-formats] Without `--format`, a terminal gets `human` output and a pipe gets `json`. `markdown` is never chosen for you; pass `--format markdown` to get it. `markdown` is for AI agents that read command output as text rather than parsing JSON. It prints the same content as `human`, as plain Markdown: a summary line, `label: value` lines, pipe tables, bullet lists, and fenced code, followed by a `### Next` section with the suggested next commands and a `### Diagnostics` section with any findings. There is no padding, alignment, or color, and no JSON envelope. Everything the command produces, including errors, help, `--version`, and progress, goes to stdout, so an agent reads one stream. Use `npx prisma@latest --help` when you need the exact command help from the installed version. The output modes and the JSON envelope these flags select are documented on [Configuration](https://www.prisma.io/docs/cli/configuration#output-modes). ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # Overview (/docs/cli) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Prisma CLI reference Location: Overview Prisma ORM ships with a unified Prisma CLI. One binary contains the ORM commands and the platform commands for [Prisma Composer](https://www.prisma.io/docs/composer), [Prisma Compute](https://www.prisma.io/docs/compute), Prisma Postgres, and object-store buckets. > [!NOTE] > Prisma ORM 7 users > > Prisma ORM 8 is the current release, as a release candidate. Prisma ORM 7 remains fully supported; its docs live at [/orm/v7](https://www.prisma.io/docs/orm/v7) and its setup paths at [/v7/getting-started](https://www.prisma.io/docs/v7/getting-started). > > For what release candidate means, when the final release is expected, and how to stay on version 7, see [Release status](https://www.prisma.io/docs/orm/release-status). For the Prisma ORM 8 name of every Prisma ORM 7 API, see [Coming from Prisma ORM 7](https://www.prisma.io/docs/orm/coming-from-prisma-orm-7). The Prisma ORM CLI ships in the `prisma` package. Run it without installing: #### bun ```bash bunx prisma@latest --help bunx prisma@latest contract emit ``` #### pnpm ```bash pnpm dlx prisma@latest --help pnpm dlx prisma@latest contract emit ``` #### yarn ```bash yarn dlx prisma@latest --help yarn dlx prisma@latest contract emit ``` #### npm ```bash npx prisma@latest --help npx prisma@latest contract emit ``` With `prisma` installed in your project, these commands become plain `prisma contract emit` and so on. For a full app scaffold, use a [Prisma ORM quickstart](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql). That path creates the project files and package scripts for you. This CLI reference is for the lower-level commands those scripts call. ## Platform commands [#platform-commands] The platform commands manage the services, databases, and buckets your app runs on. With [`deploy`](https://www.prisma.io/docs/cli/deploy) and [`dev`](https://www.prisma.io/docs/cli/dev) you deploy a [Prisma Composer](https://www.prisma.io/docs/composer) app to [Prisma Compute](https://www.prisma.io/docs/compute) and run it locally; with [`service`](https://www.prisma.io/docs/cli/service) and [`git`](https://www.prisma.io/docs/cli/git) you manage services, their versions, logs, and domains, and the repository connection. With [`postgres`](https://www.prisma.io/docs/cli/postgres) you spin up and manage [Prisma Postgres](https://www.prisma.io/docs/postgres) databases. With [`bucket`](https://www.prisma.io/docs/cli/bucket) you create blob-storage buckets and their access keys. [`auth`](https://www.prisma.io/docs/cli/auth), [`project`](https://www.prisma.io/docs/cli/project), and [`branch`](https://www.prisma.io/docs/cli/branch) handle the account, project, and branch plumbing around them. Each command group has its own page in this section. Deployments are created by a git push to the connected repository, the [Console](https://pris.ly/pdp), or `deploy`, and each deploy produces a service **version**. ## Common workflows [#common-workflows] There are two main entry points. Platform users deploy apps, create databases, and provision buckets with the [platform commands](#platform-commands). ORM users manage their schema, contracts, and migrations with the ORM and migration commands. ### Deploy an app [#deploy-an-app] Sign in, create or link a project, and connect the repository; every push then deploys. A [Prisma Composer](https://www.prisma.io/docs/composer) app deploys directly with `deploy`: #### bun ```bash bunx prisma@latest auth login bunx prisma@latest project create my-app bunx prisma@latest git connect bunx prisma@latest deploy module.ts ``` #### pnpm ```bash pnpm dlx prisma@latest auth login pnpm dlx prisma@latest project create my-app pnpm dlx prisma@latest git connect pnpm dlx prisma@latest deploy module.ts ``` #### yarn ```bash yarn dlx prisma@latest auth login yarn dlx prisma@latest project create my-app yarn dlx prisma@latest git connect yarn dlx prisma@latest deploy module.ts ``` #### npm ```bash npx prisma@latest auth login npx prisma@latest project create my-app npx prisma@latest git connect npx prisma@latest deploy module.ts ``` Follow a deploy with [`service logs`](https://www.prisma.io/docs/cli/service) and manage the result with the [`service` commands](https://www.prisma.io/docs/cli/service). ### Create a database [#create-a-database] #### bun ```bash bunx prisma@latest postgres create mydb bunx prisma@latest postgres connection create mydb ``` #### pnpm ```bash pnpm dlx prisma@latest postgres create mydb pnpm dlx prisma@latest postgres connection create mydb ``` #### yarn ```bash yarn dlx prisma@latest postgres create mydb yarn dlx prisma@latest postgres connection create mydb ``` #### npm ```bash npx prisma@latest postgres create mydb npx prisma@latest postgres connection create mydb ``` `postgres create` prints a one-time connection URL; `postgres connection create` mints another when you need one. See [`postgres`](https://www.prisma.io/docs/cli/postgres). ### Create a bucket [#create-a-bucket] #### bun ```bash bunx prisma@latest bucket create --name my-bucket bunx prisma@latest bucket key create ``` #### pnpm ```bash pnpm dlx prisma@latest bucket create --name my-bucket pnpm dlx prisma@latest bucket key create ``` #### yarn ```bash yarn dlx prisma@latest bucket create --name my-bucket yarn dlx prisma@latest bucket key create ``` #### npm ```bash npx prisma@latest bucket create --name my-bucket npx prisma@latest bucket key create ``` `bucket key create` prints the key's one-time credentials. See [`bucket`](https://www.prisma.io/docs/cli/bucket). ### Start in an existing project [#start-in-an-existing-project] #### bun ```bash bunx prisma@latest orm init --target postgres --authoring psl bunx prisma@latest contract emit bunx prisma@latest db init --db "$DATABASE_URL" --advance-ref db ``` #### pnpm ```bash pnpm dlx prisma@latest orm init --target postgres --authoring psl pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db init --db "$DATABASE_URL" --advance-ref db ``` #### yarn ```bash yarn dlx prisma@latest orm init --target postgres --authoring psl yarn dlx prisma@latest contract emit yarn dlx prisma@latest db init --db "$DATABASE_URL" --advance-ref db ``` #### npm ```bash npx prisma@latest orm init --target postgres --authoring psl npx prisma@latest contract emit npx prisma@latest db init --db "$DATABASE_URL" --advance-ref db ``` `db init` and `db update` advance the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` on their own when you leave `--db` off and let the connection come from `prisma.config.ts`. Passing `--db` suppresses that, so add `--advance-ref db` to keep the ref current. Without it, `--db` leaves any existing `db` ref where it was, and a later [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) starts from that stale contract; if the ref was never created, `migration plan` refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` as soon as migrations exist on disk. ### Adopt an existing database [#adopt-an-existing-database] #### bun ```bash bunx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma bunx prisma@latest contract emit bunx prisma@latest db sign --db "$DATABASE_URL" bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest db sign --db "$DATABASE_URL" pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma yarn dlx prisma@latest contract emit yarn dlx prisma@latest db sign --db "$DATABASE_URL" yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma npx prisma@latest contract emit npx prisma@latest db sign --db "$DATABASE_URL" npx prisma@latest db verify --db "$DATABASE_URL" ``` `db sign` also sets the `db` ref to the signed contract, so the next `migration plan` starts from the database you adopted. Pass `--no-advance-ref` to sign without moving a ref. ### Use checked-in migrations [#use-checked-in-migrations] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest migration plan --name add_users bunx prisma@latest migration status --db "$DATABASE_URL" bunx prisma@latest db migrate --db "$DATABASE_URL" --advance-ref db bunx prisma@latest db verify --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest migration plan --name add_users pnpm dlx prisma@latest migration status --db "$DATABASE_URL" pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" --advance-ref db pnpm dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest migration plan --name add_users yarn dlx prisma@latest migration status --db "$DATABASE_URL" yarn dlx prisma@latest db migrate --db "$DATABASE_URL" --advance-ref db yarn dlx prisma@latest db verify --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest migration plan --name add_users npx prisma@latest migration status --db "$DATABASE_URL" npx prisma@latest db migrate --db "$DATABASE_URL" --advance-ref db npx prisma@latest db verify --db "$DATABASE_URL" ``` Plain `db migrate` never moves a ref; `--advance-ref db` is what keeps the next `migration plan` incremental. Leave it off in deploy and CI applies, where a repository ref should not move. ## Agent skills [#agent-skills] Prisma packages ship [agent skills](https://www.prisma.io/docs/ai/tools/skills): instructions that teach AI coding agents the installed version's commands and APIs. [`init`](https://www.prisma.io/docs/cli/init) prepares a repository once, and [`skills sync`](https://www.prisma.io/docs/cli/skills) keeps the installed copies matching your package versions. #### bun ```bash bunx --bun prisma@latest init bunx prisma@latest skills sync ``` #### pnpm ```bash pnpm dlx prisma@latest init pnpm dlx prisma@latest skills sync ``` #### yarn ```bash yarn dlx prisma@latest init yarn dlx prisma@latest skills sync ``` #### npm ```bash npx prisma@latest init npx prisma@latest skills sync ``` ## Other commands [#other-commands] A few commands ship without dedicated pages yet. `contract format` formats your PSL contract source in place, and `lsp` starts the Prisma ORM language server (spawned by editors, not run interactively; see [Editor support](https://www.prisma.io/docs/orm/contract-authoring/editor-support)). The `migration` group also has read-only inspection commands: `migration list` (on-disk migrations per contract space; `--space`, `--ascii`, `--legend`), `migration log` (executed history from the database ledger; `--db`, `--utc`, `--ascii`), `migration graph` (graph topology; `--space`, `--dot` for Graphviz output, `--ascii`, `--legend`), and `migration check [target]` (artifact and graph integrity; `--space`). Run any of them with `--help` for the details. ## Global flags [#global-flags] Every command accepts the same set of output, prompt, and config flags. They are documented on [Global flags](https://www.prisma.io/docs/cli/global-flags). ## Related pages - [`Choose a Prisma ORM setup path`](https://www.prisma.io/docs/getting-started): Choose the fastest path to try Prisma ORM in a new or existing project. - [`Console`](https://www.prisma.io/docs/console): Learn how to use the Console to manage and integrate Prisma products into your application. - [`Deploy the full Prisma stack`](https://www.prisma.io/docs/full-stack-tutorial): A single tutorial from empty directory to live URL, with Prisma Composer, Prisma ORM, and Prisma Postgres. - [`Introduction to Prisma ORM`](https://www.prisma.io/docs/prisma-orm): Prisma ORM 8 is the current release. - [`Local development`](https://www.prisma.io/docs/local-development): Run the whole Prisma stack on your machine, with your app on Bun, a local Prisma Postgres database, and local object storage. # init (/docs/cli/init) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Prepare a repository for Prisma development. Location: CLI > init `init` prepares the current directory for Prisma development. It runs locally and calls no platform API. It does not scaffold the ORM: use [`orm init`](https://www.prisma.io/docs/cli/orm-init) to add the Prisma ORM config, contract, and runtime files to a project. `init` does three things: 1. Adds a `postinstall` script to `package.json` (`prisma skills sync || exit 0`), so the [Prisma agent skills](https://www.prisma.io/docs/cli/skills) resync on every install and upgrade. 2. Scaffolds a `prisma.config.ts` recording which agents to install skills for, in the [`skills` config section](https://www.prisma.io/docs/cli/configuration#agent-skills). 3. Runs [`skills sync`](https://www.prisma.io/docs/cli/skills) once. It never prompts, always exits 0, and is safe to rerun: each step reports what is already done. A `prisma.config.ts` or `postinstall` script that already exists is never edited. If `package.json` already has a different `postinstall` script, `init` reports it and tells you what to append instead of chaining or replacing it. ## Usage [#usage] #### bun ```bash bunx --bun prisma@latest init ``` #### pnpm ```bash pnpm dlx prisma@latest init ``` #### yarn ```bash yarn dlx prisma@latest init ``` #### npm ```bash npx prisma@latest init ``` ## Options [#options] | Option | What it does | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `--skills ` | Agents to install skills for, comma-separated: `claude`, `cursor`, `agents`, `devin`. Pass `none` to record that no agent skills are wanted. Default: all of them. | | `--postinstall`/`--no-postinstall` | Add the skills-sync `postinstall` hook. `--no-postinstall` skips that step. | ## Examples [#examples] #### bun ```bash bunx --bun prisma@latest init bunx --bun prisma@latest init --skills=claude,cursor bunx --bun prisma@latest init --skills=none bunx --bun prisma@latest init --no-postinstall ``` #### pnpm ```bash pnpm dlx prisma@latest init pnpm dlx prisma@latest init --skills=claude,cursor pnpm dlx prisma@latest init --skills=none pnpm dlx prisma@latest init --no-postinstall ``` #### yarn ```bash yarn dlx prisma@latest init yarn dlx prisma@latest init --skills=claude,cursor yarn dlx prisma@latest init --skills=none yarn dlx prisma@latest init --no-postinstall ``` #### npm ```bash npx prisma@latest init npx prisma@latest init --skills=claude,cursor npx prisma@latest init --skills=none npx prisma@latest init --no-postinstall ``` ## The scaffolded config [#the-scaffolded-config] `init` writes a minimal `prisma.config.ts` when none exists: ```typescript title="prisma.config.ts" import { definePrismaConfig } from "prisma/config"; export default definePrismaConfig({ skills: { agents: ["claude", "cursor", "agents", "devin"], }, }); ``` The `prisma/config` import resolves from your project's `node_modules`, so add `prisma` as a dev dependency before running other commands against this file. See [Configuration](https://www.prisma.io/docs/cli/configuration). Only `init` writes the `postinstall` hook. No other command edits `package.json`; [`skills sync`](https://www.prisma.io/docs/cli/skills) itself never touches it. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # migration new (/docs/cli/migration-new) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Scaffold a Prisma ORM migration package for manual authoring. Location: CLI > migration new `migration new` creates a migration package with a `migration.ts` file for manual authoring. Use it when the generated plan is not enough and you want to write the migration operations yourself. The command is offline. It does not consult the database. ## Usage [#usage] #### bun ```bash bunx prisma@latest migration new --name split-name ``` #### pnpm ```bash pnpm dlx prisma@latest migration new --name split-name ``` #### yarn ```bash yarn dlx prisma@latest migration new --name split-name ``` #### npm ```bash npx prisma@latest migration new --name split-name ``` ## Options [#options] | Option | What it does | | ----------------- | ------------------------------------------------------------------------- | | `--name ` | Sets the migration directory name suffix. | | `--from ` | Sets the starting contract hash. Defaults to the latest migration target. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Examples [#examples] #### bun ```bash bunx prisma@latest migration new --name split-name bunx prisma@latest migration new --name custom-fk --from abc123 ``` #### pnpm ```bash pnpm dlx prisma@latest migration new --name split-name pnpm dlx prisma@latest migration new --name custom-fk --from abc123 ``` #### yarn ```bash yarn dlx prisma@latest migration new --name split-name yarn dlx prisma@latest migration new --name custom-fk --from abc123 ``` #### npm ```bash npx prisma@latest migration new --name split-name npx prisma@latest migration new --name custom-fk --from abc123 ``` ## After scaffolding [#after-scaffolding] Write the migration body in `migration.ts`, then run the file with Node so it emits `ops.json` and attests the package: ```bash node migration.ts ``` Inspect the result: #### bun ```bash bunx prisma@latest migration show ``` #### pnpm ```bash pnpm dlx prisma@latest migration show ``` #### yarn ```bash yarn dlx prisma@latest migration show ``` #### npm ```bash npx prisma@latest migration show ``` Apply the migration only after review: #### bun ```bash bunx prisma@latest db migrate --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest db migrate --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest db migrate --db "$DATABASE_URL" ``` Manual migrations should still end at a contract state that matches the emitted contract. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # migration plan (/docs/cli/migration-plan) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Plan an on-disk migration from Prisma ORM contract changes. Location: CLI > migration plan `migration plan` compares the emitted contract against a starting contract and produces a new migration package with the required operations. The starting contract is whatever `--from` names, or the [ref](https://www.prisma.io/docs/cli/migration-ref) named `db` when `--from` is absent. With neither, what happens depends on the migrations already on disk: * **`migrations/app/` is empty.** The plan starts from an empty database and contains the full `CREATE` operations for the whole contract. This is the first migration in a new project. The command says so under its summary (`No db ref set — planning from an empty database`), and `--json` output carries `fromDefaulted: true`, so a plan that recreates a database you already have is easy to spot. If a database already exists, run `db init`, `db update`, or `db sign` first. * **Migrations already exist.** The command refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` rather than write a full-create package that no real database could apply. The error names the three exits: `migration ref set db ` to point the ref at the state your database is on, `--from ` to name the origin for this one plan, or `--from @empty` to plan from an empty database deliberately. Keep the `db` ref current and you never see the refusal. [`db init`](https://www.prisma.io/docs/cli/db-init) and [`db update`](https://www.prisma.io/docs/cli/db-update) advance it for you when you run them without `--db`; with `--db` you have to add `--advance-ref db`. [`db sign`](https://www.prisma.io/docs/cli/db-sign) advances it whenever it signs, `--db` or not. [`db migrate`](https://www.prisma.io/docs/cli/db-migrate) advances nothing unless you pass `--advance-ref db`. ### The automatic baseline [#the-automatic-baseline] When `migrations/app/` is empty and the `db` ref points at a contract whose snapshot is stored under `migrations/snapshots/`, one `migration plan` run writes a baseline package from nothing to the ref's contract and, when your emitted contract differs from the ref's, a second package with the delta. Expect one or two new directories in `git status`. The baseline is never replayed against a database that already carries a marker, because the runner starts from the marker and only applies edges past it. The command is offline. It does not need a database connection. ## Usage [#usage] #### bun ```bash bunx prisma@latest migration plan --name add_users_table ``` #### pnpm ```bash pnpm dlx prisma@latest migration plan --name add_users_table ``` #### yarn ```bash yarn dlx prisma@latest migration plan --name add_users_table ``` #### npm ```bash npx prisma@latest migration plan --name add_users_table ``` ## Options [#options] | Option | What it does | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--name ` | Sets the migration directory name suffix. | | `--from ` | Uses a specific starting contract reference (hash, prefix, ref name, migration directory name, `^`, `./path`, or `@empty`) instead of the `db` ref. `migration plan` is offline, so `@db` and `@contract` are not accepted here. | | `--to ` | Sets the destination contract reference. Defaults to the emitted contract. Same grammar as `--from`, except that `@empty` is refused as a destination. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Recommended flow [#recommended-flow] #### bun ```bash bunx prisma@latest contract emit bunx prisma@latest migration plan --name add_users_table bunx prisma@latest migration show ``` #### pnpm ```bash pnpm dlx prisma@latest contract emit pnpm dlx prisma@latest migration plan --name add_users_table pnpm dlx prisma@latest migration show ``` #### yarn ```bash yarn dlx prisma@latest contract emit yarn dlx prisma@latest migration plan --name add_users_table yarn dlx prisma@latest migration show ``` #### npm ```bash npx prisma@latest contract emit npx prisma@latest migration plan --name add_users_table npx prisma@latest migration show ``` Review the generated migration package before applying it with [`db migrate`](https://www.prisma.io/docs/cli/db-migrate). ## Planning a rollback [#planning-a-rollback] Because `--to` accepts `^` (the source contract of a migration), you can plan a migration that walks back a change: #### bun ```bash bunx prisma@latest migration plan --to ^ --name rollback ``` #### pnpm ```bash pnpm dlx prisma@latest migration plan --to ^ --name rollback ``` #### yarn ```bash yarn dlx prisma@latest migration plan --to ^ --name rollback ``` #### npm ```bash npx prisma@latest migration plan --to ^ --name rollback ``` ## When to use migration plan [#when-to-use-migration-plan] Use `migration plan` when your team wants database changes reviewed in version control. For local prototypes where review is not needed, [`db update`](https://www.prisma.io/docs/cli/db-update) is usually faster. If the generated migration is not the migration you want, use [`migration new`](https://www.prisma.io/docs/cli/migration-new) and author the migration manually. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # migration ref (/docs/cli/migration-ref) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Manage named Prisma ORM refs that point at contracts. Location: CLI > migration ref Use `migration ref` commands to manage named refs stored with your migration history. A ref maps a logical environment name, such as `staging` or `production`, to a contract hash. Other commands can then target that environment by name: [`db migrate --to production`](https://www.prisma.io/docs/cli/db-migrate), [`db update --to production`](https://www.prisma.io/docs/cli/db-update), or [`db sign production`](https://www.prisma.io/docs/cli/db-sign). Refs live on disk as `migrations/app/refs/.json`, so they are versioned with your migrations. The commands are offline. The contract a ref points at must already be part of the on-disk migration graph, which is why `migration ref set` does not accept `@db`: that token stands for the live database's marker, and the offline commands never read one. ## The db ref [#the-db-ref] The `db` ref has a special meaning: it records the contract state you expect your local database to match. When you run [`migration plan`](https://www.prisma.io/docs/cli/migration-plan) without `--from`, Prisma ORM assumes you mean from the `db` ref, so as long as the ref is kept up to date, each plan contains only your latest change. The `db` ref is updated automatically in the following situations: * [`db init`](https://www.prisma.io/docs/cli/db-init) and [`db update`](https://www.prisma.io/docs/cli/db-update) update it when you run them without `--db`, so that the connection comes from `prisma.config.ts`. With `--db`, they leave it alone unless you also pass `--advance-ref db`. * [`db sign`](https://www.prisma.io/docs/cli/db-sign) updates it after a successful signature, with or without `--db`. `--no-advance-ref` turns that off. * [`db migrate --advance-ref db`](https://www.prisma.io/docs/cli/db-migrate) updates it after an apply. Plain `db migrate` never touches it, on purpose: a deploy or CI run should not change a file in your repository. You can also set it by hand with `migration ref set db `. ## Usage [#usage] #### bun ```bash bunx prisma@latest migration ref set production 4cb4256 bunx prisma@latest migration ref list bunx prisma@latest migration ref delete production ``` #### pnpm ```bash pnpm dlx prisma@latest migration ref set production 4cb4256 pnpm dlx prisma@latest migration ref list pnpm dlx prisma@latest migration ref delete production ``` #### yarn ```bash yarn dlx prisma@latest migration ref set production 4cb4256 yarn dlx prisma@latest migration ref list yarn dlx prisma@latest migration ref delete production ``` #### npm ```bash npx prisma@latest migration ref set production 4cb4256 npx prisma@latest migration ref list npx prisma@latest migration ref delete production ``` ## Subcommands [#subcommands] | Subcommand | What it does | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `set ` | Points a ref at a contract. The contract is a hash or prefix, another ref name, a migration directory name, or `^` for that migration's source contract. | | `list` | Lists every ref with the contract hash it points at and the invariants recorded against it. | | `delete ` | Deletes a ref. The contract it pointed at is untouched. | ## Example workflow [#example-workflow] #### bun ```bash bunx prisma@latest migration ref set production 20260101T1000_add_user bunx prisma@latest migration status --db "$DATABASE_URL" --to production bunx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### pnpm ```bash pnpm dlx prisma@latest migration ref set production 20260101T1000_add_user pnpm dlx prisma@latest migration status --db "$DATABASE_URL" --to production pnpm dlx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### yarn ```bash yarn dlx prisma@latest migration ref set production 20260101T1000_add_user yarn dlx prisma@latest migration status --db "$DATABASE_URL" --to production yarn dlx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` #### npm ```bash npx prisma@latest migration ref set production 20260101T1000_add_user npx prisma@latest migration status --db "$DATABASE_URL" --to production npx prisma@latest db migrate --db "$DATABASE_URL" --to production ``` Use refs when you want to name the contract state an environment should match, instead of always applying up to the latest migration on disk. If you pass `--advance-ref ` to a command that changes the database, that command also points the ref at the state it applied, once it succeeds. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # migration show (/docs/cli/migration-show) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Inspect a Prisma ORM migration package. Location: CLI > migration show `migration show` displays the operations, statement preview, and metadata for one migration package. Use this command during review before applying a migration package. The command is offline. It does not consult the database. ## Usage [#usage] #### bun ```bash bunx prisma@latest migration show ``` #### pnpm ```bash pnpm dlx prisma@latest migration show ``` #### yarn ```bash yarn dlx prisma@latest migration show ``` #### npm ```bash npx prisma@latest migration show ``` ## Options [#options] | Argument or option | What it does | | ------------------ | ------------------------------------------------------------------------------------ | | `` | The migration to inspect: a directory name, a hash or hash prefix, a ref, or a path. | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Examples [#examples] #### bun ```bash bunx prisma@latest migration show 20260101_100000_add_user bunx prisma@latest migration show a1b2c3 bunx prisma@latest migration show migrations/app/20260101_100000_add_user bunx prisma@latest migration show 20260101_100000_add_user --json ``` #### pnpm ```bash pnpm dlx prisma@latest migration show 20260101_100000_add_user pnpm dlx prisma@latest migration show a1b2c3 pnpm dlx prisma@latest migration show migrations/app/20260101_100000_add_user pnpm dlx prisma@latest migration show 20260101_100000_add_user --json ``` #### yarn ```bash yarn dlx prisma@latest migration show 20260101_100000_add_user yarn dlx prisma@latest migration show a1b2c3 yarn dlx prisma@latest migration show migrations/app/20260101_100000_add_user yarn dlx prisma@latest migration show 20260101_100000_add_user --json ``` #### npm ```bash npx prisma@latest migration show 20260101_100000_add_user npx prisma@latest migration show a1b2c3 npx prisma@latest migration show migrations/app/20260101_100000_add_user npx prisma@latest migration show 20260101_100000_add_user --json ``` ## What to check [#what-to-check] Before applying, review: * the source and destination contract hashes * the planned operations * generated SQL statements or operation payloads * the migration's metadata ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # migration status (/docs/cli/migration-status) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Show the Prisma ORM migration path and pending status. Location: CLI > migration status `migration status` shows which migrations are pending between the database marker and the target contract. Use it before and after [`db migrate`](https://www.prisma.io/docs/cli/db-migrate), and when debugging why an environment is not at the expected contract state. ## Usage [#usage] #### bun ```bash bunx prisma@latest migration status --db "$DATABASE_URL" ``` #### pnpm ```bash pnpm dlx prisma@latest migration status --db "$DATABASE_URL" ``` #### yarn ```bash yarn dlx prisma@latest migration status --db "$DATABASE_URL" ``` #### npm ```bash npx prisma@latest migration status --db "$DATABASE_URL" ``` ## Options [#options] | Option | What it does | | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | | `--db ` | Connects to the database. | | `--space ` | Narrows output to a single contract space. | | `--to ` | Sets the target contract reference (hash, prefix, ref name, migration directory name, `^`, or `./path`). | | `--from ` | Sets the origin contract reference. With `--from`, the command computes the path offline and does not need a database. | | `--legend` | Prints a key for the tree glyphs and lane colors. | | `--ascii` | Uses ASCII glyphs (pipe-friendly). | | `--config ` | Read this config file instead of `./prisma.config.ts`. | | `--json` | Prints a machine-readable result. | ## Examples [#examples] #### bun ```bash bunx prisma@latest migration status --db "$DATABASE_URL" bunx prisma@latest migration status --to production bunx prisma@latest migration status --from abc123 --to production bunx prisma@latest migration status --ascii ``` #### pnpm ```bash pnpm dlx prisma@latest migration status --db "$DATABASE_URL" pnpm dlx prisma@latest migration status --to production pnpm dlx prisma@latest migration status --from abc123 --to production pnpm dlx prisma@latest migration status --ascii ``` #### yarn ```bash yarn dlx prisma@latest migration status --db "$DATABASE_URL" yarn dlx prisma@latest migration status --to production yarn dlx prisma@latest migration status --from abc123 --to production yarn dlx prisma@latest migration status --ascii ``` #### npm ```bash npx prisma@latest migration status --db "$DATABASE_URL" npx prisma@latest migration status --to production npx prisma@latest migration status --from abc123 --to production npx prisma@latest migration status --ascii ``` ## Reading the result [#reading-the-result] With `--db`, status compares the on-disk migration packages to what has been applied in the database. With `--from`, it computes the path offline instead, without a database. The `migration` group has three more read-only views: `migration graph` for topology, `migration log` for executed history, and `migration list` for on-disk enumeration. Run each with `--help` for details. Use [`db verify`](https://www.prisma.io/docs/cli/db-verify) after applying migrations to check the final database shape against the emitted contract. ## Related pages - [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions. - [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project. - [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets. - [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma ORM CLI commands with prisma.config.ts and global flags. - [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma ORM contract artifacts. # orm init (/docs/cli/orm-init) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Initialize Prisma ORM files in a project. Location: CLI > orm init `orm init` scaffolds the Prisma ORM config, contract source, and runtime files inside an existing project, installs dependencies, and emits the contract. It gets you from zero to typed queries in one step. Use a [Prisma ORM quickstart](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql) when you want a complete new application template. Use `orm init` when you already have a project and want to add the lower-level Prisma ORM files. ## Usage [#usage] Run it interactively for a guided setup: #### bun ```bash bunx prisma@latest orm init ``` #### pnpm ```bash pnpm dlx prisma@latest orm init ``` #### yarn ```bash yarn dlx prisma@latest orm init ``` #### npm ```bash npx prisma@latest orm init ``` Or supply `--target` and `--authoring` for a fully scriptable run (CI, AI coding agents, automation): #### bun ```bash bunx prisma@latest orm init --yes --target postgres --authoring psl ``` #### pnpm ```bash pnpm dlx prisma@latest orm init --yes --target postgres --authoring psl ``` #### yarn ```bash yarn dlx prisma@latest orm init --yes --target postgres --authoring psl ``` #### npm ```bash npx prisma@latest orm init --yes --target postgres --authoring psl ``` ## Options [#options] | Option | What it does | | ------------------------ | --------------------------------------------------------------------------- | | `--target ` | Sets the database target. Use `postgres` or `mongodb`. | | `--authoring