Skip to content

feat: add top-level Prisma Compute templates - #8562

Merged
AmanVarshney01 merged 1 commit into
latestfrom
aman/compute-root-folder
Jul 21, 2026
Merged

AmanVarshney01 merged 1 commit into
latestfrom
aman/compute-root-folder

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Moves the Prisma Compute examples to compute/hono, compute/nextjs, and compute/tanstack-start.
  • Adds compute/templates.json with source paths and smoke checks for click-to-deploy.
  • Adds prisma.compute.json and a lockfile to every template.
  • Generates Prisma Client as part of each production build.
  • Adds tests for manifest safety, frozen installs, Compute configs, and smoke markers.
compute/
  templates.json
  hono/
  nextjs/
  tanstack-start/

Checks

  • npx vitest run tests/compute.test.ts tests/deployment-platforms.test.ts
  • npm ci --ignore-scripts in all three templates
  • npm run build in all three templates with DATABASE_URL set

Summary by CodeRabbit

  • New Features
    • Added Prisma Compute example templates for Hono, Next.js, and TanStack Start.
    • Added sample applications with PostgreSQL setup, database schemas, seed data, API routes, and deployment configurations.
    • Added template metadata and validation coverage for the available examples.
  • Documentation
    • Added setup and deployment instructions for each example.
    • Updated repository documentation to highlight Prisma Compute examples.
  • Chores
    • Improved build steps to generate Prisma Client automatically.
    • Updated ignore rules for generated files and local configuration.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Prisma Compute examples for Hono, Next.js, and TanStack Start were added with Prisma schemas, seed scripts, deployment configuration, runtime routes, documentation, and template validation.

Changes

Prisma Compute templates

Layer / File(s) Summary
Template catalog and documentation
.gitignore, README.md, compute/README.md, compute/templates.json, deployment-platforms/README.md
Adds the Prisma Compute catalog, example descriptions, template manifest, and updated deployment-platform references.
Hono example application
compute/hono/*
Adds the Hono server, Prisma schema and seed workflow, PostgreSQL configuration, Compute metadata, build setup, and usage documentation.
Next.js example application
compute/nextjs/*
Adds the standalone Next.js App Router application, Prisma data workflow, API route, Compute configuration, build setup, and deployment documentation.
TanStack Start example application
compute/tanstack-start/*
Adds the TanStack Start routes, generated route tree, Prisma workflow, Nitro/Vite configuration, Compute metadata, styling, and deployment documentation.
Template validation and platform test updates
tests/compute.test.ts, tests/deployment-platforms.test.ts
Validates manifest structure, template contents, lockfiles, dry-run installation, and smoke text while replacing removed Compute test placeholders.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ComputeApp
  participant PrismaClient
  participant PostgreSQL
  Client->>ComputeApp: Request application page or /api/users
  ComputeApp->>PrismaClient: Query users with related posts
  PrismaClient->>PostgreSQL: Execute database query
  PostgreSQL-->>PrismaClient: Return users and posts
  PrismaClient-->>ComputeApp: Return query results
  ComputeApp-->>Client: Return rendered page or JSON
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding top-level Prisma Compute templates and examples.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 20, 2026
@AmanVarshney01
AmanVarshney01 force-pushed the aman/compute-root-folder branch from 369b26e to 3d45ee1 Compare July 21, 2026 15:41
@AmanVarshney01 AmanVarshney01 changed the title feat: add prisma.compute.json configs and templates manifest to Compute examples feat: add top-level Prisma Compute templates Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (3)
compute/nextjs/src/lib/prisma.ts (1)

11-13: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Cache the Prisma client during development.

This module constructs a new PostgreSQL pool and Prisma client whenever it is re-evaluated. Development reloads can therefore accumulate connections and eventually exhaust the database pool. Cache the client on globalThis in non-production, constructing the adapter only on a cache miss.

Proposed fix
-const adapter = new PrismaPg({ connectionString: databaseUrl });
-
-export const prisma = new PrismaClient({ adapter });
+const globalForPrisma = globalThis as typeof globalThis & {
+  prisma?: PrismaClient;
+};
+
+export const prisma =
+  globalForPrisma.prisma ??
+  new PrismaClient({
+    adapter: new PrismaPg({ connectionString: databaseUrl }),
+  });
+
+if (process.env.NODE_ENV !== "production") {
+  globalForPrisma.prisma = prisma;
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/nextjs/src/lib/prisma.ts` around lines 11 - 13, Update the Prisma
initialization around the exported prisma client to cache it on globalThis in
non-production environments, reusing the cached client on module reloads.
Construct PrismaPg and PrismaClient only on a cache miss, while preserving a
fresh client path for production.
compute/hono/.gitignore (1)

5-5: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Do not ignore Prisma migration history.

The README creates migrations under prisma/migrations; ignoring this directory means schema history is not tracked or reproducible from a fresh checkout. Remove this entry unless the template intentionally recreates migrations every time.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/hono/.gitignore` at line 5, Remove the prisma/migrations entry from
.gitignore so Prisma migration history generated by the README remains tracked
and reproducible from a fresh checkout.
compute/tanstack-start/.gitignore (1)

6-6: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

The documented migration workflow conflicts with the ignore policy. The README creates migrations, but the repository ignores them, preventing schema history from being reproduced from source control.

  • compute/tanstack-start/.gitignore#L6-L6: stop ignoring prisma/migrations unless schema application is intentionally out of band.
  • compute/tanstack-start/README.md#L21-L23: document the tracked migration workflow or explicitly document the required out-of-band schema step.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/tanstack-start/.gitignore` at line 6, Align the migration policy with
the documented workflow: in compute/tanstack-start/.gitignore at lines 6-6, stop
ignoring prisma/migrations so generated migration history can be committed; in
compute/tanstack-start/README.md at lines 21-23, document that migrations are
tracked and applied from source control, or explicitly document the required
out-of-band schema application step.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@compute/hono/prisma.config.ts`:
- Around line 10-12: Make the datasource URL in the Prisma configuration
optional by replacing the required env lookup in compute/hono/prisma.config.ts
at lines 10-12 with process.env.DATABASE_URL or an equivalent optional fallback,
while preserving the existing URL when provided. The build command in
compute/hono/package.json at line 7 requires no direct change; it should
continue allowing credential-free prisma generate.

In `@compute/hono/src/index.ts`:
- Around line 32-35: Update the user list rendering in the map callback used by
the root HTML response to HTML-escape user.name, user.email, and user.username
before interpolation, including fallback values as appropriate. Preserve the
existing displayed values and post counts while ensuring database-controlled
text cannot be interpreted as markup.

In `@compute/nextjs/prisma.config.ts`:
- Around line 10-12: Update the datasource configuration in prisma.config.ts to
read DATABASE_URL through process.env.DATABASE_URL instead of the throwing env
helper, so Prisma CLI commands such as generate can load without the variable
being set.

In `@compute/tanstack-start/src/styles.css`:
- Around line 17-19: Update the global anchor rule in styles.css to use a link
color with at least 4.5:1 contrast against the default white canvas, replacing
`#0c6` while preserving the existing link styling scope.

In `@tests/compute.test.ts`:
- Around line 75-80: Update the rootEntries validation in the compute test to
read and parse prisma.compute.json rather than only asserting its filename is
present. Assert the required Compute configuration fields, including the
framework metadata and Hono port setting, while retaining the existing
supported-lockfile assertion.
- Around line 9-13: Update the smoke validation in the test setup and the
affected smoke checks to use each template manifest’s template.smoke.path
instead of the hardcoded smokeRouteByFramework mapping. Assert that the declared
path matches the expected framework contract, then read and validate that
declared path so incorrect deployment routes fail the tests.
- Around line 82-92: Extend the test flow around the existing execa npm ci
dry-run to add a dedicated clean-build assertion. After dependency installation,
run the repository’s package-manager-specific build command in its own CI step,
ensuring the build executes without ignored scripts and validates required
generation such as prisma generate.

---

Nitpick comments:
In `@compute/hono/.gitignore`:
- Line 5: Remove the prisma/migrations entry from .gitignore so Prisma migration
history generated by the README remains tracked and reproducible from a fresh
checkout.

In `@compute/nextjs/src/lib/prisma.ts`:
- Around line 11-13: Update the Prisma initialization around the exported prisma
client to cache it on globalThis in non-production environments, reusing the
cached client on module reloads. Construct PrismaPg and PrismaClient only on a
cache miss, while preserving a fresh client path for production.

In `@compute/tanstack-start/.gitignore`:
- Line 6: Align the migration policy with the documented workflow: in
compute/tanstack-start/.gitignore at lines 6-6, stop ignoring prisma/migrations
so generated migration history can be committed; in
compute/tanstack-start/README.md at lines 21-23, document that migrations are
tracked and applied from source control, or explicitly document the required
out-of-band schema application step.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6fa1f139-540c-4595-8c89-afbf96356d11

📥 Commits

Reviewing files that changed from the base of the PR and between 369b26e and 3d45ee1.

⛔ Files ignored due to path filters (3)
  • compute/hono/package-lock.json is excluded by !**/package-lock.json
  • compute/nextjs/package-lock.json is excluded by !**/package-lock.json
  • compute/tanstack-start/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (49)
  • .gitignore
  • README.md
  • compute/README.md
  • compute/hono/.env.example
  • compute/hono/.gitignore
  • compute/hono/README.md
  • compute/hono/package.json
  • compute/hono/prisma.compute.json
  • compute/hono/prisma.config.ts
  • compute/hono/prisma/schema.prisma
  • compute/hono/prisma/seed.ts
  • compute/hono/src/index.ts
  • compute/hono/src/lib/prisma.ts
  • compute/hono/tsconfig.json
  • compute/nextjs/.env.example
  • compute/nextjs/.gitignore
  • compute/nextjs/README.md
  • compute/nextjs/next.config.ts
  • compute/nextjs/package.json
  • compute/nextjs/prisma.compute.json
  • compute/nextjs/prisma.config.ts
  • compute/nextjs/prisma/schema.prisma
  • compute/nextjs/prisma/seed.ts
  • compute/nextjs/src/app/api/users/route.ts
  • compute/nextjs/src/app/layout.tsx
  • compute/nextjs/src/app/page.tsx
  • compute/nextjs/src/lib/prisma.ts
  • compute/nextjs/tsconfig.json
  • compute/tanstack-start/.env.example
  • compute/tanstack-start/.gitignore
  • compute/tanstack-start/README.md
  • compute/tanstack-start/package.json
  • compute/tanstack-start/prisma.compute.json
  • compute/tanstack-start/prisma.config.ts
  • compute/tanstack-start/prisma/schema.prisma
  • compute/tanstack-start/prisma/seed.ts
  • compute/tanstack-start/src/lib/prisma.server.ts
  • compute/tanstack-start/src/routeTree.gen.ts
  • compute/tanstack-start/src/router.tsx
  • compute/tanstack-start/src/routes/__root.tsx
  • compute/tanstack-start/src/routes/api/users.ts
  • compute/tanstack-start/src/routes/index.tsx
  • compute/tanstack-start/src/styles.css
  • compute/tanstack-start/tsconfig.json
  • compute/tanstack-start/vite.config.ts
  • compute/templates.json
  • deployment-platforms/README.md
  • tests/compute.test.ts
  • tests/deployment-platforms.test.ts
💤 Files with no reviewable changes (2)
  • deployment-platforms/README.md
  • tests/deployment-platforms.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 7

🧹 Nitpick comments (3)
compute/nextjs/src/lib/prisma.ts (1)

11-13: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Cache the Prisma client during development.

This module constructs a new PostgreSQL pool and Prisma client whenever it is re-evaluated. Development reloads can therefore accumulate connections and eventually exhaust the database pool. Cache the client on globalThis in non-production, constructing the adapter only on a cache miss.

Proposed fix
-const adapter = new PrismaPg({ connectionString: databaseUrl });
-
-export const prisma = new PrismaClient({ adapter });
+const globalForPrisma = globalThis as typeof globalThis & {
+  prisma?: PrismaClient;
+};
+
+export const prisma =
+  globalForPrisma.prisma ??
+  new PrismaClient({
+    adapter: new PrismaPg({ connectionString: databaseUrl }),
+  });
+
+if (process.env.NODE_ENV !== "production") {
+  globalForPrisma.prisma = prisma;
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/nextjs/src/lib/prisma.ts` around lines 11 - 13, Update the Prisma
initialization around the exported prisma client to cache it on globalThis in
non-production environments, reusing the cached client on module reloads.
Construct PrismaPg and PrismaClient only on a cache miss, while preserving a
fresh client path for production.
compute/hono/.gitignore (1)

5-5: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Do not ignore Prisma migration history.

The README creates migrations under prisma/migrations; ignoring this directory means schema history is not tracked or reproducible from a fresh checkout. Remove this entry unless the template intentionally recreates migrations every time.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/hono/.gitignore` at line 5, Remove the prisma/migrations entry from
.gitignore so Prisma migration history generated by the README remains tracked
and reproducible from a fresh checkout.
compute/tanstack-start/.gitignore (1)

6-6: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

The documented migration workflow conflicts with the ignore policy. The README creates migrations, but the repository ignores them, preventing schema history from being reproduced from source control.

  • compute/tanstack-start/.gitignore#L6-L6: stop ignoring prisma/migrations unless schema application is intentionally out of band.
  • compute/tanstack-start/README.md#L21-L23: document the tracked migration workflow or explicitly document the required out-of-band schema step.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/tanstack-start/.gitignore` at line 6, Align the migration policy with
the documented workflow: in compute/tanstack-start/.gitignore at lines 6-6, stop
ignoring prisma/migrations so generated migration history can be committed; in
compute/tanstack-start/README.md at lines 21-23, document that migrations are
tracked and applied from source control, or explicitly document the required
out-of-band schema application step.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@compute/hono/prisma.config.ts`:
- Around line 10-12: Make the datasource URL in the Prisma configuration
optional by replacing the required env lookup in compute/hono/prisma.config.ts
at lines 10-12 with process.env.DATABASE_URL or an equivalent optional fallback,
while preserving the existing URL when provided. The build command in
compute/hono/package.json at line 7 requires no direct change; it should
continue allowing credential-free prisma generate.

In `@compute/hono/src/index.ts`:
- Around line 32-35: Update the user list rendering in the map callback used by
the root HTML response to HTML-escape user.name, user.email, and user.username
before interpolation, including fallback values as appropriate. Preserve the
existing displayed values and post counts while ensuring database-controlled
text cannot be interpreted as markup.

In `@compute/nextjs/prisma.config.ts`:
- Around line 10-12: Update the datasource configuration in prisma.config.ts to
read DATABASE_URL through process.env.DATABASE_URL instead of the throwing env
helper, so Prisma CLI commands such as generate can load without the variable
being set.

In `@compute/tanstack-start/src/styles.css`:
- Around line 17-19: Update the global anchor rule in styles.css to use a link
color with at least 4.5:1 contrast against the default white canvas, replacing
`#0c6` while preserving the existing link styling scope.

In `@tests/compute.test.ts`:
- Around line 75-80: Update the rootEntries validation in the compute test to
read and parse prisma.compute.json rather than only asserting its filename is
present. Assert the required Compute configuration fields, including the
framework metadata and Hono port setting, while retaining the existing
supported-lockfile assertion.
- Around line 9-13: Update the smoke validation in the test setup and the
affected smoke checks to use each template manifest’s template.smoke.path
instead of the hardcoded smokeRouteByFramework mapping. Assert that the declared
path matches the expected framework contract, then read and validate that
declared path so incorrect deployment routes fail the tests.
- Around line 82-92: Extend the test flow around the existing execa npm ci
dry-run to add a dedicated clean-build assertion. After dependency installation,
run the repository’s package-manager-specific build command in its own CI step,
ensuring the build executes without ignored scripts and validates required
generation such as prisma generate.

---

Nitpick comments:
In `@compute/hono/.gitignore`:
- Line 5: Remove the prisma/migrations entry from .gitignore so Prisma migration
history generated by the README remains tracked and reproducible from a fresh
checkout.

In `@compute/nextjs/src/lib/prisma.ts`:
- Around line 11-13: Update the Prisma initialization around the exported prisma
client to cache it on globalThis in non-production environments, reusing the
cached client on module reloads. Construct PrismaPg and PrismaClient only on a
cache miss, while preserving a fresh client path for production.

In `@compute/tanstack-start/.gitignore`:
- Line 6: Align the migration policy with the documented workflow: in
compute/tanstack-start/.gitignore at lines 6-6, stop ignoring prisma/migrations
so generated migration history can be committed; in
compute/tanstack-start/README.md at lines 21-23, document that migrations are
tracked and applied from source control, or explicitly document the required
out-of-band schema application step.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6fa1f139-540c-4595-8c89-afbf96356d11

📥 Commits

Reviewing files that changed from the base of the PR and between 369b26e and 3d45ee1.

⛔ Files ignored due to path filters (3)
  • compute/hono/package-lock.json is excluded by !**/package-lock.json
  • compute/nextjs/package-lock.json is excluded by !**/package-lock.json
  • compute/tanstack-start/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (49)
  • .gitignore
  • README.md
  • compute/README.md
  • compute/hono/.env.example
  • compute/hono/.gitignore
  • compute/hono/README.md
  • compute/hono/package.json
  • compute/hono/prisma.compute.json
  • compute/hono/prisma.config.ts
  • compute/hono/prisma/schema.prisma
  • compute/hono/prisma/seed.ts
  • compute/hono/src/index.ts
  • compute/hono/src/lib/prisma.ts
  • compute/hono/tsconfig.json
  • compute/nextjs/.env.example
  • compute/nextjs/.gitignore
  • compute/nextjs/README.md
  • compute/nextjs/next.config.ts
  • compute/nextjs/package.json
  • compute/nextjs/prisma.compute.json
  • compute/nextjs/prisma.config.ts
  • compute/nextjs/prisma/schema.prisma
  • compute/nextjs/prisma/seed.ts
  • compute/nextjs/src/app/api/users/route.ts
  • compute/nextjs/src/app/layout.tsx
  • compute/nextjs/src/app/page.tsx
  • compute/nextjs/src/lib/prisma.ts
  • compute/nextjs/tsconfig.json
  • compute/tanstack-start/.env.example
  • compute/tanstack-start/.gitignore
  • compute/tanstack-start/README.md
  • compute/tanstack-start/package.json
  • compute/tanstack-start/prisma.compute.json
  • compute/tanstack-start/prisma.config.ts
  • compute/tanstack-start/prisma/schema.prisma
  • compute/tanstack-start/prisma/seed.ts
  • compute/tanstack-start/src/lib/prisma.server.ts
  • compute/tanstack-start/src/routeTree.gen.ts
  • compute/tanstack-start/src/router.tsx
  • compute/tanstack-start/src/routes/__root.tsx
  • compute/tanstack-start/src/routes/api/users.ts
  • compute/tanstack-start/src/routes/index.tsx
  • compute/tanstack-start/src/styles.css
  • compute/tanstack-start/tsconfig.json
  • compute/tanstack-start/vite.config.ts
  • compute/templates.json
  • deployment-platforms/README.md
  • tests/compute.test.ts
  • tests/deployment-platforms.test.ts
💤 Files with no reviewable changes (2)
  • deployment-platforms/README.md
  • tests/deployment-platforms.test.ts
🛑 Comments failed to post (7)
compute/hono/prisma.config.ts (1)

10-12: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== package.json ==\n'
cat -n compute/hono/package.json

printf '\n== prisma.config.ts ==\n'
cat -n compute/hono/prisma.config.ts

printf '\n== search for DATABASE_URL usage ==\n'
rg -n "DATABASE_URL|prisma generate|prisma.config" compute/hono -S

Repository: prisma/prisma-examples

Length of output: 1973


🌐 Web query:

Prisma config env() DATABASE_URL prisma generate config load behavior

💡 Result:

In Prisma, the env() helper function from prisma/config is designed to strictly enforce the presence of environment variables [1][2]. When used in prisma.config.ts, this helper will throw a PrismaConfigEnvError and prevent any Prisma CLI command from executing if the specified environment variable is missing [1][2][3]. Because every Prisma CLI command loads the prisma.config.ts file upon execution, this can cause issues with commands that do not strictly require a database URL—such as prisma generate [1][2][4]. While prisma generate primarily uses the schema file to generate the client, the configuration load behavior forces a check of all env() calls within prisma.config.ts [1][4]. To handle scenarios where an environment variable (like DATABASE_URL) may be optional or missing (e.g., in certain CI/CD pipelines or environments where the URL is not needed for specific commands), you should avoid the env() helper [1][2][4]. Instead, you should access the environment variable directly using process.env [1][4][3]. Recommended patterns: For strict requirements (ensures the variable exists): import { env } from 'prisma/config';... datasource: { url: env("DATABASE_URL"), }, For optional requirements (avoids errors if missing): datasource: { url: process.env.DATABASE_URL!, // or use a fallback: process.env.DATABASE_URL?? '' }, To ensure Prisma can read your .env file within the prisma.config.ts context, you must also manually import dotenv/config at the top of your prisma.config.ts file [1][2][5].

Citations:


Avoid requiring DATABASE_URL for prisma generate.
env("DATABASE_URL") makes Prisma fail while loading compute/hono/prisma.config.ts, so the build step in compute/hono/package.json breaks in environments that don’t provide database credentials. Use process.env.DATABASE_URL or another optional fallback there so client generation stays credential-free.

📍 Affects 2 files
  • compute/hono/prisma.config.ts#L10-L12 (this comment)
  • compute/hono/package.json#L7-L7
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/hono/prisma.config.ts` around lines 10 - 12, Make the datasource URL
in the Prisma configuration optional by replacing the required env lookup in
compute/hono/prisma.config.ts at lines 10-12 with process.env.DATABASE_URL or an
equivalent optional fallback, while preserving the existing URL when provided.
The build command in compute/hono/package.json at line 7 requires no direct
change; it should continue allowing credential-free prisma generate.
compute/hono/src/index.ts (1)

32-35: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Escape database values before embedding them in HTML.

user.name, user.email, and user.username are interpolated directly into c.html; any non-seed value containing markup will execute when / is viewed. HTML-escape these text values before interpolation or use a context-aware renderer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/hono/src/index.ts` around lines 32 - 35, Update the user list
rendering in the map callback used by the root HTML response to HTML-escape
user.name, user.email, and user.username before interpolation, including
fallback values as appropriate. Preserve the existing displayed values and post
counts while ensuring database-controlled text cannot be interpreted as markup.
compute/nextjs/prisma.config.ts (1)

10-12: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,120p' compute/nextjs/prisma.config.ts
printf '\n---\n'
sed -n '1,220p' compute/nextjs/package.json
printf '\n---\n'
rg -n "prisma generate|DATABASE_URL|prisma/config|env\\(" compute/nextjs -S

Repository: prisma/prisma-examples

Length of output: 1973


🌐 Web query:

Prisma config reference env("DATABASE_URL") missing environment variable prisma generate loads config build failure

💡 Result:

The error occurs because the env() helper function in prisma.config.ts (introduced in Prisma ORM v7) is designed to enforce the presence of environment variables [1][2]. When you run any Prisma CLI command—including prisma generate—Prisma loads your prisma.config.ts file [1][2][3]. If env("DATABASE_URL") is used, the env() function immediately throws a PrismaConfigEnvError if the specified variable is undefined, causing the entire command to fail, even if the specific command (like generate) does not strictly require a database connection [1][2][3]. To resolve this issue in environments where the database URL is not available (such as CI/CD pipelines or Docker build stages), use process.env instead of the env() helper [1][2][3]. ### Recommended Solution Replace the env() helper in your prisma.config.ts with direct access to process.env [2][3]: typescript import "dotenv/config"; import { defineConfig } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", // ... other config datasource: { // Using process.env avoids the strict validation enforced by env() url: process.env.DATABASE_URL!, }, }); ### Why this happens 1. The env() helper from prisma/config is intended for scenarios where you want to strictly enforce that a configuration value must be present [2]. 2. Because prisma.config.ts is loaded by every Prisma CLI command, the env() validation runs prematurely for commands that do not actually need to connect to a database [1][2]. 3. By using process.env.DATABASE_URL (or providing a fallback like process.env.DATABASE_URL ?? ''), you bypass the env() helper's strict requirement, allowing prisma generate to complete successfully even when the URL is missing [2][3]. ### Additional Tips - Ensure you have dotenv/config imported at the top of your prisma.config.ts to ensure local .env files are loaded into process.env [1][4][2]. - If you are in a CI/Docker environment, you can also set a dummy value during the build step (e.g., DATABASE_URL=ignore prisma generate) as a temporary workaround [5][3], but the process.env approach is the recommended, cleaner fix [2].

Citations:


Keep Prisma config loading independent of DATABASE_URL.

prisma.config.ts is loaded by every Prisma CLI command, and env("DATABASE_URL") throws if the variable is missing. That makes prisma generate fail during npm run build in environments that don’t inject the database URL. Use process.env.DATABASE_URL here, or guarantee the variable is always present at build time.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/nextjs/prisma.config.ts` around lines 10 - 12, Update the datasource
configuration in prisma.config.ts to read DATABASE_URL through
process.env.DATABASE_URL instead of the throwing env helper, so Prisma CLI
commands such as generate can load without the variable being set.

Source: MCP tools

compute/tanstack-start/src/styles.css (1)

17-19: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a contrast-safe link color.

#0c6 on the default white canvas is approximately 2.1:1, below the WCAG AA 4.5:1 minimum for normal text. (w3.org)

Proposed fix
 a {
-  color: `#0c6`;
+  color: `#006b3c`;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

a {
  color: `#006b3c`;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/tanstack-start/src/styles.css` around lines 17 - 19, Update the
global anchor rule in styles.css to use a link color with at least 4.5:1
contrast against the default white canvas, replacing `#0c6` while preserving the
existing link styling scope.

Source: MCP tools

tests/compute.test.ts (3)

9-13: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Exercise the manifest-declared smoke path.

template.smoke.path is validated but ignored; the test reads a hardcoded source file instead. A manifest can declare an incorrect deployment route and still pass. Assert the declared path against the framework contract and use it in smoke validation.

Also applies to: 67-70, 94-102

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/compute.test.ts` around lines 9 - 13, Update the smoke validation in
the test setup and the affected smoke checks to use each template manifest’s
template.smoke.path instead of the hardcoded smokeRouteByFramework mapping.
Assert that the declared path matches the expected framework contract, then read
and validate that declared path so incorrect deployment routes fail the tests.

75-80: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Validate prisma.compute.json contents, not just its presence.

A malformed configuration or missing framework/port metadata can pass because the test only counts the filename. Parse each file and assert the required Compute configuration, including Hono’s port setting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/compute.test.ts` around lines 75 - 80, Update the rootEntries
validation in the compute test to read and parse prisma.compute.json rather than
only asserting its filename is present. Assert the required Compute
configuration fields, including the framework metadata and Hono port setting,
while retaining the existing supported-lockfile assertion.

82-92: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant test file and nearby context.
wc -l tests/compute.test.ts
sed -n '1,180p' tests/compute.test.ts

# Find package manifests and scripts that the test might be exercising.
git ls-files '**/package.json' '**/npm-shrinkwrap.json' '**/package-lock.json' '**/pnpm-lock.yaml' '**/yarn.lock'

# Look for build/generate-related scripts and prisma usage.
rg -n '"(build|generate|prisma|prepare|postinstall|prebuild)"' -g 'package.json' -g '!**/node_modules/**' .
rg -n 'prisma generate|npm run build|build:' -g '!**/node_modules/**' .

Repository: prisma/prisma-examples

Length of output: 1973


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the test file structure so we only read the needed parts if it is large.
ast-grep outline tests/compute.test.ts --view expanded

Repository: prisma/prisma-examples

Length of output: 1973


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the test file around the relevant lines.
cat -n tests/compute.test.ts | sed -n '1,180p'

Repository: prisma/prisma-examples

Length of output: 1973


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the full test file with line numbers.
cat -n tests/compute.test.ts

# Show neighboring test filenames to infer the suite's purpose.
git ls-files tests | sed -n '1,200p'

Repository: prisma/prisma-examples

Length of output: 1973


Add a clean-build assertion. This only runs npm ci --dry-run --ignore-scripts, so it won’t catch build failures or missing prisma generate. Run the package-manager-specific build in a dedicated CI step.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/compute.test.ts` around lines 82 - 92, Extend the test flow around the
existing execa npm ci dry-run to add a dedicated clean-build assertion. After
dependency installation, run the repository’s package-manager-specific build
command in its own CI step, ensuring the build executes without ignored scripts
and validates required generation such as prisma generate.

Source: MCP tools

@AmanVarshney01

Copy link
Copy Markdown
Member Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

@AmanVarshney01
AmanVarshney01 merged commit fedbbeb into latest Jul 21, 2026
6 of 9 checks passed
@AmanVarshney01
AmanVarshney01 deleted the aman/compute-root-folder branch July 21, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant