Prisma CLI

Documents every Prisma ORM 7 CLI command, from init and generate to migrate, db push and studio, and how to get user consent before Prisma lets an agent reset a database. Use when running migrations or schema commands in a Prisma 7 project.

Databases & SQLPack: Prisma skills267 linesprisma-cli
Author
Source
prisma/skills/prisma-cli @ a6f1929
License
MIT · Copyright (c) 2025 Prisma

About this skill

What it does

A command reference for the Prisma ORM 7 CLI, one file per command in references/: init, generate, validate, format, dev, the four db commands, the six migrate commands (dev, deploy, reset, status, diff, resolve), studio, mcp, complete and debug. Most pages give flags, examples and when the command fits. migrate-dev.md explains the shadow database and drift detection, migrate-diff.md a baseline migration and a CI drift check with --exit-code, dev.md the local Prisma Postgres that prisma dev starts.

It also covers Prisma 7 behaviour that trips up old habits: config lives in prisma.config.ts with env loaded through dotenv; migrate dev no longer runs generate or the seed; under Bun the command is bunx --bun prisma. The agent uses the project's CLI version, never a floating prisma@latest.

agent-safety.md describes a check built into Prisma: when it detects an AI agent, it blocks migrate reset, db push --force-reset and db push --accept-data-loss until the user agrees. The agent explains what will be lost, asks right before the command and passes the user's exact words in PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION; --force skips the usual prompt but is not consent. prisma mcp starts Prisma's MCP server, which has no reset tool by design.

When to use it, and when not

Use it in a Prisma 7 project for migrations, schema sync, introspection, seeding or a local development database.

For first setup, a broken connection or Prisma 8 it sends the agent to Prisma ORM setup. The separate Platform CLI (@prisma/cli, binary prisma-cli) belongs to the prisma-compute and prisma-postgres-setup skills, which are not in our catalog.

How to run it

The install command below puts the whole folder in place. The agent picks the skill up when Prisma commands come up; to call it yourself:

  • Claude Code: /prisma-cli, or ask for the skill by name.
  • Codex: $prisma-cli.
  • Cursor: type / in the Agent chat and pick prisma-cli.

Example: /prisma-cli Create a migration for the new Invoice model, apply it locally and show what migrate deploy will run in production.

How it differs from similar skills

Safe DB migration plans zero-downtime changes on a production database: expand and contract, batched backfills, lock timeouts, rollback. It fits any migration tool and has the agent read the SQL from prisma migrate diff. This skill knows the Prisma commands but says nothing about locks or table size, so for a risky change on a large table use both. Upgrade Prisma ORM to v7 lists the CLI flags and automatic steps v7 removed, for a project still on v6.

Install

Run one command — it saves SKILL.md and the files it uses into your agent's skills folder. Claude Code and Codex pick up a new skill without a restart; if it does not show up, restart the agent.

Claude Code — macOS, Linux
curl -fsSL --create-dirs -o ~/.claude/skills/prisma-cli/SKILL.md https://anymodel.org/en/skills/prisma/prisma-cli/SKILL.md -o ~/.claude/skills/prisma-cli/LICENSE https://anymodel.org/en/skills/prisma/prisma-cli/LICENSE -o ~/.claude/skills/prisma-cli/references/agent-safety.md https://anymodel.org/en/skills/prisma/prisma-cli/references/agent-safety.md -o ~/.claude/skills/prisma-cli/references/complete.md https://anymodel.org/en/skills/prisma/prisma-cli/references/complete.md -o ~/.claude/skills/prisma-cli/references/db-execute.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-execute.md -o ~/.claude/skills/prisma-cli/references/db-pull.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-pull.md -o ~/.claude/skills/prisma-cli/references/db-push.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-push.md -o ~/.claude/skills/prisma-cli/references/db-seed.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-seed.md -o ~/.claude/skills/prisma-cli/references/debug.md https://anymodel.org/en/skills/prisma/prisma-cli/references/debug.md -o ~/.claude/skills/prisma-cli/references/dev.md https://anymodel.org/en/skills/prisma/prisma-cli/references/dev.md -o ~/.claude/skills/prisma-cli/references/format.md https://anymodel.org/en/skills/prisma/prisma-cli/references/format.md -o ~/.claude/skills/prisma-cli/references/generate.md https://anymodel.org/en/skills/prisma/prisma-cli/references/generate.md -o ~/.claude/skills/prisma-cli/references/init.md https://anymodel.org/en/skills/prisma/prisma-cli/references/init.md -o ~/.claude/skills/prisma-cli/references/mcp.md https://anymodel.org/en/skills/prisma/prisma-cli/references/mcp.md -o ~/.claude/skills/prisma-cli/references/migrate-deploy.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-deploy.md -o ~/.claude/skills/prisma-cli/references/migrate-dev.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-dev.md -o ~/.claude/skills/prisma-cli/references/migrate-diff.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-diff.md -o ~/.claude/skills/prisma-cli/references/migrate-reset.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-reset.md -o ~/.claude/skills/prisma-cli/references/migrate-resolve.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-resolve.md -o ~/.claude/skills/prisma-cli/references/migrate-status.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-status.md -o ~/.claude/skills/prisma-cli/references/studio.md https://anymodel.org/en/skills/prisma/prisma-cli/references/studio.md -o ~/.claude/skills/prisma-cli/references/validate.md https://anymodel.org/en/skills/prisma/prisma-cli/references/validate.md
Codex, Cursor — macOS, Linux
curl -fsSL --create-dirs -o ~/.agents/skills/prisma-cli/SKILL.md https://anymodel.org/en/skills/prisma/prisma-cli/SKILL.md -o ~/.agents/skills/prisma-cli/LICENSE https://anymodel.org/en/skills/prisma/prisma-cli/LICENSE -o ~/.agents/skills/prisma-cli/references/agent-safety.md https://anymodel.org/en/skills/prisma/prisma-cli/references/agent-safety.md -o ~/.agents/skills/prisma-cli/references/complete.md https://anymodel.org/en/skills/prisma/prisma-cli/references/complete.md -o ~/.agents/skills/prisma-cli/references/db-execute.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-execute.md -o ~/.agents/skills/prisma-cli/references/db-pull.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-pull.md -o ~/.agents/skills/prisma-cli/references/db-push.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-push.md -o ~/.agents/skills/prisma-cli/references/db-seed.md https://anymodel.org/en/skills/prisma/prisma-cli/references/db-seed.md -o ~/.agents/skills/prisma-cli/references/debug.md https://anymodel.org/en/skills/prisma/prisma-cli/references/debug.md -o ~/.agents/skills/prisma-cli/references/dev.md https://anymodel.org/en/skills/prisma/prisma-cli/references/dev.md -o ~/.agents/skills/prisma-cli/references/format.md https://anymodel.org/en/skills/prisma/prisma-cli/references/format.md -o ~/.agents/skills/prisma-cli/references/generate.md https://anymodel.org/en/skills/prisma/prisma-cli/references/generate.md -o ~/.agents/skills/prisma-cli/references/init.md https://anymodel.org/en/skills/prisma/prisma-cli/references/init.md -o ~/.agents/skills/prisma-cli/references/mcp.md https://anymodel.org/en/skills/prisma/prisma-cli/references/mcp.md -o ~/.agents/skills/prisma-cli/references/migrate-deploy.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-deploy.md -o ~/.agents/skills/prisma-cli/references/migrate-dev.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-dev.md -o ~/.agents/skills/prisma-cli/references/migrate-diff.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-diff.md -o ~/.agents/skills/prisma-cli/references/migrate-reset.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-reset.md -o ~/.agents/skills/prisma-cli/references/migrate-resolve.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-resolve.md -o ~/.agents/skills/prisma-cli/references/migrate-status.md https://anymodel.org/en/skills/prisma/prisma-cli/references/migrate-status.md -o ~/.agents/skills/prisma-cli/references/studio.md https://anymodel.org/en/skills/prisma/prisma-cli/references/studio.md -o ~/.agents/skills/prisma-cli/references/validate.md https://anymodel.org/en/skills/prisma/prisma-cli/references/validate.md
Claude Code — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','references/agent-safety.md','references/complete.md','references/db-execute.md','references/db-pull.md','references/db-push.md','references/db-seed.md','references/debug.md','references/dev.md','references/format.md','references/generate.md','references/init.md','references/mcp.md','references/migrate-deploy.md','references/migrate-dev.md','references/migrate-diff.md','references/migrate-reset.md','references/migrate-resolve.md','references/migrate-status.md','references/studio.md','references/validate.md') { $p = Join-Path "$HOME\.claude\skills\prisma-cli" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/prisma/prisma-cli/$f" -UseBasicParsing -OutFile $p }
Codex, Cursor — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','references/agent-safety.md','references/complete.md','references/db-execute.md','references/db-pull.md','references/db-push.md','references/db-seed.md','references/debug.md','references/dev.md','references/format.md','references/generate.md','references/init.md','references/mcp.md','references/migrate-deploy.md','references/migrate-dev.md','references/migrate-diff.md','references/migrate-reset.md','references/migrate-resolve.md','references/migrate-status.md','references/studio.md','references/validate.md') { $p = Join-Path "$HOME\.agents\skills\prisma-cli" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/prisma/prisma-cli/$f" -UseBasicParsing -OutFile $p }

Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/prisma/prisma-cli/SKILL.md

SKILL.md

Raw

Prisma ORM 7 CLI reference

These commands and examples apply to Prisma ORM 7 only. For setup, connection repair, or a Prisma 8 application, load prisma-orm-setup.

Use the project's version-matched CLI. Do not install a floating prisma@latest to run these commands.

Boundary: Platform and Compute

Do not confuse the stable ORM command (prisma) with the public-beta Platform package (@prisma/cli, binary prisma-cli). Use prisma-compute for Compute apps and workspace auth, and prisma-postgres-setup for Platform projects and databases.

When to Apply

Reference this skill when:

  • Setting up an explicitly selected Prisma 7 project (prisma init)
  • Generating Prisma Client (prisma generate)
  • Running database migrations (prisma migrate)
  • Managing database state (prisma db push/pull)
  • Using local development database (prisma dev)
  • Debugging Prisma issues (prisma debug)
  • Generating shell completions (prisma complete)

Rule Categories by Priority

Priority Category Impact Prefix
1 Setup HIGH init
2 Generation HIGH generate
3 Development HIGH dev
4 Database HIGH db-
5 Migrations CRITICAL migrate-
6 Utility MEDIUM complete, studio, validate, format, debug, mcp

Command Categories

Category Commands Purpose
Setup init Initialize a Prisma project
Generation generate Generate Prisma Client
Validation validate, format Schema validation and formatting
Development dev Local Prisma Postgres for development
Database db pull, db push, db seed, db execute Direct database operations
Migrations migrate dev, migrate deploy, migrate reset, migrate status, migrate diff, migrate resolve Schema migrations
Utility complete, studio, mcp, version, debug Shell, development, and AI tooling

Quick Reference

Project Setup

# Initialize new project (creates prisma/ folder and prisma.config.ts)
prisma init

# Initialize with specific database
prisma init --datasource-provider postgresql
prisma init --datasource-provider mysql
prisma init --datasource-provider sqlite

# Initialize with Prisma Postgres (cloud)
prisma init --db

# Initialize with an example model
prisma init --with-model

Client Generation

# Generate Prisma Client
prisma generate

# Watch mode for development
prisma generate --watch

# Generate specific generator only
prisma generate --generator client

Bun Runtime

When using Bun, always add the --bun flag so Prisma runs with the Bun runtime (otherwise it falls back to Node.js because of the CLI shebang):

bunx --bun prisma init
bunx --bun prisma generate

Local Development Database

# Start local Prisma Postgres
prisma dev

# Start with specific name
prisma dev --name myproject

# Start in background (detached)
prisma dev --detach

# List all local instances
prisma dev ls

# Stop instance
prisma dev stop myproject

# Remove instance data
prisma dev rm myproject

Database Operations

# Pull schema from existing database
prisma db pull

# Push schema to database (no migrations)
prisma db push

# Seed database
prisma db seed

# Execute raw SQL
prisma db execute --file ./script.sql

Migrations (Development)

# Create and apply migration
prisma migrate dev

# Create migration with name
prisma migrate dev --name add_users_table

# Create migration without applying
prisma migrate dev --create-only

# Reset database and apply all migrations
prisma migrate reset

Migrations (Production)

# Apply pending migrations (CI/CD)
prisma migrate deploy

# Check migration status
prisma migrate status

# Compare schemas and generate diff
prisma migrate diff --from-config-datasource --to-schema schema.prisma --script

Utility Commands

# Open Prisma Studio (database GUI)
prisma studio

# Start Prisma's MCP server for AI tools
prisma mcp

# Show version info
prisma version
prisma -v

# Debug information
prisma debug

# Validate schema
prisma validate

# Format schema
prisma format

# Generate shell completion code
prisma complete zsh

AI Safety Checkpoint

Prisma blocks destructive commands when it detects an AI agent until the agent has obtained explicit user consent. This covers migrate reset, db push --force-reset, and db push --accept-data-loss.

  • Explain the exact data-loss impact and ask for consent immediately before running the command.
  • Do not infer consent from earlier or unrelated messages.
  • If automation needs the consent variable, set PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION to the user's exact consent message. Do not invent the text.
  • The Prisma MCP server deliberately has no migrate-reset tool.

Read references/agent-safety.md before any destructive Prisma command.

Current Prisma CLI Setup

New Configuration File

Use prisma.config.ts for CLI configuration:

import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'

export default defineConfig({
  schema: 'prisma/schema.prisma',
  migrations: {
    path: 'prisma/migrations',
    seed: 'tsx prisma/seed.ts',
  },
  datasource: {
    url: env('DATABASE_URL'),
  },
})

Current Command Behavior

  • Run prisma generate explicitly after migrate dev, db push, or other schema syncs when you need fresh client output
  • Run prisma db seed explicitly after migrate dev or migrate reset when you need seed data
  • Use prisma db execute --file ... for raw SQL scripts

Environment Variables

Load environment variables explicitly in prisma.config.ts, commonly with dotenv:

// prisma.config.ts
import 'dotenv/config'

Rule Files

See individual rule files for detailed command documentation:

references/init.md           - Project initialization
references/generate.md       - Client generation
references/dev.md            - Local development database
references/db-pull.md        - Database introspection
references/db-push.md        - Schema push
references/db-seed.md        - Database seeding
references/db-execute.md     - Raw SQL execution
references/migrate-dev.md    - Development migrations
references/migrate-deploy.md - Production migrations
references/migrate-reset.md  - Database reset
references/migrate-status.md - Migration status
references/migrate-resolve.md - Migration resolution
references/migrate-diff.md   - Schema diffing
references/studio.md         - Database GUI
references/mcp.md            - Prisma MCP server
references/complete.md       - Shell completion generation
references/agent-safety.md   - AI consent checkpoint for destructive commands
references/validate.md       - Schema validation
references/format.md         - Schema formatting
references/debug.md          - Debug info

How to Use

Use the command categories above for navigation, then open the specific command reference file you need.

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack Prisma skills