# orm init (/docs/cli/orm-init)

> 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.

Initialize Prisma 8 files in a project.

Location: CLI > orm init

`orm init` scaffolds the Prisma 8 config, contract source, and runtime files inside an existing project, installs dependencies, and emits the contract. It gets you from zero to typed queries in one step.

Use a [Prisma 8 quickstart](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql) when you want a complete new application template. Use `orm init` when you already have a project and want to add the lower-level Prisma 8 files.

## Usage [#usage]

Run it interactively for a guided setup:

  

#### bun

```bash
bunx prisma@latest orm init
```

#### pnpm

```bash
pnpm dlx prisma@latest orm init
```

#### yarn

```bash
yarn dlx prisma@latest orm init
```

#### npm

```bash
npx prisma@latest orm init
```

Or supply `--target` and `--authoring` for a fully scriptable run (CI, AI coding agents, automation):

  

#### bun

```bash
bunx prisma@latest orm init --yes --target postgres --authoring psl
```

#### pnpm

```bash
pnpm dlx prisma@latest orm init --yes --target postgres --authoring psl
```

#### yarn

```bash
yarn dlx prisma@latest orm init --yes --target postgres --authoring psl
```

#### npm

```bash
npx prisma@latest orm init --yes --target postgres --authoring psl
```

## Options [#options]

| Option                   | What it does                                                                                                                        |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| `--target <db>`          | Sets the database target. Use `postgres` or `mongodb`.                                                                              |
| `--authoring <style>`    | Sets the contract authoring style. Use `psl` or `typescript`.                                                                       |
| `--schema-path <path>`   | Sets where the starter contract is written.                                                                                         |
| `--write-env`            | Writes `.env` from `.env.example` (gitignored).                                                                                     |
| `--probe-db`             | Connects to `DATABASE_URL` once and checks the server version.                                                                      |
| `--strict-probe`         | Treats a failed database probe as fatal.                                                                                            |
| `--skip-install`         | Skips dependency installation and contract emission.                                                                                |
| `--skip-skills`          | Skips installing the [Prisma 8 agent skills](https://www.prisma.io/docs/ai/tools/skills) (the version-pinned `prisma-8` usage skill plus the upgrade skills). |
| `--keep-previous-facade` | Keeps the previous target package in `package.json` when switching targets.                                                         |

## What it creates [#what-it-creates]

The exact files depend on the target and authoring style, but a Postgres PSL setup normally includes:

* `prisma.config.ts`
* a starter contract file such as `src/prisma/contract.prisma`
* emitted contract artifacts after installation runs
* a runtime client file (`src/prisma/db.ts`) that imports `contract.json`
* `.env.example`, `tsconfig.json`, and updated `package.json`

The runtime files are ES modules. If your `package.json` declares `"type": "commonjs"`, `orm init` keeps it and prints a warning. Set `"type": "module"` so the scaffolded `db.ts` loads.

The generated `prisma.config.ts` imports `definePrismaConfig` from `@prisma/cli-engine`, and the `contract:emit` script it adds calls `prisma-cli`, while projects created by `create-prisma` (and the examples in [Configuration](https://www.prisma.io/docs/cli/configuration)) import it from `prisma/config`. Both work; keep the import your project already has when you copy a config example. If the command ends with `CLI.INIT_SKILL_INSTALL_FAILED`, the files and dependencies are in place and only the skill install failed; run `npx prisma@latest skills sync` to install the skills.

## Examples [#examples]

  

#### bun

```bash
bunx prisma@latest orm init --yes --target postgres --authoring psl
bunx prisma@latest orm init --yes --target mongodb --authoring typescript --json
bunx prisma@latest orm init --skip-install
```

#### pnpm

```bash
pnpm dlx prisma@latest orm init --yes --target postgres --authoring psl
pnpm dlx prisma@latest orm init --yes --target mongodb --authoring typescript --json
pnpm dlx prisma@latest orm init --skip-install
```

#### yarn

```bash
yarn dlx prisma@latest orm init --yes --target postgres --authoring psl
yarn dlx prisma@latest orm init --yes --target mongodb --authoring typescript --json
yarn dlx prisma@latest orm init --skip-install
```

#### npm

```bash
npx prisma@latest orm init --yes --target postgres --authoring psl
npx prisma@latest orm init --yes --target mongodb --authoring typescript --json
npx prisma@latest orm init --skip-install
```

## After initialization [#after-initialization]

Review the generated files, set `DATABASE_URL`, and emit the contract when you change the schema:

  

#### bun

```bash
bunx prisma@latest contract emit
```

#### pnpm

```bash
pnpm dlx prisma@latest contract emit
```

#### yarn

```bash
yarn dlx prisma@latest contract emit
```

#### npm

```bash
npx prisma@latest contract emit
```

Then initialize or verify the database:

  

#### bun

```bash
bunx prisma@latest db init --db "$DATABASE_URL"
bunx prisma@latest db verify --db "$DATABASE_URL"
```

#### pnpm

```bash
pnpm dlx prisma@latest db init --db "$DATABASE_URL"
pnpm dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### yarn

```bash
yarn dlx prisma@latest db init --db "$DATABASE_URL"
yarn dlx prisma@latest db verify --db "$DATABASE_URL"
```

#### npm

```bash
npx prisma@latest db init --db "$DATABASE_URL"
npx prisma@latest db verify --db "$DATABASE_URL"
```

The scaffolded `db.ts` reads `DATABASE_URL` from the process environment at runtime. The CLI loads `.env` through the config file, but your own scripts do not. Run them with the variable set, for example `node --env-file=.env src/index.ts`.

## Related pages

- [`auth`](https://www.prisma.io/docs/cli/auth): Sign in to your Prisma account from the CLI, sign out, and manage workspace sessions.
- [`branch`](https://www.prisma.io/docs/cli/branch): List platform branches for a project.
- [`bucket`](https://www.prisma.io/docs/cli/bucket): Create and manage object-store buckets.
- [`Configuration`](https://www.prisma.io/docs/cli/configuration): Configure Prisma 8 CLI commands with prisma.config.ts and global flags.
- [`contract emit`](https://www.prisma.io/docs/cli/contract-emit): Emit Prisma 8 contract artifacts.