You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: prisma-compute/SKILL.md
+37-20Lines changed: 37 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: prisma-compute
3
-
description: Prisma Compute deployment and hosting guide. Use whenever the user mentions Prisma Compute, `prisma.compute.ts`, `defineComputeConfig`, deploying or hosting a Prisma app, `@prisma/cli app deploy`, `compute:deploy`, `create-prisma --deploy`, `PRISMA_SERVICE_TOKEN`, Compute apps/deployments/logs/domains, localhost vs `0.0.0.0`, deploy port binding, or framework deploy readiness for Hono, Elysia, Next.js, TanStack Start, Astro, Nuxt, Svelte, Nest, or Turborepo.
3
+
description: Prisma Compute deployment and hosting guide. Use whenever the user mentions Prisma Compute, `prisma.compute.ts`, `defineComputeConfig`, deploying or hosting a Prisma app, `@prisma/cli app deploy`, `compute:deploy`, `create-prisma --deploy`, `PRISMA_SERVICE_TOKEN`, `auth workspace`, Compute apps/deployments/logs/domains, localhost vs `0.0.0.0`, deploy port binding, or framework deploy readiness for Hono, Elysia, Next.js, TanStack Start, Astro, Nuxt, Svelte, Nest, or Turborepo.
4
4
license: MIT
5
5
metadata:
6
6
author: prisma
@@ -52,7 +52,8 @@ Use this skill for:
52
52
- Deciding whether a framework is Compute-ready
53
53
- Debugging `create-prisma --deploy`, `compute:deploy`, or `app deploy`
| 4 | Runtime host and port binding | CRITICAL |`runtime-`|
87
+
| 5 | Typed Compute config | HIGH |`config-`|
88
+
| 6 | Branch, environment, and database wiring | HIGH |`env-`|
89
+
| 7 | Deploy operations | HIGH |`deploy-`|
90
+
| 8 | SDK and API automation | MEDIUM |`sdk-`|
89
91
90
92
## Quick Rules
91
93
@@ -97,21 +99,33 @@ Use this skill for:
97
99
-`verify-generated-scripts` - Prefer the generated `compute:deploy` script when a project already has one.
98
100
-`verify-public-url` - After a real deploy, smoke-test the public deployment URL instead of trusting local or readiness-only checks.
99
101
-`verify-config-support` - For `prisma.compute.ts`, verify current CLI help/source because published package help may lag the repo.
102
+
-`verify-auth-workspace-support` - Check `@prisma/cli auth workspace --help` before using workspace list/use/logout commands against an installed package.
100
103
101
-
### 2. Framework Readiness
104
+
### 2. Auth and Workspace Selection
105
+
106
+
-`auth-source-precedence` - A non-empty `PRISMA_SERVICE_TOKEN` is the active auth source for commands and local OAuth workspaces are ignored for execution. If it is set but empty, the CLI should fail instead of falling back to stored OAuth.
107
+
-`auth-multi-workspace` - `auth login` can store OAuth sessions for multiple workspaces on the same machine. The active workspace pointer selects which stored OAuth grant normal commands use.
108
+
-`auth-list-before-switch` - Use `auth workspace list --json` to inspect local sessions. Agents should prefer workspace ids from JSON over names because names can be ambiguous.
109
+
-`auth-switch-explicitly` - Use `auth workspace use <id-or-name>` for non-interactive switching. Use `auth workspace use` with no argument only for an interactive picker or when exactly one local OAuth workspace exists.
110
+
-`auth-no-fallthrough` - If the active OAuth workspace is logged out or fails refresh, the CLI should not silently fall through to another cached workspace. Run `auth workspace use <id>` to choose the next workspace.
111
+
-`auth-single-workspace-logout` - Use `auth workspace logout <id-or-name>` or `auth logout --workspace <id-or-name>` to remove one local OAuth workspace session. Plain `auth logout` clears all local OAuth workspace sessions.
112
+
-`auth-service-token-switching` - While `PRISMA_SERVICE_TOKEN` is set, `auth workspace use` is unavailable because the service token is the active auth source; unset the env var to switch local OAuth workspaces. Workspace logout still only cleans local OAuth state.
113
+
-`auth-storage-awareness` - Local OAuth credentials live in the platform auth file, with workspace metadata in a sidecar context file. Project pins live in `.prisma/local.json`, and CLI app/project state lives in `.prisma/cli/state.json` near `prisma.compute.ts` when present.
114
+
115
+
### 3. Framework Readiness
102
116
103
117
-`framework-cli-first` - Evaluate deploy readiness against current `@prisma/cli app deploy`, not against what `create-prisma` can scaffold.
104
-
-`framework-supported-cli-deploy` - Current CLI source supports `nextjs`, `nuxt`, `astro`, `hono`, `tanstack-start`, and `bun`; verify installed help/source before relying on a key.
118
+
-`framework-supported-cli-deploy` - Current CLI source supports `nextjs`, `nuxt`, `astro`, `hono`, `nestjs`, `tanstack-start`, and `bun`; verify installed help/source before relying on a key.
105
119
-`framework-create-prisma-defaults-only` - `create-prisma` can provide generated defaults and `compute:deploy`, but it is not the general deploy surface for existing apps.
106
120
-`framework-build-output` - Compute needs a server entrypoint or framework artifact, not only static output.
107
121
108
-
### 3. Runtime Host and Port Binding
122
+
### 4. Runtime Host and Port Binding
109
123
110
124
-`runtime-bind-all-interfaces` - Deployed servers must bind on all interfaces (`0.0.0.0` or the framework equivalent), not hard-coded `localhost` or `127.0.0.1`.
111
125
-`runtime-match-http-port` - The app must listen on the deployed HTTP port: read `process.env.PORT` when possible, or pass the matching `--http-port`.
112
126
-`runtime-readiness-port-only` - Compute readiness watches listening ports; a loopback-only listener can look ready while public ingress cannot reach it.
113
127
114
-
### 4. Typed Compute Config
128
+
### 5. Typed Compute Config
115
129
116
130
-`config-optional-simple-app` - `prisma.compute.ts` is not required to deploy a normal single app; use flags when there is no durable config.
117
131
-`config-use-prisma-compute-ts` - Put reusable deploy defaults in `prisma.compute.ts` with `defineComputeConfig`, not in `prisma.config.ts`.
@@ -121,7 +135,7 @@ Use this skill for:
121
135
-`config-no-project-branch-secrets` - Do not commit Workspace, Project, Branch, production intent, service tokens, or secret values in `prisma.compute.ts`; keep those in flags, `.prisma/local.json`, env storage, or CI secrets.
122
136
-`config-flags-win` - Explicit deploy flags such as `--framework`, `--entry`, `--http-port`, and `--env` override matching config values.
123
137
124
-
### 5. Branch, Environment, and Database
138
+
### 6. Branch, Environment, and Database
125
139
126
140
-`env-do-not-leak-secrets` - Never print full `DATABASE_URL`, service tokens, or secret values.
127
141
-`env-deploy-loads-dotenv` - Generated deploy scripts may load env via `prisma.compute.ts` or `--env .env`; inspect the actual script/config before redeploy.
@@ -131,15 +145,15 @@ Use this skill for:
131
145
-`env-production-vs-preview` - Use `--role production` for production env, `--role preview` for preview template env, and `--branch <git-name>` for branch-specific overrides.
132
146
-`env-db-explicit` - `--db` creates and wires one Prisma Postgres database for the branch; it never runs migrations, never creates one database per app, and conflicts with database URLs supplied through `--env`.
133
147
134
-
### 6. Deploy Operations
148
+
### 7. Deploy Operations
135
149
136
150
-`deploy-prod-intent` - Use `--prod --yes` only when the user intends a production deploy.
137
-
-`deploy-noninteractive-auth` - Non-interactive deploys need either stored CLI login or a supported service token env var; never print the token.
151
+
-`deploy-noninteractive-auth` - Non-interactive deploys need either the correct active stored OAuth workspace or a supported service token env var; never print the token.
138
152
-`deploy-json-for-agents` - Use `--json --no-interactive` for scripts and agent-readable output.
139
153
-`deploy-create-project` - Use `--create-project <name>` only when the user wants deploy to create and link a new project; it conflicts with `--project` and `PRISMA_PROJECT_ID`.
140
154
-`deploy-ops-targets` - App show/open/logs/list-deploys/promote/rollback/remove and domain commands can also accept `[app]` targets from `prisma.compute.ts`.
141
155
142
-
### 7. SDK and API
156
+
### 8. SDK and API
143
157
144
158
-`sdk-use-cli-first` - Prefer `@prisma/cli app deploy` for app workflows; use `create-prisma` only to scaffold a new app unless the user is building lower-level automation.
145
159
-`sdk-result-handling` - `@prisma/compute-sdk` returns `Result` values; check `isOk()`/`isErr()` instead of relying on exceptions.
@@ -148,13 +162,14 @@ Use this skill for:
148
162
149
163
1. Inspect the project: package manager, template/framework, `package.json` scripts, Prisma version, Prisma client location, `prisma.compute.ts`, and existing `compute:deploy`.
150
164
2. Verify CLI help output for the package actually being used, or run `scripts/verify-compute-surface.mjs` for the standard Compute surface check.
151
-
3. Choose the path:
165
+
3. Verify auth context before project/app mutations: `auth whoami --json`, and when multiple local sessions may exist, `auth workspace list --json`.
166
+
4. Choose the path:
152
167
- existing app deploy: config-backed target when present, generated `compute:deploy`, or `@prisma/cli app build/run/deploy` flags
153
168
- new app scaffold: `create-prisma`, then generated `compute:deploy` or `@prisma/cli app deploy`
154
169
- low-level automation: `@prisma/compute-sdk` or Management API
155
-
4. Check framework readiness plus host/port/env/runtime requirements, including project and branch scope.
156
-
5. Run a local build or `app build` before deploying when feasible.
157
-
6. Deploy with JSON output when automating, then smoke-test the public URL and summarize app URL, app id, deployment id, project id, and follow-up steps.
170
+
5. Check framework readiness plus host/port/env/runtime requirements, including project and branch scope.
171
+
6. Run a local build or `app build` before deploying when feasible.
172
+
7. Deploy with JSON output when automating, then smoke-test the public URL and summarize app URL, app id, deployment id, project id, workspace id, and follow-up steps.
158
173
159
174
## Avoid
160
175
@@ -165,3 +180,5 @@ Use this skill for:
165
180
- Do not deploy with placeholder `DATABASE_URL` values.
166
181
- Do not assume `next start` is the Compute runtime path; Next.js deploys need standalone output.
167
182
- Do not expose secret values from `.env`, CLI output, Management API responses, or logs.
183
+
- Do not assume a stored OAuth login means the desired workspace is active; inspect or switch it explicitly.
184
+
- Do not auto-switch to another cached workspace after logout or auth refresh failure.
bunx @prisma/cli@latest project link <project-id-or-name>
39
43
bunx @prisma/cli@latest project create my-app
40
44
```
41
45
46
+
Current `@prisma/cli` can keep multiple local browser-login workspace sessions. Running `auth login` again for a different workspace should add/update that workspace session and make it active; it should not delete the existing workspace session. The active workspace pointer decides which stored OAuth workspace normal commands use.
47
+
48
+
For agents, prefer this flow before project/app mutations:
49
+
50
+
```bash
51
+
bunx @prisma/cli@latest auth whoami --json
52
+
bunx @prisma/cli@latest auth workspace list --json
53
+
bunx @prisma/cli@latest auth workspace use <workspace-id>
54
+
```
55
+
56
+
Use workspace ids from `auth workspace list --json` when possible. Names are friendlier for humans but can be ambiguous. Use `auth workspace use` with no argument for a human interactive picker; headless scripts should pass an id because no-argument `use` fails non-interactively when multiple local OAuth workspaces exist.
57
+
58
+
If the active workspace is logged out or its refresh fails, the CLI intentionally does not auto-select another cached workspace. Choose the next workspace explicitly:
59
+
60
+
```bash
61
+
bunx @prisma/cli@latest auth workspace list --json
62
+
bunx @prisma/cli@latest auth workspace use <workspace-id>
63
+
```
64
+
65
+
To clean up one local OAuth workspace without clearing every stored workspace session:
For non-interactive or CI work, current `@prisma/cli` accepts a workspace service token through `PRISMA_SERVICE_TOKEN` before falling back to stored browser-login credentials. Verify auth with `auth whoami` and never print the token value.
81
+
For non-interactive or CI work, current `@prisma/cli` accepts a workspace service token through `PRISMA_SERVICE_TOKEN`. A non-empty service token takes precedence over stored browser-login credentials, so local OAuth workspace switching does not affect command execution while the env var is set. `auth workspace list --json` may still show local OAuth sessions, but they are not switchable until the service-token env var is unset. Verify auth with `auth whoami` and never print the token value.
82
+
83
+
If `PRISMA_SERVICE_TOKEN` is set but empty, unset it or provide a real token. The CLI should fail instead of silently falling back to local OAuth credentials.
84
+
85
+
Local auth storage is useful for debugging but should not be printed verbatim:
86
+
87
+
-`PRISMA_COMPUTE_AUTH_FILE` can override the auth file path.
88
+
- On macOS, the default OAuth credentials file is `~/Library/Application Support/prisma/auth.json`.
89
+
- Workspace metadata and the active workspace pointer live beside it as `auth.context.json`.
90
+
- Project pins live in `.prisma/local.json`.
91
+
- Local CLI state such as selected app and known live deployment lives in `.prisma/cli/state.json`, rooted near `prisma.compute.ts` when a config is discovered.
49
92
50
93
## Project, Branch, Database, and Env Scope
51
94
@@ -68,9 +111,9 @@ Branch scope must line up across deploys, databases, and env vars:
68
111
69
112
-`app deploy --branch <git-name>` creates a deployment for that branch.
70
113
-`database create <name> --branch <git-name>` creates a Prisma Postgres database for that branch scope.
Do not assume a local Git branch was used by the CLI unless the generated script or command output says so. If a user asks for `feature/login`, pass `--branch feature/login` consistently to app, database, and env commands.
76
119
@@ -95,6 +138,8 @@ bunx @prisma/cli@latest project env list
95
138
bunx @prisma/cli@latest project env add --file .env --role production
- Database env values supplied through `--env DATABASE_URL=...`, `--env DIRECT_URL=...`, or an env file suppress automatic database prompting; combining those values with `--db` is rejected.
115
160
- Known non-PostgreSQL Prisma schema sources do not trigger database prompting; explicit `--db` is rejected because it creates Prisma Postgres.
116
161
162
+
## Project Git, Branch, and Database Operations
163
+
164
+
These commands are part of the same Platform CLI surface and often matter while preparing Compute deploys:
Git integration connects a Project to a GitHub repository. Do not assume it replaces CLI deploys or returns preview deployment comments in GitHub unless current product behavior proves that flow exists.
179
+
180
+
Database and database-connection commands never print stored secret values in list/show output. `database create` and `database connection create` return a one-time connection URL; treat it as a secret, store it immediately in env if needed, and do not echo it back in summaries. Removal requires exact `--confirm <id>`; `--yes` is not enough.
181
+
117
182
## Build and Run Locally
118
183
119
184
Before deploy, verify that the app can produce a Compute artifact:
With a compute config, pass the target name instead of repeating framework/entry/port flags:
134
206
135
207
```bash
@@ -139,6 +211,8 @@ bunx @prisma/cli@latest app run api --port 8080
139
211
140
212
`app run --port` sets `PORT` for local development. It does not rewrite an app's explicit host binding, so a local run is not enough to prove the deployed server is reachable from ingress.
141
213
214
+
`app run --build-type nestjs` is not supported in the current CLI. If a config-backed NestJS target is selected, run the Nest dev server directly instead.
0 commit comments