Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/blog/content/blog/agents-md-for-databases/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Prototypes, bug reproductions, and test runs want a clean database that nobody e
npx create-db@latest --json
```

One command provisions a temporary Prisma Postgres database: real PostgreSQL, no account, no Docker daemon, deleted automatically after 24 hours. The `--json` flag makes the output parseable, so the agent takes `connectionString`, sets it as `DATABASE_URL` for the task at hand, and gets to work. The output also includes a `claimUrl`; if the result turns out to matter, claim it with a free Prisma account to keep it as a permanent database. You can pin one of six regions with `--region`; when the flag is omitted, the CLI picks the region closest to you, falling back to `us-east-1`.
One command provisions a temporary Prisma Postgres database: real PostgreSQL, no account, no Docker daemon, deleted automatically after 72 hours. The `--json` flag makes the output parseable, so the agent takes `connectionString`, sets it as `DATABASE_URL` for the task at hand, and gets to work. The output also includes a `claimUrl`; if the result turns out to matter, claim it with a free Prisma account to keep it as a permanent database. You can pin one of six regions with `--region`; when the flag is omitted, the CLI picks the region closest to you, falling back to `us-east-1`.

The rule tells the agent this is the default, not a fallback: when a task needs a database, create one, instead of borrowing whichever one is lying around in `.env`.

Expand Down Expand Up @@ -69,7 +69,7 @@ Terminal output with spinners and box-drawing characters is written for humans.

### Connection strings live in the environment

Provisioning databases on demand means connection strings flow through the agent's hands constantly, and each one contains credentials. The rule keeps them contained: connection strings live in environment variables only, never in source files, test fixtures, or commits, and a throwaway database's connection string stays scoped to the task at hand instead of overwriting the team's entry in `.env` with a URL that dies in 24 hours. When a throwaway database is worth keeping, the agent surfaces the claim URL to the human instead of quietly promoting scratch credentials into configuration.
Provisioning databases on demand means connection strings flow through the agent's hands constantly, and each one contains credentials. The rule keeps them contained: connection strings live in environment variables only, never in source files, test fixtures, or commits, and a throwaway database's connection string stays scoped to the task at hand instead of overwriting the team's entry in `.env` with a URL that dies in 72 hours. When a throwaway database is worth keeping, the agent surfaces the claim URL to the human instead of quietly promoting scratch credentials into configuration.

## The complete block to copy

Expand All @@ -81,7 +81,7 @@ Here is the full section, ready to paste into your AGENTS.md:
- When a task needs a database for testing or prototyping, run
`npx create-db@latest --json` and use the `connectionString` field as
`DATABASE_URL` for that task. The database is temporary and deletes
itself after 24 hours unless claimed. Always show me the `claimUrl`
itself after 72 hours unless claimed. Always show me the `claimUrl`
and `deletionDate`.
- Never run `prisma migrate reset`, drop a schema or table, or delete
data without my explicit confirmation. The only exception is a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Rows are ordered by the free storage one database can use, largest first; ties a

- **Only the database, online and free with no time limit:** Prisma Postgres, whose Free plan has 2 GB of storage per workspace (shared by its databases), 200,000 operations a month and no credit card. It moves a laptop database on PostgreSQL 17 or older in three steps (create, `pg_dump`, `pg_restore`); under 1 GB, Neon also fits, and the [size check](#how-big-is-your-laptop-database) shows which one fits.
- **A free database with no time limit, plus the app on the same account:** Prisma Postgres, with a Node.js, Bun or Next.js app on Prisma Compute.
- **Trying it before you sign up:** `npx create-db@latest` creates a temporary Prisma Postgres database that is deleted after 24 hours unless you claim it ([docs](https://www.prisma.io/docs/postgres/npx-create-db)).
- **Trying it before you sign up:** `npx create-db@latest` creates a temporary Prisma Postgres database that is deleted after 72 hours unless you claim it ([docs](https://www.prisma.io/docs/postgres/npx-create-db)).
- **Database branches, point-in-time restore or a PostgreSQL 18 source:** Neon, whose Free plan also has no time limit and no credit card, with 1 GB per project.
- **Auth and file storage from the database vendor:** Supabase.
- **An app already on Render or Railway:** that platform's Postgres.
Expand All @@ -77,7 +77,7 @@ Which Prisma Postgres path to follow depends on what you are moving:
| A database for any app, on PostgreSQL 17 or older | [Migrate a local Postgres database to the cloud](#migrate-a-local-postgres-database-to-the-cloud-create-pg_dump-pg_restore-swap-database_url): create the database, `pg_dump`, `pg_restore`, swap `DATABASE_URL` |
| A Prisma ORM project whose migration history has to come along | [If your app uses Prisma ORM](#if-your-app-uses-prisma-orm): the `_prisma_migrations` table is part of the dump, and `npx prisma@7 migrate status` confirms it arrived |
| The app as well as the database | [Prisma Compute](https://www.prisma.io/docs/compute): add a [Prisma Composer](https://www.prisma.io/docs/composer) declaration, with its config in the `composer` section of `prisma.config.ts` (`entry: './module.ts'`), run your build and deploy with `npx prisma deploy` |
| Throwaway data, to rehearse the restore before you sign up | `npx create-db@latest`, which creates a temporary Prisma Postgres database that is deleted after 24 hours unless you claim it |
| Throwaway data, to rehearse the restore before you sign up | `npx create-db@latest`, which creates a temporary Prisma Postgres database that is deleted after 72 hours unless you claim it |

Prisma Composer needs Node.js 22.18 or newer ([prerequisites](https://www.prisma.io/docs/prisma-compute/deploy#prerequisites)). An app you already have gets a `service.ts` per server and one `module.ts`, plus three changes to the server itself: read the port from `service.port()` and bind `0.0.0.0`, turn its other `process.env` reads into service inputs or dependencies, and build the Postgres client from the injected `db.url` ([porting an app](https://www.prisma.io/docs/composer/porting-an-app)). The Free plan includes a Compute allowance with no usage billing, while paid plans meter Compute memory, CPU and bandwidth on top of the plan price ([pricing](https://www.prisma.io/pricing)).

Expand Down Expand Up @@ -105,7 +105,7 @@ These steps work for any stack, because Prisma Postgres is standard PostgreSQL b

Steps 1 to 3 are the three that the table counts. If you would rather stay in a terminal, step 1 becomes three commands, `npx prisma auth login`, `npx prisma project create my-app` and `npx prisma postgres create mydb`, so the import takes five commands in all. The docs page [Migrate a local Postgres database to a managed Postgres service](https://www.prisma.io/docs/postgres/import-from-existing-database) has both paths, and the checks to run first for extensions and row-level security policies.

To rehearse steps 2 and 3 with throwaway data before you sign up, create a temporary Prisma Postgres database without an account and restore into the connection string it prints. It is deleted after 24 hours unless you claim it, and claiming it (free) needs a Prisma account:
To rehearse steps 2 and 3 with throwaway data before you sign up, create a temporary Prisma Postgres database without an account and restore into the connection string it prints. It is deleted after 72 hours unless you claim it, and claiming it (free) needs a Prisma account:

```bash
npx create-db@latest
Expand Down Expand Up @@ -185,7 +185,7 @@ npx prisma@7 db seed

Create the database in the [Prisma Console](https://console.prisma.io/sign-up) and copy both connection strings, as in the first step of [Migrate a local Postgres database to the cloud](#migrate-a-local-postgres-database-to-the-cloud-create-pg_dump-pg_restore-swap-database_url). Every Prisma Postgres database has [two connection strings](https://www.prisma.io/docs/postgres/database/connecting-to-your-database): **pooled** (`pooled.db.prisma.io`) for application traffic and **direct** (`db.prisma.io`) for migrations and tools like `pg_restore`. You will use both.

Two CLI alternatives: for a brand-new project, `npx prisma@7.9.1 init --db` scaffolds the schema and provisions a Prisma Postgres database in one go, and [`npx create-db@latest`](https://www.prisma.io/docs/postgres/npx-create-db) creates a temporary database with no sign-up, deleted after 24 hours unless you claim it.
Two CLI alternatives: for a brand-new project, `npx prisma@7.9.1 init --db` scaffolds the schema and provisions a Prisma Postgres database in one go, and [`npx create-db@latest`](https://www.prisma.io/docs/postgres/npx-create-db) creates a temporary database with no sign-up, deleted after 72 hours unless you claim it.

### Update env and config

Expand Down
18 changes: 9 additions & 9 deletions apps/blog/content/blog/give-your-agent-a-database/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors:
metaTitle: "npx create-db: Instant Postgres for Your Coding Agent"
metaDescription: "npx create-db gives coding agents a temporary Postgres database in seconds, no sign-up. JSON output lets Cursor, Claude Code, and Codex test on real Postgres."
heroImagePath: "/give-your-agent-a-database/imgs/hero.svg"
heroImageAlt: "A three step flow: a coding agent runs npx create-db@latest --json and gets a real Prisma Postgres database at db.prisma.io that deletes itself after 24 hours"
heroImageAlt: "A three step flow: a coding agent runs npx create-db@latest --json and gets a real Prisma Postgres database at db.prisma.io that deletes itself after 72 hours"
metaImagePath: "/give-your-agent-a-database/imgs/meta.png"
tags:
- "ai"
Expand All @@ -17,11 +17,11 @@ tags:

The fastest way to give a coding agent a database is one command: `npx create-db@latest`. It provisions a temporary [Prisma Postgres](https://www.prisma.io/docs/postgres) database, a managed serverless PostgreSQL instance, in a few seconds, with no sign-up and nothing to install. Add the `--json` flag and the output becomes machine-readable, so Cursor, Claude Code, Codex, or any other agent can provision a database and start testing without a human in the loop. In a project with no `.env` yet, `--env .env` writes `DATABASE_URL` and `CLAIM_URL` to a new one.

If the work turns out to matter, claim the database with a free Prisma account to keep it; the Free plan has 2 GB of storage per workspace and needs no card. Unclaimed databases are deleted after 24 hours. This post covers how `create-db` works, how it compares to Docker, SQLite, and mocks, and how to wire it into your agent's workflow.
If the work turns out to matter, claim the database with a free Prisma account to keep it; the Free plan has 2 GB of storage per workspace and needs no card. Unclaimed databases are deleted after 72 hours. This post covers how `create-db` works, how it compares to Docker, SQLite, and mocks, and how to wire it into your agent's workflow.

## What is npx create-db?

[`create-db`](https://www.prisma.io/docs/postgres/npx-create-db) is an open-source CLI that provisions temporary Prisma Postgres databases with a single command. Each database runs real PostgreSQL, requires no account, lives for 24 hours by default, and can be claimed into a permanent instance via a URL in the output. It runs anywhere Node.js 20.12 or later runs.
[`create-db`](https://www.prisma.io/docs/postgres/npx-create-db) is an open-source CLI that provisions temporary Prisma Postgres databases with a single command. Each database runs real PostgreSQL, requires no account, lives for 72 hours by default, and can be claimed into a permanent instance via a URL in the output. It runs anywhere Node.js 20.12 or later runs.

```bash
npx create-db@latest
Expand All @@ -33,7 +33,7 @@ A few seconds later:
┌ 🚀 Creating a Prisma Postgres database
│
│ Provisioning a temporary database...
│ It will be automatically deleted in 24 hours, but you can claim it.
│ It will be automatically deleted in 72 hours, but you can claim it.
◇ Database created successfully!
│
● Database Connection
Expand Down Expand Up @@ -67,7 +67,7 @@ Setup time compounds the problem. An agent that generates a working prototype in
| Works without a daemon or install | ✅ | ❌ | ✅ | ✅ |
| Runs in restricted agent sandboxes | ✅ | ❌ | ✅ | ✅ |
| Non-interactive, parseable output | ✅ (`--json`) | Manual scripting | n/a | n/a |
| Cleans up automatically | ✅ (24 h) | ❌ | ❌ | n/a |
| Cleans up automatically | ✅ (72 h) | ❌ | ❌ | n/a |
| Can graduate to production | ✅ (claim) | ❌ | ❌ | ❌ |

The short version: SQLite and mocks are fast but do not test what you ship, Docker tests what you ship but agents struggle to run it unattended, and `create-db` gives you real Postgres with none of the setup.
Expand Down Expand Up @@ -134,7 +134,7 @@ When you need a database for testing or prototyping, run:
npx create-db@latest --json

Parse the JSON output and use `connectionString` as `DATABASE_URL`.
The database is temporary and deletes itself after 24 hours.
The database is temporary and deletes itself after 72 hours.
Always show me the `claimUrl` and `deletionDate` so I can claim the database before it is deleted.
```

Expand All @@ -144,7 +144,7 @@ If your agent speaks MCP, the [Prisma MCP server](https://www.prisma.io/docs/ai/

`create-db` is deliberately scoped, and it is worth knowing the edges:

- **24-hour lifetime.** Unclaimed databases are deleted, data included. That is the point for scratch work, but do not put anything in one that you would miss. The `deletionDate` field tells you exactly when the clock runs out.
- **72-hour lifetime.** Unclaimed databases are deleted, data included. That is the point for scratch work, but do not put anything in one that you would miss. The `deletionDate` field tells you exactly when the clock runs out.
- **Temporary means temporary.** Until claimed, treat the database as a scratch environment, not a home for real user data. For an app whose data keeps disappearing, see [why an app's records vanish after a restart](https://www.prisma.io/postgres/app-data-lost-after-restart).
- **Fixed region set.** Six regions are available today. Pick the closest one with `--region` if latency matters for your test.

Expand All @@ -154,10 +154,10 @@ None of these bite in the intended use case, and the claim flow covers the momen

<Accordions type="single">
<Accordion title="What is npx create-db?">
`create-db` is an open-source CLI that provisions a temporary [Prisma Postgres](https://www.prisma.io/docs/postgres) database with one command, `npx create-db@latest`. No account is required, the database lives for 24 hours by default, and you can claim it with a free Prisma account, via the claim URL in the output, to keep it permanently.
`create-db` is an open-source CLI that provisions a temporary [Prisma Postgres](https://www.prisma.io/docs/postgres) database with one command, `npx create-db@latest`. No account is required, the database lives for 72 hours by default, and you can claim it with a free Prisma account, via the claim URL in the output, to keep it permanently.
</Accordion>
<Accordion title="How long does a create-db database last?">
24 hours from creation. After that the database and its data are deleted automatically. The exact timestamp is shown in the CLI output and returned as `deletionDate` in `--json` mode. Claiming the database before that time removes the expiry.
72 hours from creation. After that the database and its data are deleted automatically. The exact timestamp is shown in the CLI output and returned as `deletionDate` in `--json` mode. Claiming the database before that time removes the expiry.
</Accordion>
<Accordion title="How does an AI agent use create-db without human input?">
Run `npx create-db@latest --json`. The command prints a JSON object with `connectionString`, `claimUrl`, `deletionDate`, `region`, and `projectId`, then exits without any interactive prompts. The agent parses `connectionString` into `DATABASE_URL` and proceeds. This works in Claude Code, Cursor, Codex, and any environment that can run Node.js 20.12 or later.
Expand Down
2 changes: 1 addition & 1 deletion apps/blog/content/blog/introducing-create-prisma/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ npm create prisma@stable -- \

The CLI writes the connection string into `.env`. It can also generate Prisma Client, run the first migration, and seed the database.

Databases created this way are temporary for 24 hours until claimed. That makes it easy to try an idea quickly and keep the database if the project becomes real.
Databases created this way are temporary for 72 hours until claimed. That makes it easy to try an idea quickly and keep the database if the project becomes real.

## Optional AI and editor setup

Expand Down
2 changes: 1 addition & 1 deletion apps/blog/content/blog/prisma-orm-8-nestjs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Create a temporary Prisma Postgres database:
npx create-db@latest
```

The command prints a connection string and a claim link. The database is deleted after 24 hours unless you open the claim link and claim it with a free Prisma account to keep it.
The command prints a connection string and a claim link. The database is deleted after 72 hours unless you open the claim link and claim it with a free Prisma account to keep it.

Copy the connection string, export it in your terminal, then apply the starter contract to the database:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Answer the prompts (PostgreSQL, PSL, your package manager) or skip them:
npm create prisma@latest -- my-app --yes --provider postgres --authoring psl --template minimal
```

This scaffolds a contract at `src/prisma/contract.prisma`. Then create a [Prisma Postgres](https://www.prisma.io/docs/postgres) database with `npx create-db@latest` and export the connection string it prints as `DATABASE_URL` (the CLI reads the environment variable, not `.env`). The database is temporary for 24 hours; `create-db` also prints a claim URL; claim it with a free Prisma account to keep it.
This scaffolds a contract at `src/prisma/contract.prisma`. Then create a [Prisma Postgres](https://www.prisma.io/docs/postgres) database with `npx create-db@latest` and export the connection string it prints as `DATABASE_URL` (the CLI reads the environment variable, not `.env`). The database is temporary for 72 hours; `create-db` also prints a claim URL; claim it with a free Prisma account to keep it.

### Step 2: Model, plan, apply

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ We'll use:
- `pg` to connect to Postgres
- `create-db` to create a temporary Prisma Postgres database

The [`create-db`](https://www.prisma.io/docs/postgres/npx-create-db) CLI creates a temporary Prisma Postgres database (auto-deleted after 24 hours unless you claim it) and supports JSON output, which makes it useful from scripts. Prisma Postgres also works with PostgreSQL-compatible clients like `pg`.
The [`create-db`](https://www.prisma.io/docs/postgres/npx-create-db) CLI creates a temporary Prisma Postgres database (auto-deleted after 72 hours unless you claim it) and supports JSON output, which makes it useful from scripts. Prisma Postgres also works with PostgreSQL-compatible clients like `pg`.

Everything below was run against PostgreSQL 17, Bun 1.2, and pg 8.22.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const STEPS: StepSource[] = [
lang: "bash",
source: "npx create-db@latest --json",
caption:
"create-db spawns a temporary Prisma Postgres database, no account required. It is deleted after 24 hours unless you open the claim URL and claim it with a free Prisma account to keep it. Copy the connection string into .env.",
"create-db spawns a temporary Prisma Postgres database, no account required. It is deleted after 72 hours unless you open the claim URL and claim it with a free Prisma account to keep it. Copy the connection string into .env.",
output: [
"{",
' "connectionString": "postgres://…@db.prisma.io:5432/postgres",',
Expand Down
Loading
Loading