# prisma-next contract infer (/docs/cli/next/contract-infer)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Infer a starter contract from an existing database.

Location: CLI > Next > prisma-next contract infer

`prisma-next contract infer` inspects a live database and writes a starter PSL contract.

Use it when you are adding Prisma Next to an existing database and want an initial contract to review and edit.

## Usage [#usage]

```bash
prisma-next contract infer --db "$DATABASE_URL"
```

## Options [#options]

| Option            | What it does                                         |
| ----------------- | ---------------------------------------------------- |
| `--db <url>`      | Connects to the database.                            |
| `--config <path>` | Reads a specific `prisma-next.config.ts` file.       |
| `--output <path>` | Writes the inferred PSL contract to a specific path. |
| `--json`          | Prints a machine-readable result.                    |

## Examples [#examples]

```bash
prisma-next contract infer --db "$DATABASE_URL"
prisma-next contract infer --db "$DATABASE_URL" --output ./prisma/contract.prisma
prisma-next contract infer --db "$DATABASE_URL" --json
```

## What to review [#what-to-review]

Inference gives you a starting point, not a finished design. Review:

* model and field names
* relation names
* mapped database names
* defaults, indexes, and constraints
* extension-backed column types

Then run:

```bash
prisma-next contract emit
prisma-next db sign --db "$DATABASE_URL"
prisma-next db verify --db "$DATABASE_URL"
```

`db sign` is the handoff point where you record that the existing database matches the reviewed contract.

## Related pages

- [`CLI configuration`](https://www.prisma.io/docs/cli/next/configuration): Configure Prisma Next CLI commands with prisma-next.config.ts and global flags.
- [`prisma-next contract emit`](https://www.prisma.io/docs/cli/next/contract-emit): Emit Prisma Next contract artifacts.
- [`prisma-next db init`](https://www.prisma.io/docs/cli/next/db-init): Initialize a database from the current Prisma Next contract.
- [`prisma-next db schema`](https://www.prisma.io/docs/cli/next/db-schema): Inspect a live database schema.
- [`prisma-next db sign`](https://www.prisma.io/docs/cli/next/db-sign): Sign a database with the current Prisma Next contract.