Skip to content

Commit e724bae

Browse files
docs: align compute skill with latest cli
1 parent 6a6d97f commit e724bae

8 files changed

Lines changed: 296 additions & 48 deletions

File tree

prisma-compute/SKILL.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
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.
44
license: MIT
55
metadata:
66
author: prisma
@@ -52,7 +52,8 @@ Use this skill for:
5252
- Deciding whether a framework is Compute-ready
5353
- Debugging `create-prisma --deploy`, `compute:deploy`, or `app deploy`
5454
- Managing Compute app logs, deployments, environment variables, branches, and domains
55-
- Running non-interactive deploys with browser auth or Prisma service tokens
55+
- Running non-interactive deploys with browser auth, multiple stored workspaces, or Prisma service tokens
56+
- Switching, selecting, listing, or logging out local Prisma Platform workspaces for `@prisma/cli`
5657
- Programmatic deployments with `@prisma/compute-sdk` or Management API integrations
5758

5859
## Decision Tree
@@ -80,12 +81,13 @@ Use this skill for:
8081
| Priority | Category | Impact | Prefix |
8182
|----------|----------|--------|--------|
8283
| 1 | Command verification | CRITICAL | `verify-` |
83-
| 2 | Framework readiness | CRITICAL | `framework-` |
84-
| 3 | Runtime host and port binding | CRITICAL | `runtime-` |
85-
| 4 | Typed Compute config | HIGH | `config-` |
86-
| 5 | Branch, environment, and database wiring | HIGH | `env-` |
87-
| 6 | Deploy operations | HIGH | `deploy-` |
88-
| 7 | SDK and API automation | MEDIUM | `sdk-` |
84+
| 2 | Auth and workspace selection | CRITICAL | `auth-` |
85+
| 3 | Framework readiness | CRITICAL | `framework-` |
86+
| 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-` |
8991

9092
## Quick Rules
9193

@@ -97,21 +99,33 @@ Use this skill for:
9799
- `verify-generated-scripts` - Prefer the generated `compute:deploy` script when a project already has one.
98100
- `verify-public-url` - After a real deploy, smoke-test the public deployment URL instead of trusting local or readiness-only checks.
99101
- `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.
100103

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
102116

103117
- `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.
105119
- `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.
106120
- `framework-build-output` - Compute needs a server entrypoint or framework artifact, not only static output.
107121

108-
### 3. Runtime Host and Port Binding
122+
### 4. Runtime Host and Port Binding
109123

110124
- `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`.
111125
- `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`.
112126
- `runtime-readiness-port-only` - Compute readiness watches listening ports; a loopback-only listener can look ready while public ingress cannot reach it.
113127

114-
### 4. Typed Compute Config
128+
### 5. Typed Compute Config
115129

116130
- `config-optional-simple-app` - `prisma.compute.ts` is not required to deploy a normal single app; use flags when there is no durable config.
117131
- `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:
121135
- `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.
122136
- `config-flags-win` - Explicit deploy flags such as `--framework`, `--entry`, `--http-port`, and `--env` override matching config values.
123137

124-
### 5. Branch, Environment, and Database
138+
### 6. Branch, Environment, and Database
125139

126140
- `env-do-not-leak-secrets` - Never print full `DATABASE_URL`, service tokens, or secret values.
127141
- `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:
131145
- `env-production-vs-preview` - Use `--role production` for production env, `--role preview` for preview template env, and `--branch <git-name>` for branch-specific overrides.
132146
- `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`.
133147

134-
### 6. Deploy Operations
148+
### 7. Deploy Operations
135149

136150
- `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.
138152
- `deploy-json-for-agents` - Use `--json --no-interactive` for scripts and agent-readable output.
139153
- `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`.
140154
- `deploy-ops-targets` - App show/open/logs/list-deploys/promote/rollback/remove and domain commands can also accept `[app]` targets from `prisma.compute.ts`.
141155

142-
### 7. SDK and API
156+
### 8. SDK and API
143157

144158
- `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.
145159
- `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:
148162

149163
1. Inspect the project: package manager, template/framework, `package.json` scripts, Prisma version, Prisma client location, `prisma.compute.ts`, and existing `compute:deploy`.
150164
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:
152167
- existing app deploy: config-backed target when present, generated `compute:deploy`, or `@prisma/cli app build/run/deploy` flags
153168
- new app scaffold: `create-prisma`, then generated `compute:deploy` or `@prisma/cli app deploy`
154169
- 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.
158173

159174
## Avoid
160175

@@ -165,3 +180,5 @@ Use this skill for:
165180
- Do not deploy with placeholder `DATABASE_URL` values.
166181
- Do not assume `next start` is the Compute runtime path; Next.js deploys need standalone output.
167182
- 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.

prisma-compute/references/app-deploy-cli.md

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,62 @@ Useful commands:
3333
```bash
3434
bunx @prisma/cli@latest auth login
3535
bunx @prisma/cli@latest auth whoami
36+
bunx @prisma/cli@latest auth workspace list --json
37+
bunx @prisma/cli@latest auth workspace use <workspace-id-or-name>
38+
bunx @prisma/cli@latest auth workspace use
39+
bunx @prisma/cli@latest auth workspace logout <workspace-id-or-name>
3640
bunx @prisma/cli@latest project list --json
3741
bunx @prisma/cli@latest project show
3842
bunx @prisma/cli@latest project link <project-id-or-name>
3943
bunx @prisma/cli@latest project create my-app
4044
```
4145

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:
66+
67+
```bash
68+
bunx @prisma/cli@latest auth workspace logout <workspace-id-or-name>
69+
# equivalent:
70+
bunx @prisma/cli@latest auth logout --workspace <workspace-id-or-name>
71+
```
72+
73+
Plain `auth logout` clears all local OAuth workspace sessions. It does not unset `PRISMA_SERVICE_TOKEN`.
74+
4275
For a new linked project:
4376

4477
```bash
4578
bunx @prisma/cli@latest project create my-app --json
4679
```
4780

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

5093
## Project, Branch, Database, and Env Scope
5194

@@ -68,9 +111,9 @@ Branch scope must line up across deploys, databases, and env vars:
68111

69112
- `app deploy --branch <git-name>` creates a deployment for that branch.
70113
- `database create <name> --branch <git-name>` creates a Prisma Postgres database for that branch scope.
71-
- `project env add/list/remove --branch <git-name>` manages branch-specific env overrides.
72-
- `project env add/list/remove --role production` manages production env.
73-
- `project env add/list/remove --role preview` manages preview-template env.
114+
- `project env add/update/list/remove --branch <git-name>` manages branch-specific env overrides.
115+
- `project env add/update/list/remove --role production` manages production env.
116+
- `project env add/update/list/remove --role preview` manages preview-template env.
74117

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

@@ -95,6 +138,8 @@ bunx @prisma/cli@latest project env list
95138
bunx @prisma/cli@latest project env add --file .env --role production
96139
bunx @prisma/cli@latest project env add --file .env.preview --role preview
97140
bunx @prisma/cli@latest project env add DATABASE_URL=postgresql://... --branch feature/foo
141+
bunx @prisma/cli@latest project env update --file .env --role production
142+
bunx @prisma/cli@latest project env update DATABASE_URL=postgresql://... --branch feature/foo
98143
bunx @prisma/cli@latest project env list --branch feature/foo
99144
bunx @prisma/cli@latest project env remove STRIPE_KEY --role preview
100145
```
@@ -114,6 +159,26 @@ Database setup guardrails:
114159
- 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.
115160
- Known non-PostgreSQL Prisma schema sources do not trigger database prompting; explicit `--db` is rejected because it creates Prisma Postgres.
116161

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:
165+
166+
```bash
167+
bunx @prisma/cli@latest branch list --json
168+
bunx @prisma/cli@latest git connect git@github.com:org/repo.git --project proj_123
169+
bunx @prisma/cli@latest git disconnect --project proj_123
170+
bunx @prisma/cli@latest database list --branch feature/foo --json
171+
bunx @prisma/cli@latest database show db_123 --json
172+
bunx @prisma/cli@latest database remove db_123 --confirm db_123
173+
bunx @prisma/cli@latest database connection list db_123 --json
174+
bunx @prisma/cli@latest database connection create db_123 --name readonly
175+
bunx @prisma/cli@latest database connection remove conn_123 --confirm conn_123
176+
```
177+
178+
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+
117182
## Build and Run Locally
118183

119184
Before deploy, verify that the app can produce a Compute artifact:
@@ -130,6 +195,13 @@ bunx @prisma/cli@latest app build --build-type bun --entry src/index.ts
130195
bunx @prisma/cli@latest app run --build-type bun --entry src/index.ts --port 8080
131196
```
132197

198+
For NestJS, use `app build` to validate the Compute artifact and run the framework's own dev command locally:
199+
200+
```bash
201+
bunx @prisma/cli@latest app build --build-type nestjs
202+
bun run dev
203+
```
204+
133205
With a compute config, pass the target name instead of repeating framework/entry/port flags:
134206

135207
```bash
@@ -139,6 +211,8 @@ bunx @prisma/cli@latest app run api --port 8080
139211

140212
`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.
141213

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.
215+
142216
## Deploy
143217

144218
Deploy with prompts:

0 commit comments

Comments
 (0)