
Prisma Cli
- 109k installs
- 50 repo stars
- Updated August 4, 2026
- prisma/skills
Prisma ORM command-line interface for project initialization, Prisma Client generation, schema migrations, database operations, and development utilities.
About
Prisma CLI provides command reference for ORM operations including init, generate, migrate, db, dev, studio, validate, format, debug, and mcp. Developers use it to bootstrap projects, generate Prisma Client, manage database migrations, introspect schemas, seed data, and run local development databases. Key workflows cover setup (prisma init with datasource provider), client generation in watch mode, development migrations with prisma migrate dev, production deployments via prisma migrate deploy, and local Prisma Postgres instances via prisma dev. Configuration uses prisma.config.ts with environment variable loading. The skill excludes Prisma Compute app deployment - use prisma-compute for app deploy, compute:deploy, and framework readiness.
- Initialize projects with prisma init, optional datasource provider selection (postgresql, mysql, sqlite), or cloud Prism
- Generate Prisma Client explicitly after schema syncs; use --watch mode for development iteration
- Manage migrations with prisma migrate dev (development) and prisma migrate deploy (production CI/CD); check status and r
- Operate local development database via prisma dev with detach, list, stop, and rm subcommands; manages Prisma Postgres i
- Execute database operations: prisma db pull (introspect), db push (schema sync), db seed (data loading), db execute (raw
Prisma Cli by the numbers
- 108,799 all-time installs (skills.sh)
- +44,034 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #8 of 911 Databases skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
prisma-cli capabilities & compatibility
- Capabilities
- initialize new prisma projects with configurable · generate and regenerate prisma client in watch m · create, apply, and manage database migrations · introspect existing database schemas · push schema changes directly to database · run local development databases via prisma postg · seed databases with data · execute raw sql scripts · validate and format prisma schemas · open prisma studio database gui
- Works with
- postgres · mysql
- Use cases
- database · api development · ci cd · debugging
- Platforms
- macOS · Windows · Linux
- Pricing
- Free
npx skills add https://github.com/prisma/skills --skill prisma-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 109k |
|---|---|
| repo stars | ★ 50 |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 4, 2026 |
| Repository | prisma/skills ↗ |
What it does
Execute Prisma ORM CLI commands for project initialization, client generation, migrations, and database operations in development and production workflows.
Who is it for?
Backend developers building TypeScript/Node.js applications with relational databases; teams using Prisma ORM for schema-driven development and migration management.
Skip if: Prisma Compute app deployment, Docker container orchestration, cloud infrastructure provisioning, or non-ORM database administration.
When should I use this skill?
Developer runs prisma init, prisma generate, prisma migrate dev, prisma db pull/push, prisma studio, prisma mcp, prisma dev, or prisma debug.
What you get
Developers can bootstrap Prisma projects, generate fresh Prisma Client code, deploy migrations to production, introspect schemas, seed data, and run isolated local databases via CLI commands.
- Migration files
- Generated Prisma Client
- Configured schema.prisma
By the numbers
- Supports PostgreSQL, MySQL, and SQLite via datasource provider flag
- Prisma version 7.6.0 referenced in documentation
- 13 primary command categories documented: init, generate, validate, format, dev, db pull/push/seed/execute, migrate dev/
Files
Prisma CLI Reference
Reference for Prisma ORM CLI commands. This skill provides guidance on command usage, options, and best practices for current Prisma ORM releases.
Boundary: Compute
Do not use this skill for Prisma Compute app deployment. Use prisma-compute for @prisma/cli app deploy, compute:deploy, create-prisma --deploy, Compute apps, deployments, logs, domains, and framework deploy readiness.
When to Apply
Reference this skill when:
- Setting up a new Prisma 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)
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 | studio, validate, format, debug, mcp |
Command Categories
| Category | Commands | Purpose |
|---|---|---|
| Setup | init | Bootstrap new 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 | studio, mcp, version, debug | 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-modelClient Generation
# Generate Prisma Client
prisma generate
# Watch mode for development
prisma generate --watch
# Generate specific generator only
prisma generate --generator clientBun 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 generateLocal 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 myprojectDatabase 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.sqlMigrations (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 resetMigrations (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 --scriptUtility 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 formatCurrent 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 generateexplicitly aftermigrate dev,db push, or other schema syncs when you need fresh client output - Run
prisma db seedexplicitly aftermigrate devormigrate resetwhen 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/validate.md - Schema validation
references/format.md - Schema formatting
references/debug.md - Debug infoHow to Use
Use the command categories above for navigation, then open the specific command reference file you need.
prisma db execute
Execute native commands (SQL) to your database.
Command
prisma db execute [options]What It Does
- Connects to your database using the configured datasource
- Executes a script provided via file (
--file) or stdin (--stdin) - Useful for running raw SQL, maintenance tasks, or applying diffs from
migrate diff - Not supported on MongoDB
Options
| Option | Description |
|---|---|
--file | Path to a file containing the script to execute |
--stdin | Use terminal standard input as the script |
--config | Custom path to your Prisma config file |
Current Option Surface
prisma db execute uses the datasource configured in prisma.config.ts. Use --config if you need a separate config file for another environment.
Examples
Execute from file
prisma db execute --file ./script.sqlExecute from stdin
echo "TRUNCATE TABLE User;" | prisma db execute --stdinExecute migrate diff output
Pipe the output of migrate diff directly to the database:
prisma migrate diff \
--from-empty \
--to-schema prisma/schema.prisma \
--script \
| prisma db execute --stdinConfiguration
Uses datasource from prisma.config.ts:
export default defineConfig({
datasource: {
url: env('DATABASE_URL'),
},
})Use Cases
- Manual Migrations: Applying raw SQL changes
- Data Maintenance: Truncating tables, cleaning up data
- Schema Synchronization: Applying
migrate diffscripts - Debugging: Running test queries (though typically not for fetching data)
Limitations
- No Data Return: The command reports success/failure, not query results (rows). Use Prisma Client or
prisma studioto view data. - SQL Only: Primarily for SQL databases.
prisma db pull
Introspects an existing database and updates your Prisma schema to reflect its structure.
Command
prisma db pull [options]What It Does
- Connects to your database
- Reads the database schema (tables, columns, relations, indexes)
- Updates
schema.prismawith corresponding Prisma models - For MongoDB, samples data to infer schema
Options
| Option | Description |
|---|---|
--force | Ignore current Prisma schema file |
--print | Print the introspected Prisma schema to stdout |
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
--url | Override the datasource URL from the Prisma config file |
--composite-type-depth | Specify the depth for introspecting composite types (default: -1 for infinite, 0 = off) |
--schemas | Specify the database schemas to introspect |
--local-d1 | Generate a Prisma schema from a local Cloudflare D1 database |
Examples
Basic introspection
prisma db pullPreview without writing
prisma db pull --printOutputs schema to terminal for review.
Force overwrite
prisma db pull --forceReplaces schema file, losing any manual customizations.
Prerequisites
Configure database connection in prisma.config.ts:
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: env('DATABASE_URL'),
},
})Workflow
Starting from existing database
1. Initialize Prisma:
prisma init2. Configure database URL
3. Pull schema:
prisma db pull4. Review and customize generated schema
5. Generate client:
prisma generateSyncing changes from database
When database changes are made outside Prisma:
prisma db pull
prisma generateGenerated Schema Example
Database tables become Prisma models:
-- Database tables
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(100)
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author_id INTEGER REFERENCES users(id)
);Becomes:
model users {
id Int @id @default(autoincrement())
email String @unique @db.VarChar(255)
name String? @db.VarChar(100)
posts posts[]
}
model posts {
id Int @id @default(autoincrement())
title String @db.VarChar(255)
author_id Int?
users users? @relation(fields: [author_id], references: [id])
}Post-Introspection Cleanup
After db pull, consider:
1. Rename models to PascalCase:
model User { // Was: users
@@map("users")
}2. Rename fields to camelCase:
authorId Int? @map("author_id")3. Add relation names for clarity:
author User? @relation("PostAuthor", fields: [authorId], references: [id])4. Add documentation:
/// User account information
model User {
/// Primary email for authentication
email String @unique
}MongoDB Introspection
For MongoDB, db pull samples documents to infer schema:
prisma db pullMay require manual refinement since MongoDB is schemaless.
Warning
db pull overwrites your schema file. Always:
- Commit current schema before pulling
- Use
--printto preview first - Backup customizations you want to keep
prisma db push
Pushes schema changes directly to database without creating migrations. Ideal for prototyping.
Command
prisma db push [options]What It Does
- Syncs your Prisma schema to the database
- Creates database if it doesn't exist
- Does NOT create migration files
- Does NOT track migration history
Options
| Option | Description |
|---|---|
--force-reset | Force a reset of the database before push |
--accept-data-loss | Ignore data loss warnings |
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
--url | Override the datasource URL from the Prisma config file |
Follow-up Command
- Run
prisma generateexplicitly when you need refreshed client output
Examples
Basic push
prisma db pushAccept data loss
prisma db push --accept-data-lossRequired when changes would delete data (dropping columns, etc.)
Force reset
prisma db push --force-resetCompletely resets database and applies schema.
Full workflow
prisma db push
prisma generateWhen to Use
- Prototyping - Rapid schema iteration
- Local development - Quick schema changes
- MongoDB - Primary workflow (migrations not supported)
- Testing - Setting up test databases
When NOT to Use
- Production - Use
migrate deploy - Team collaboration - Use migrations for trackable changes
- When you need rollback - Migrations provide history
Comparison with migrate dev
| Feature | db push | migrate dev |
|---|---|---|
| Creates migration files | No | Yes |
| Tracks history | No | Yes |
| Requires shadow database | No | Yes |
| Speed | Faster | Slower |
| Rollback capability | No | Yes |
| Best for | Prototyping | Development |
MongoDB Workflow
MongoDB doesn't support migrations. Use db push exclusively:
# Schema changes for MongoDB
prisma db push
prisma generateCommon Patterns
Prototyping workflow
# Make schema changes
# ...
# Push to database
prisma db push
# Generate client
prisma generate
# Test your changes
# Repeat as neededReset and start fresh
prisma db push --force-reset
prisma db seedHandling conflicts
If db push can't apply changes safely:
Error: The following changes cannot be applied:
- Removing field `email` would cause data loss
Use --accept-data-loss to proceedDecide whether data loss is acceptable, then:
prisma db push --accept-data-lossTransition to Migrations
When ready for production, switch to migrations:
# Create baseline migration from current schema
prisma migrate dev --name initThen use migrate dev for future changes.
prisma db seed
Runs your database seed script to populate data.
Command
prisma db seed [options]What It Does
- Executes your configured seed script
- Populates database with initial/test data
- Runs independently (not auto-run by migrations in v7)
Options
| Option | Description |
|---|---|
--config | Custom path to your Prisma config file |
-- | Pass custom arguments to seed script |
Configuration
Configure seed script in prisma.config.ts:
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', // Your seed command
},
datasource: {
url: env('DATABASE_URL'),
},
})Common seed commands
// TypeScript with tsx
seed: 'tsx prisma/seed.ts'
// TypeScript with ts-node
seed: 'ts-node prisma/seed.ts'
// JavaScript
seed: 'node prisma/seed.js'Seed Script Example
// prisma/seed.ts
import { PrismaClient } from '../generated/client'
const prisma = new PrismaClient()
async function main() {
// Create users
const alice = await prisma.user.upsert({
where: { email: 'alice@prisma.io' },
update: {},
create: {
email: 'alice@prisma.io',
name: 'Alice',
posts: {
create: {
title: 'Hello World',
published: true,
},
},
},
})
const bob = await prisma.user.upsert({
where: { email: 'bob@prisma.io' },
update: {},
create: {
email: 'bob@prisma.io',
name: 'Bob',
},
})
console.log({ alice, bob })
}
main()
.then(async () => {
await prisma.$disconnect()
})
.catch(async (e) => {
console.error(e)
await prisma.$disconnect()
process.exit(1)
})Examples
Run seed
prisma db seedWith custom arguments
prisma db seed -- --environment developmentArguments after -- are passed to your seed script.
Current Workflow
Run seeding explicitly after migrations when you need seed data:
prisma migrate dev --name init
prisma generate
prisma db seed # Must run explicitlyIdempotent Seeding
Use upsert to make seeds re-runnable:
// Good: Can run multiple times
await prisma.user.upsert({
where: { email: 'alice@prisma.io' },
update: {}, // Don't change existing
create: { email: 'alice@prisma.io', name: 'Alice' },
})
// Bad: Fails on second run
await prisma.user.create({
data: { email: 'alice@prisma.io', name: 'Alice' },
})Common Patterns
Development reset
prisma migrate reset --force
prisma db seedConditional seeding
// prisma/seed.ts
const count = await prisma.user.count()
if (count === 0) {
// Only seed if empty
await seedUsers()
}Environment-specific seeds
// prisma/seed.ts
const env = process.env.NODE_ENV || 'development'
if (env === 'development') {
await seedDevData()
} else if (env === 'test') {
await seedTestData()
}Best Practices
1. Use upsert for idempotent seeds 2. Keep seeds focused and minimal 3. Use realistic but fake data 4. Document required seed data 5. Version control your seed scripts
prisma debug
Prints information helpful for debugging and bug reports.
Command
prisma debug [options]What It Does
Outputs details about your Prisma environment, including:
- Prisma CLI version
- Prisma Client version (if installed)
- Engine binaries (Query Engine, Migration Engine, etc.)
- Platform information (OS, Architecture)
- Node.js version
- Configured datasource provider
Options
| Option | Description |
|---|---|
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Example Output
prisma : 7.3.0
@prisma/client : 7.3.0
Operating System : darwin
Architecture : arm64
Node.js : v20.10.0
TypeScript : 5.3.3
Query Compiler : enabled
PSL : ...
Schema Engine : ...When to Use
- Troubleshooting: Checking version mismatches
- Reporting Issues: Including environment info in GitHub issues
- Verifying Installation: Ensuring correct binaries are downloaded
prisma dev
Starts a local Prisma Postgres database for development. Provides a PostgreSQL-compatible database that runs entirely on your machine.
Command
prisma dev [options]What It Does
- Starts a local PostgreSQL-compatible database
- Runs in your terminal or as a background process
- Perfect for development and testing
- Easy migration to Prisma Postgres cloud in production
Options
| Option | Description | Default |
|---|---|---|
--name / -n | Name for the database instance | default |
--port / -p | HTTP server port | 51213 |
--db-port / -P | Database server port | 51214 |
--shadow-db-port | Shadow database port (for migrations) | 51215 |
--detach / -d | Run in background | false |
--debug | Enable debug logging | false |
Examples
Start local database
prisma devInteractive mode with keyboard shortcuts:
q- Quith- Show HTTP URLt- Show TCP URLs
Named instance
prisma dev --name myprojectUseful for multiple projects.
Background mode
prisma dev --detachFrees your terminal for other commands.
Custom ports
prisma dev --port 5000 --db-port 5432Instance Management
List all instances
prisma dev lsShows all local Prisma Postgres instances with status.
Start existing instance
prisma dev start myprojectStarts a previously created instance in background.
Stop instance
prisma dev stop myprojectStop with glob pattern
prisma dev stop "myproject*"Stops all instances matching pattern.
Remove instance
prisma dev rm myprojectRemoves instance data from filesystem.
Force remove (stops first)
prisma dev rm myproject --forceConfiguration
Configure your prisma.config.ts to use local Prisma Postgres:
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
// Local Prisma Postgres URL (from prisma dev output)
url: env('DATABASE_URL'),
},
})Workflow
1. Start local database:
prisma dev2. In another terminal, run migrations:
prisma migrate dev3. Generate client:
prisma generate4. Run your application
Production Migration
When ready for production, switch to Prisma Postgres cloud:
prisma init --dbUpdate your DATABASE_URL to the cloud connection string.
prisma format
Formats your Prisma schema file.
Command
prisma format [options]What It Does
- Fixes formatting (indentation, spacing)
- Adds missing back-relations (e.g., adds the other side of a relation)
- Adds missing relation arguments (e.g.,
fields,references) - Sorts fields and attributes (opinionated)
Options
| Option | Description |
|---|---|
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Examples
Format default schema
prisma formatFormat specific schema
prisma format --schema=./custom/schema.prismaBehavior
prisma format modifies the file in place. It is equivalent to "Prettier for Prisma schemas" but also has semantic understanding to fix/add missing schema definitions.
Use in Editor
Most Prisma editor extensions (VS Code, WebStorm) run prisma format automatically on save. This command is useful for:
- CI pipelines (check formatting)
- CLI-based workflows
- Fixing large schema refactors
prisma generate
Generates assets based on the generator blocks in your Prisma schema, most commonly Prisma Client.
Command
prisma generate [options]Bun Runtime
If you're using Bun, run Prisma with bunx --bun so it doesn't fall back to Node.js:
bunx --bun prisma generateWhat It Does
1. Reads your schema.prisma file 2. Generates a customized Prisma Client based on your models 3. Outputs to the directory specified in the generator block
Options
| Option | Description |
|---|---|
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
--sql | Generate typed sql module |
--watch | Watch the Prisma schema and rerun after a change |
--generator | Generator to use (may be provided multiple times) |
--no-hints | Hides the hint messages but still outputs errors and warnings |
--require-models | Do not allow generating a client without models |
Examples
Basic generation
prisma generateWatch mode (development)
prisma generate --watchAuto-regenerates when schema.prisma changes.
Specific generator
prisma generate --generator clientMultiple generators
prisma generate --generator client --generator zod_schemasTyped SQL generation
prisma generate --sqlSchema Configuration
generator client {
provider = "prisma-client"
output = "../generated"
}Current Generator Behavior
prisma-clientis the standard generatoroutputis required when usingprisma-clientprisma-clientsupports both ESM and CommonJS viamoduleFormatcompilerBuildsupportsfastandsmallquery compiler artifacts- Use TypeScript
satisfiesfor typed query fragments withprisma-client - Import Prisma Client from your generated output path, for example:
import { PrismaClient } from '../generated/prisma/client'Compiler Build Tuning
Use compilerBuild when you need to trade artifact size against the default build:
generator client {
provider = "prisma-client"
output = "../generated"
compilerBuild = "small"
}fastis the default build for most targetssmallis useful for size-constrained targets- Prisma defaults
vercel-edgetargets tosmall
Common Patterns
After schema changes
prisma migrate dev --name my_migration
prisma generateRun prisma generate whenever you need refreshed client code after schema-changing commands.
CI/CD pipeline
prisma generateRun before building your application.
Multiple generators
generator client {
provider = "prisma-client"
output = "../generated"
}
generator zod {
provider = "zod-prisma-types"
output = "../generated/zod"
}prisma generate # Runs all generatorsOutput Structure
After running prisma generate, your output directory contains:
generated/
├── browser.ts
├── client.ts
├── commonInputTypes.ts
├── models/
├── enums.ts
├── models.ts
└── ...Import the client:
import { PrismaClient, Prisma } from '../generated/prisma/client'Import browser-safe types:
import { Prisma } from '../generated/prisma/browser'
import { Role } from '../generated/prisma/enums'
import type { UserModel } from '../generated/prisma/models/User'prisma init
Bootstraps a fresh Prisma ORM project in the current directory.
Command
prisma init [options]Bun Runtime
If you're using Bun, run Prisma with bunx --bun so it doesn't fall back to Node.js:
bunx --bun prisma initWhat It Creates
prisma/schema.prisma- Your Prisma schema fileprisma.config.ts- TypeScript configuration for Prisma CLI.env- Environment variables (DATABASE_URL).gitignore- Ensures.envis ignored and appends the generated client path
Options
| Option | Description | Default |
|---|---|---|
--datasource-provider | Database provider: postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb | postgresql |
--db | Provisions a fully managed Prisma Postgres database on the Prisma Data Platform | - |
--url | Define a custom datasource url | - |
--generator-provider | Define the generator provider to use | prisma-client |
--output | Define Prisma Client generator output path to use | - |
--preview-feature | Define a preview feature to use | - |
--with-model | Add example model to created schema file | - |
Examples
Basic initialization
prisma initCreates a PostgreSQL project setup.
SQLite project
prisma init --datasource-provider sqliteMySQL with custom URL
prisma init --datasource-provider mysql --url "mysql://user:password@localhost:3306/mydb"Prisma Postgres (cloud)
prisma init --dbOpens browser for authentication, creates cloud database instance.
Add an example model
prisma init --with-modelAdds a starter model to the generated schema.
With preview features
prisma init --preview-feature relationJoins --preview-feature fullTextSearchGenerated Schema
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
}Generated Config (Node.js default)
// prisma.config.ts
import "dotenv/config";
import { defineConfig } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: process.env['DATABASE_URL'],
},
})Generated Config (Bun)
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: env('DATABASE_URL'),
},
})Next Steps After Init
1. Configure DATABASE_URL in .env (and let prisma.config.ts read it) 2. Define your models in prisma/schema.prisma 3. Run prisma dev for local development or connect to remote DB 4. Run prisma migrate dev to create migrations 5. Run prisma generate to generate Prisma Client 6. Run prisma db seed explicitly if you want seed data
prisma mcp
Starts Prisma's MCP server for AI development tools.
Command
prisma mcpWhat It Does
- Starts a Model Context Protocol (MCP) server for your Prisma project
- Exposes Prisma schema and database context to compatible AI tools
- Helps AI assistants understand models, generate queries, and suggest migrations
Usage
prisma mcpTypical Use Cases
- Connect Prisma to ChatGPT, Claude, or other MCP-aware tools
- Give an AI assistant access to your Prisma schema structure
- Help an agent propose queries, schema updates, and migration steps with project context
Notes
- Run this from the project that contains your Prisma schema and
prisma.config.ts - The command is separate from Prisma Studio and does not open a browser UI
- The MCP server wraps Prisma CLI commands. For exact behavior of commands like
migrate devormigrate reset, follow the underlying CLI command docs rather than relying only on the MCP tool descriptions.
References
prisma migrate deploy
Applies pending migrations in production/staging environments.
Command
prisma migrate deployWhat It Does
- Applies all pending migrations from
prisma/migrations/ - Updates
_prisma_migrationstable - Does NOT generate new migrations
- Does NOT run seed scripts
- Safe for CI/CD and production
Options
| Option | Description |
|---|---|
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
When to Use
- Production deployments
- Staging environments
- CI/CD pipelines
- Any non-development environment
Examples
Basic deployment
prisma migrate deployIn CI/CD pipeline
# GitHub Actions example
- name: Apply migrations
run: npx prisma migrate deploy
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}Docker deployment
# Run migrations before starting app
CMD npx prisma migrate deploy && node dist/index.jsComparison with migrate dev
| Feature | migrate dev | migrate deploy |
|---|---|---|
| Creates migrations | Yes | No |
| Applies migrations | Yes | Yes |
| Detects drift | Yes | No |
| Prompts for input | Yes | No |
| Uses shadow database | Yes | No |
| Safe for production | No | Yes |
| Resets on issues | Prompts | Fails |
Production Workflow
1. Development: Create migrations locally
prisma migrate dev --name add_feature2. Commit: Include migration files in version control
git add prisma/migrations
git commit -m "Add feature migration"3. Deploy: Apply in production
prisma migrate deployError Handling
Failed migration
If a migration fails, migrate deploy exits with error. The failed migration is marked as failed in _prisma_migrations.
To fix: 1. Resolve the issue (fix SQL, database state, etc.) 2. Mark as resolved: prisma migrate resolve --applied <migration_name> 3. Re-run: prisma migrate deploy
Check status first
prisma migrate statusShows pending and applied migrations before deploying.
Configuration
Ensure prisma.config.ts has the production database URL:
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
datasource: {
url: env('DATABASE_URL'),
},
})Best Practices
1. Always run migrate status before migrate deploy in CI 2. Have a rollback plan (backup before migrations) 3. Test migrations in staging first 4. Never use migrate dev in production
prisma migrate dev
Creates and applies migrations during development. Requires a shadow database.
Command
prisma migrate dev [options]What It Does
1. Runs existing migrations in shadow database to detect drift 2. Applies any pending migrations 3. Generates new migration from schema changes 4. Applies new migration to development database 5. Updates _prisma_migrations table
Options
| Option | Description |
|---|---|
--name / -n | Name the migration |
--create-only | Create a new migration but do not apply it |
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
--url | Override the datasource URL from the Prisma config file |
Follow-up Commands
- Run
prisma generateexplicitly when you need refreshed client output - Run
prisma db seedexplicitly when you need seed data
Note: Prisma CLI help for 7.6.0 still says migrate dev "trigger[s] generators", but local verification in a temp Prisma 7.6.0 project did not emit generated client files. Treat prisma generate as an explicit follow-up step when you need generated artifacts on disk.
Examples
Create and apply migration
prisma migrate devPrompts for migration name if schema changed.
Named migration
prisma migrate dev --name add_users_tableCreate without applying
prisma migrate dev --create-onlyUseful for reviewing migration SQL before applying.
Full workflow
prisma migrate dev --name my_migration
prisma generate
prisma db seedMigration Files
Created in prisma/migrations/:
prisma/migrations/
├── 20240115120000_add_users_table/
│ └── migration.sql
├── 20240116090000_add_posts/
│ └── migration.sql
└── migration_lock.tomlSchema Drift Detection
If migrate dev detects drift (manual database changes or edited migrations), it prompts to reset:
Drift detected: Your database schema is not in sync.
Do you want to reset your database? All data will be lost.When to Use
- Local development
- Adding new models/fields
- Changing relations
- Creating indexes
When NOT to Use
- Production deployments (use
migrate deploy) - CI/CD pipelines (use
migrate deploy) - MongoDB (use
db pushinstead)
Common Patterns
After schema changes
// schema.prisma - Add new field
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
createdAt DateTime @default(now()) // New field
}prisma migrate dev --name add_created_atHandling data loss warnings
When a migration would cause data loss:
prisma migrate dev --name remove_field
# Warning: You are about to delete data...
# Accept with: --accept-data-lossShadow Database
migrate dev requires a shadow database for drift detection. Configure in prisma.config.ts:
export default defineConfig({
datasource: {
url: env('DATABASE_URL'),
shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
},
})For local Prisma Postgres (prisma dev), shadow database is handled automatically.
prisma migrate diff
Compares database schemas and generates diffs (SQL or summary).
Command
prisma migrate diff [options]What It Does
- Compares two sources (
--from-...and--to-...) - Sources can be:
- Empty (
empty) - Schema file (
schema) - Migrations directory (
migrations) - Database URL (
url) or Configured Datasource (config-datasource) - Outputs the difference:
- Human-readable summary (default)
- SQL script (
--script)
Options
| Option | Description |
|---|---|
--script | Render SQL script to stdout |
--exit-code | Exit 2 if changes detected, 0 if empty, 1 if error |
--config | Custom path to your Prisma config file |
Sources (Must provide one from and one to)
--from-empty,--to-empty--from-schema <path>,--to-schema <path>--from-migrations <path>,--to-migrations <path>--from-url <url>,--to-url <url>--from-config-datasource,--to-config-datasource(usesprisma.config.ts)
Examples
Generate SQL for a schema change
Compare current production DB to your local schema:
prisma migrate diff \
--from-url "$PROD_DB_URL" \
--to-schema ./prisma/schema.prisma \
--scriptReview pending migrations
Compare database state to migrations directory:
prisma migrate diff \
--from-config-datasource \
--to-migrations ./prisma/migrationsCreate baseline migration
Compare empty state to current schema:
prisma migrate diff \
--from-empty \
--to-schema ./prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sqlCheck for drift (CI)
Check if database matches schema:
prisma migrate diff \
--from-config-datasource \
--to-schema ./prisma/schema.prisma \
--exit-codeUse Cases
- Forward-generating migrations: Creating SQL without
migrate dev. - Drift detection: Checking if DB is in sync.
- Baselining: Creating initial migration from existing DB.
- Debugging: Understanding what
migrate devwould do.
prisma migrate reset
Resets your database and re-applies all migrations.
Command
prisma migrate reset [options]What It Does
1. Drops the database (if possible) or deletes all data/tables 2. Re-creates the database 3. Applies all migrations from prisma/migrations/ 4. Stops there - run seed and generate explicitly if needed
Warning: All data will be lost.
Options
| Option | Description |
|---|---|
--force / -f | Skip confirmation prompt |
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Examples
Basic reset
prisma migrate resetPrompts for confirmation in interactive terminals.
Force reset (CI/Automation)
prisma migrate reset --forceWith custom schema
prisma migrate reset --schema=./custom/schema.prismaWhen to Use
- Development: When you want a fresh start
- Testing: Resetting test database before suites
- Drift Recovery: When the database is out of sync and you can't migrate
Follow-up Steps
Run prisma generate and prisma db seed explicitly when you need refreshed client output or seed data after a reset.
Configuration
Configure the seed script in prisma.config.ts, then run it explicitly after reset:
export default defineConfig({
migrations: {
seed: 'tsx prisma/seed.ts',
},
})Typical workflow:
prisma migrate reset --force
prisma generate
prisma db seedprisma migrate resolve
Resolves issues with database migrations, such as failed migrations or baselining.
Command
prisma migrate resolve [options]What It Does
Updates the _prisma_migrations table to manually change the state of a migration. This is a recovery tool.
Options
You must provide exactly one of --applied or --rolled-back.
| Option | Description |
|---|---|
--applied <name> | Mark a migration as applied (success) |
--rolled-back <name> | Mark a migration as rolled back (ignored/failed) |
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Examples
Mark as Applied (Baselining)
If you have existing tables and want to initialize migrations without running the SQL:
prisma migrate resolve --applied 20240101000000_initial_migrationThis tells Prisma "Assume this migration has already run".
Mark as Rolled Back (Fixing Failures)
If a migration failed (e.g., syntax error) and you fixed the SQL or want to retry:
prisma migrate resolve --rolled-back 20240115120000_failed_migrationThis tells Prisma "Forget this migration run, let me try applying it again".
Use Cases
1. Baselining: Adopting Prisma Migrate on an existing production database. 2. Failed Migrations: Recovering from a failed migrate deploy in production. 3. Hotfixes: reconciling manual database changes (rare).
References
prisma migrate status
Checks the status of your database migrations.
Command
prisma migrate status [options]What It Does
- Connects to the database
- Checks the
_prisma_migrationstable - Compares applied migrations with local migration files
- Reports:
- Status: Database is up-to-date or behind
- Unapplied migrations: Count of pending migrations
- Missing migrations: Migrations present in DB but missing locally
- Failed migrations: Any migrations that failed to apply
Options
| Option | Description |
|---|---|
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Examples
Check status
prisma migrate statusOutput example (Up to date):
Database schema is up to date!Output example (Pending):
Following migration have not yet been applied:
20240115120000_add_user
To apply migrations in development, run:
prisma migrate dev
To apply migrations in production, run:
prisma migrate deployWhen to Use
- Debugging: Why is
migrate devcomplaining about drift? - CI/CD: Verify database state before deploying
- Production: Check if migrations are needed (
migrate deploy) or if a deployment failed
Exit Codes
0: Success (may have pending migrations, but command ran successfully)1: Error
To check for pending migrations programmatically, you might need to parse the output or use migrate diff with exit code flags.
prisma studio
Opens a visual database browser for viewing and editing data.
Command
prisma studio [options]What It Does
- Starts a web-based database GUI
- View all your models and records
- Create, update, and delete records
- Filter and sort data
- Navigate relations
Options
| Option | Description | Default |
|---|---|---|
--port / -p | Port to start Studio on | 5555 |
--browser / -b | Browser to open Studio in | System default |
--config | Custom path to your Prisma config file | - |
--url | Database connection string (overrides the one in your Prisma config) | - |
Examples
Open Studio
prisma studioOpens at http://localhost:5555
Custom port
prisma studio --port 3000Specific browser
prisma studio --browser firefoxDon't open browser
BROWSER=none prisma studioUseful for remote servers.
Features
View Records
- See all records in table format
- Pagination for large datasets
- Column sorting
Filter Data
- Filter by any field
- Multiple conditions
- Relation filtering
Edit Records
- Click to edit inline
- Add new records
- Delete records (with confirmation)
Navigate Relations
- Click relations to view related records
- See counts of related items
- Follow relation links
Recent Studio Capabilities
Recent Prisma Studio releases added richer editor workflows:
- multi-cell selection and editing
- full-table search and more intuitive filtering
- command palette shortcuts
- dark mode
- copy selections as Markdown
- back-relation navigation
- SQL workflows including raw SQL queries
Some recent builds also expose AI-assisted SQL authoring. Treat these as interactive Studio features rather than a replacement for checked-in migrations or application queries.
Use Cases
- Development: Quick data inspection
- Debugging: Check data state
- Testing: Verify seed data
- Demo: Show data to stakeholders
Limitations
- Development tool only
- Not for production use
- Limited to configured database
- Prisma Studio in Prisma 7 currently targets PostgreSQL, MySQL, and SQLite first
- For reproducible application logic, prefer Prisma Client and checked-in SQL scripts
Common Workflow
1. Run migrations:
prisma migrate dev2. Seed data:
prisma db seed3. Open Studio to verify:
prisma studio4. Make manual edits if needed
Security Note
Studio provides direct database access. Only run on:
- Local development machines
- Secure internal networks
- Never expose publicly
prisma validate
Validates your Prisma schema file.
Command
prisma validate [options]What It Does
- Parses the
schema.prismafile - Checks for syntax errors
- Validates model definitions, relations, and types
- Reports any errors or warnings without generating code
Options
| Option | Description |
|---|---|
--schema | Path to schema file |
--config | Custom path to your Prisma config file |
Examples
Validate default schema
prisma validateValidate specific schema
prisma validate --schema=./custom/schema.prismaUse in CI
Run validate in your CI pipeline to catch schema errors early:
- name: Validate Schema
run: npx prisma validateCommon Errors
- Missing
@relationfields - Invalid types
- Duplicate model names
- Syntax errors (missing braces, etc.)
Related skills
Forks & variants (1)
Prisma Cli has 1 known copy in the catalog totaling 7 installs. They canonicalize to this original listing.
- prisma - 7 installs
How it compares
Pick prisma-cli over generic database skills when the task involves Prisma CLI syntax, flags, or migration workflows specifically.
FAQ
When should I use prisma migrate dev vs prisma migrate deploy?
Use prisma migrate dev during development to create and apply migrations locally. Use prisma migrate deploy in CI/CD production pipelines to apply only pending migrations without creating new ones.
How do I start a local Prisma Postgres database for development?
Run prisma dev to start a local Prisma Postgres instance. Use --detach to run in background, --name to specify instance name, and prisma dev stop/rm to manage instances.
Do I need to run prisma generate after migrations?
Yes, run prisma generate explicitly after migrate dev, db push, or other schema syncs when you need fresh Prisma Client output reflecting schema changes.
Is Prisma Cli safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.