0
# Prisma CLI
1
2
Prisma CLI is a next-generation ORM toolkit that provides comprehensive database management, client generation, and development workflow capabilities. It includes type-safe query builder, declarative migrations, and GUI database management with support for multiple database systems including PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, and CockroachDB.
3
4
## Package Information
5
6
- **Package Name**: prisma
7
- **Package Type**: npm
8
- **Language**: TypeScript
9
- **Installation**: `npm install prisma`
10
- **Requirements**: Node.js >=18.18
11
12
## Core Imports
13
14
The Prisma CLI is primarily accessed via command line interface, but also exports types for configuration:
15
16
```typescript
17
import { PrismaConfig } from "prisma";
18
```
19
20
For configuration utilities:
21
22
```typescript
23
import { PrismaConfig } from "prisma/config";
24
```
25
26
ESM import:
27
```typescript
28
import { PrismaConfig } from "prisma";
29
```
30
31
CommonJS require:
32
```javascript
33
const { PrismaConfig } = require("prisma");
34
```
35
36
## Basic Usage
37
38
```bash
39
# Initialize new project
40
npx prisma init
41
42
# Start local development server
43
npx prisma dev
44
45
# Generate Prisma Client after schema changes
46
npx prisma generate
47
48
# Push schema changes to database
49
npx prisma db push
50
51
# Create and apply migrations
52
npx prisma migrate dev --name init
53
54
# Launch database GUI
55
npx prisma studio
56
57
# Format schema file
58
npx prisma format
59
60
# Display debug information
61
npx prisma debug
62
63
# Show telemetry information
64
npx prisma telemetry
65
```
66
67
With TypeScript configuration:
68
69
```typescript
70
// schema.prisma example
71
generator client {
72
provider = "prisma-client-js"
73
}
74
75
datasource db {
76
provider = "postgresql"
77
url = env("DATABASE_URL")
78
}
79
80
model User {
81
id Int @id @default(autoincrement())
82
email String @unique
83
name String?
84
}
85
```
86
87
## Architecture
88
89
Prisma CLI is built around several key components:
90
91
- **Core Commands**: Essential operations like generate, migrate, db operations, debug, telemetry
92
- **Platform Integration**: Authentication, workspace, and project management for Prisma Platform
93
- **Migration System**: Declarative schema migration with dev and deploy workflows
94
- **Studio**: Web-based GUI for database visualization and editing
95
- **MCP Server**: Model Context Protocol server for AI development tools integration
96
- **Dynamic Extensions**: On-demand loading of specialized CLI packages
97
- **External Packages**: Integration with external CLI packages like `@prisma/cli-init`, `@prisma/cli-security-rules`
98
- **Type Exports**: Provides TypeScript configuration types via `PrismaConfig` from `@prisma/config`
99
100
## Capabilities
101
102
### Client Generation
103
104
Generate type-safe Prisma Client from schema definitions with support for multiple generators and custom output options.
105
106
```bash { .api }
107
prisma generate [options]
108
109
Options:
110
--schema <path> Custom schema file path
111
--sql Generate typed SQL module
112
--watch Watch mode for continuous generation
113
--generator <name> Target specific generator
114
--no-engine Generate for Accelerate only
115
--no-hints Hide hint messages
116
--allow-no-models Allow schemas without models
117
--require-models Require models in schema
118
```
119
120
[Client Generation](./client-generation.md)
121
122
### Database Operations
123
124
Direct database operations including schema synchronization, raw query execution, and database introspection.
125
126
```bash { .api }
127
prisma db <command> [options]
128
129
Commands:
130
pull Pull schema from database
131
push Push schema changes to database
132
execute Execute raw SQL queries
133
seed Run database seeding
134
```
135
136
[Database Operations](./database-operations.md)
137
138
### Migration Management
139
140
Declarative data modeling and migration system with development and production workflows.
141
142
```bash { .api }
143
prisma migrate <command> [options]
144
145
Commands:
146
dev Development migrations with auto-generation
147
deploy Deploy pending migrations to production
148
status Check migration status
149
resolve Mark failed migrations as resolved
150
reset Reset database and apply all migrations
151
diff Generate migration diffs between states
152
```
153
154
[Migration Management](./migration-management.md)
155
156
### Studio Interface
157
158
Web-based GUI for database visualization, data editing, and relationship exploration with real-time updates.
159
160
```bash { .api }
161
prisma studio [options]
162
163
Options:
164
--port/-p <number> Custom port (default: 5555-5600 range)
165
--browser/-b <browser> Browser selection
166
--hostname/-n <host> Hostname binding
167
--schema <path> Schema file path
168
```
169
170
[Studio Interface](./studio-interface.md)
171
172
### Platform Integration
173
174
Authentication and project management for Prisma Platform services including Pulse, Accelerate, and workspace management.
175
176
```bash { .api }
177
prisma platform <command> [options]
178
179
Commands:
180
auth Authentication management
181
workspace Workspace operations
182
environment Environment management
183
project Project operations
184
serviceToken Service token management
185
pulse Real-time event streaming
186
accelerate Connection pooling and caching
187
```
188
189
[Platform Integration](./platform-integration.md)
190
191
### MCP Server
192
193
Model Context Protocol server for AI development tools integration, providing structured access to Prisma operations.
194
195
```bash { .api }
196
prisma mcp [options]
197
198
Options:
199
--early-access Enable early access features
200
201
MCP Tools:
202
migrate-status Check migration status
203
migrate-dev Run development migrations
204
migrate-reset Reset database (with --force)
205
Prisma-Studio Launch Studio interface
206
```
207
208
[MCP Server](./mcp-server.md)
209
210
### Schema Management
211
212
Schema validation, formatting, and development utilities for maintaining clean and valid Prisma schema files.
213
214
```bash { .api }
215
prisma format [options]
216
prisma validate [options]
217
218
Format Options:
219
--schema <path> Schema file path
220
--check Check formatting without modifying
221
222
Validate Options:
223
--schema <path> Schema file path
224
--config <path> Configuration file path
225
```
226
227
[Schema Management](./schema-management.md)
228
229
### Project Initialization
230
231
Set up a new Prisma project with schema files, configuration, and development environment.
232
233
```bash { .api }
234
prisma init [options]
235
236
Options:
237
--datasource-provider <provider> Database provider (postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb)
238
--url <url> Database connection URL
239
--help/-h Show help information
240
```
241
242
**Note**: This command is provided by the external package `@prisma/cli-init`.
243
244
### Development Server
245
246
Start a local Prisma Postgres server for development with automatic schema synchronization.
247
248
```bash { .api }
249
prisma dev [options]
250
251
Options:
252
--help/-h Show help information
253
```
254
255
**Note**: This command provides local development database capabilities.
256
257
### Debug Information
258
259
Display comprehensive debugging information including environment variables, paths, and configuration details.
260
261
```bash { .api }
262
prisma debug [options]
263
264
Options:
265
--schema <path> Custom path to Prisma schema file
266
--config <path> Custom path to configuration file
267
--help/-h Show help information
268
```
269
270
### Telemetry Information
271
272
Display telemetry cache information and project identifiers for debugging telemetry issues.
273
274
```bash { .api }
275
prisma telemetry [options]
276
277
Options:
278
--schema <path> Custom path to Prisma schema file
279
```
280
281
## Global Options
282
283
```bash { .api }
284
Global Options:
285
--help/-h Show help information
286
--version/-v Show version information
287
--config <path> Configuration file path
288
--json JSON output format (for version)
289
--experimental Enable experimental features
290
--preview-feature Enable preview features
291
--early-access Enable early access features
292
--telemetry-information Telemetry configuration
293
```
294
295
## Types
296
297
```typescript { .api }
298
// Configuration type from @prisma/config
299
export type { PrismaConfig } from '@prisma/config';
300
301
// Command interface (internal)
302
interface Command {
303
parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
304
help(error?: string): string;
305
}
306
307
// CLI global arguments
308
interface GlobalArgs {
309
'--help'?: boolean;
310
'--version'?: boolean;
311
'--config'?: string;
312
'--json'?: boolean;
313
'--experimental'?: boolean;
314
'--preview-feature'?: boolean;
315
'--early-access'?: boolean;
316
'--telemetry-information'?: string;
317
}
318
```