# generate (Prisma CLI v7)

Generate artifacts like Prisma Client based on your Prisma schema

The `prisma generate` command generates assets like Prisma Client based on the [`generator`](/guides/prisma-schema-overview-generators) and [`data model`](/guides/prisma-schema-data-model-models) blocks defined in your `schema.prisma` file.

## Usage

```bash
prisma generate [options]
```

## How it works

1. Inspects the current directory to find a Prisma schema
2. Generates a customized Prisma Client based on your schema into the output directory specified in the generator block

## Prerequisites

Add a generator definition in your `schema.prisma` file:

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

## Options

| Option             | Description                                            |
| ------------------ | ------------------------------------------------------ |
| `-h`, `--help`     | Display help message                                   |
| `--config`         | Custom path to your Prisma config file                 |
| `--schema`         | Custom path to your Prisma schema                      |
| `--sql`            | Generate typed SQL module                              |
| `--watch`          | Watch the Prisma schema and regenerate after changes   |
| `--generator`      | Generator to use (can be provided multiple times)      |
| `--no-hints`       | Hide hint messages (still outputs errors and warnings) |
| `--require-models` | Do not allow generating a client without models        |

## Examples

### Generate Prisma Client

:::code-group
```bash title="bun"
bunx prisma generate
```

```bash title="pnpm"
pnpm prisma generate
```

```bash title="yarn"
yarn prisma generate
```

```bash title="npm"
npx prisma generate
```
:::

Output:

```text
✔ Generated Prisma Client to ./node_modules/.prisma/client in 61ms

You can now start using Prisma Client in your code:

import { PrismaClient } from '../prisma/generated/client'

const prisma = new PrismaClient()
```

### Generate with a custom schema path

:::code-group
```bash title="bun"
bunx prisma generate --schema=./alternative/schema.prisma
```

```bash title="pnpm"
pnpm prisma generate --schema=./alternative/schema.prisma
```

```bash title="yarn"
yarn prisma generate --schema=./alternative/schema.prisma
```

```bash title="npm"
npx prisma generate --schema=./alternative/schema.prisma
```
:::

### Watch mode

Automatically regenerate when the schema changes:

:::code-group
```bash title="bun"
bunx prisma generate --watch
```

```bash title="pnpm"
pnpm prisma generate --watch
```

```bash title="yarn"
yarn prisma generate --watch
```

```bash title="npm"
npx prisma generate --watch
```
:::

Output:

```text
Watching... /home/prismauser/prisma/schema.prisma

✔ Generated Prisma Client to ./node_modules/.prisma/client in 45ms
```

### Generate specific generators

Run only specific generators:

:::code-group
```bash title="bun"
bunx prisma generate --generator client
```

```bash title="pnpm"
pnpm prisma generate --generator client
```

```bash title="yarn"
yarn prisma generate --generator client
```

```bash title="npm"
npx prisma generate --generator client
```
:::

Multiple generators:

:::code-group
```bash title="bun"
bunx prisma generate --generator client --generator zod_schemas
```

```bash title="pnpm"
pnpm prisma generate --generator client --generator zod_schemas
```

```bash title="yarn"
yarn prisma generate --generator client --generator zod_schemas
```

```bash title="npm"
npx prisma generate --generator client --generator zod_schemas
```
:::

## Generated assets

The `prisma-client` generator creates a customized client for working with your database. You can [customize the output folder](/guides/reference-5-prisma-schema-reference#fields-for-prisma-client-provider) using the `output` field in the generator block.

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
