prisma generate
Generate artifacts (e.g. Prisma Client) from your Prisma schema.Usage
Options
Display help message.Alias:
-hCustom path to your Prisma config file.
Custom path to your Prisma schema file.
Generate typed SQL module for type-safe raw queries.
Watch the Prisma schema and automatically regenerate when changes are detected.
Specify which generator(s) to run. Can be provided multiple times to run specific generators.
Hide hint messages but still show errors and warnings.
Fail generation if the schema contains no models.
Examples
Basic generation
Generate Prisma Client with default settings:Specify a custom schema
Run specific generators
Generate only specific generators defined in your schema:Watch mode
Automatically regenerate when schema changes:Generate with typed SQL
Generate Prisma Client along with typed SQL queries:Output
Successful generation produces output similar to:Generators
Generators are defined in your Prisma schema:prisma generate, all generators are executed unless you specify specific ones with --generator.
Prisma Client Generation
The default Prisma Client generator (prisma-client-js) creates a type-safe database client based on your schema. The generated client includes:
- Type-safe queries for all models
- Auto-completion in your IDE
- Validation at compile time
- Query builder API
- Transaction support
- Middleware hooks
Watch Mode
In watch mode, Prisma continuously monitors your schema file for changes and automatically regenerates when it detects modifications. This is useful during development:Ctrl+C.
Version Mismatch Warning
If theprisma CLI version doesn’t match the @prisma/client version, you’ll see a warning:
Exit Codes
0- Generation successful1- Generation failed (schema errors, generator errors, etc.)
Related Commands
prisma validate- Validate your schema before generationprisma format- Format your schemaprisma migrate dev- Create and apply migrations, then generate