Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Command

prisma generate

Generates artifacts such as Prisma Client from the generator and data model blocks in a Prisma schema. It can target a custom schema, select generators, generate typed SQL, or watch for changes.

How it works

The command locates a Prisma schema, runs the generators declared in it, and writes generated assets—commonly Prisma Client—to each generator's configured output directory. Use options to select a schema, restrict generators, generate typed SQL, or watch for schema changes.

Syntax

prisma generate [options]

Parameters

NameTypeDescription
optionsflagsOptional command-line flags controlling schema selection, generator selection, watch mode, SQL generation, hints, and model requirements.

Returns

Generated artifacts such as Prisma Client, written to the output directory configured by each generator.

Key points

  • With no path override, the command searches the current directory for the Prisma schema to process.
  • The generated client reflects the schema and is written to the generator's configured output directory.
  • Select one or more generators explicitly with repeated --generator options.
  • Use --schema when the schema is outside the command's default discovery location.
  • The --sql option adds generation of a typed SQL module.
  • Watch mode automatically reruns generation when the Prisma schema is modified.

Common mistakes

  • --watch keeps the command running and regenerates when the schema changes; it is not a one-shot invocation.

Example: Generate a configured Prisma Client

generator client {
  provider = "prisma-client"
  output   = "./generated"
}

// Run: bunx prisma generate

A generator block defines the Prisma Client provider and output directory; the command generates the client there.

When to use it

Update generated client

Build or refresh Prisma Client after changing models or generator configuration.

Watch schema changes

Keep generated artifacts synchronized during schema development.

Use an alternate schema

Generate from a schema stored outside the default location.

Generate typed SQL

Produce typed SQL alongside other generated assets.

Interview questions

QWhat does prisma generate do?

It reads the Prisma schema, finds the configured generator blocks, and creates the requested artifacts in the output directories declared by those generators. Prisma Client is the common generated artifact.

Follow-up: How would you generate only one configured generator? Use prisma generate --generator <name>; the option can be supplied multiple times when selecting several generators.

QWhich options are useful in development or CI?

The basic form is prisma generate [options]. Common options include --schema for a custom schema path, --generator to select generators, --watch to regenerate after changes, and --sql for a typed SQL module.

Follow-up: How can you generate from a non-default schema? Pass its path explicitly, for example prisma generate --schema=./alternative/schema.prisma.

QHow is the generated Prisma Client location determined?

The command uses the generator configuration in the target schema, including the provider and output directory. A prisma-client generator can therefore emit a customized client at the configured path.

Follow-up: What prevents accidental client generation without models? Use --require-models, which disallows generating a client when the schema has no models.

  • prisma-client
  • generator block
  • schema.prisma
  • --schema
  • --generator
  • --watch
  • --sql

Source: prisma generate | Generate Prisma Client & Artifacts (Prisma ORM v7). Checked 2026-10-16.