Files
Kokorone/.agents/skills/prisma-compute/references/create-prisma.md
T
Jeffery f44200f543 feat: 完成 B 群組 — 資料層與核心領域模型
- 導入 Prisma 7.9.1 + SQLite(better-sqlite3 driver adapter),prisma.config.ts 管理連線設定
- 完整資料模型:User/Work/Character/CharacterAlias/EpisodicMemory/SemanticMemory/
  ProceduralRule/EmotionState/Relationship/SentimentLedgerEntry
- packages/db:Prisma Client 存取層(ESM,因 Prisma 7 產出的 generated client 僅支援 ESM)
- apps/api 隨之改為 ESM 以相容 packages/db
- packages/shared:新增角色/記憶/情緒/關係共用型別,api 與 web 皆從此匯入
- prisma/seed.ts:建立測試使用者與元氣型測試角色,含完整關係帳本與記憶種子資料
- apps/api:新增 GET /characters
- scripts/smoke/B.mjs:驗證資料表齊全、API 讀出種子角色、關係與記憶可寫入讀出
- 保留 Prisma 官方隨 CLI 附的 agent skill 文件(.agents/skills 等),供後續群組查閱

npm run restart && npm run smoke -- B 皆通過(B-V),A 群組冒煙測試無回歸。
2026-08-13 09:43:15 +08:00

4.1 KiB

create-prisma Compute Flow

Use this reference when creating a new app with Prisma and optionally deploying it to Prisma Compute.

Do not use create-prisma as the deploy path for an existing app. For existing projects, use the generated compute:deploy script when present, or call bunx @prisma/cli@latest app deploy directly.

Reference

Useful scaffold checks:

bunx create-prisma@latest --help
bunx create-prisma@latest --version

Use create-prisma@latest for new-project scaffolding.

Supported Templates

create-prisma@latest scaffolds hono, elysia, nest, next, svelte, astro, nuxt, tanstack-start, and turborepo.

Integrated --deploy support applies to hono, elysia, nest, next, astro, nuxt, tanstack-start, and turborepo. For turborepo, the generated config target is usually api.

The scaffold template name is nest, but the Compute deploy framework/config key is nestjs.

svelte is scaffold-only for Compute because @prisma/cli app deploy --framework has no svelte key.

Basic Commands

Interactive creation:

bunx create-prisma@latest

Non-interactive scaffold only:

bunx create-prisma@latest \
  --name my-api \
  --template hono \
  --provider postgresql \
  --no-install \
  --no-generate \
  --no-migrate-and-seed \
  --no-deploy

Create and deploy a supported template:

bunx create-prisma@latest \
  --name my-api \
  --template hono \
  --provider postgresql \
  --deploy

PostgreSQL and Database Behavior

With PostgreSQL, no explicit --database-url, and no --no-prisma-postgres, the Compute flow can create:

  • a Prisma Compute project
  • a main Prisma Postgres database on the main branch
  • a .env file containing DATABASE_URL
  • an initial Compute deployment with env vars loaded from .env

create-prisma is the new-project path. If the user needs a later preview branch deploy, use the generated compute:deploy script or @prisma/cli app deploy --branch <git-name> after the app exists. Keep branch names aligned across app deploy --branch, database create --branch, and project env ... --branch.

For unattended local tests, pass --no-prisma-postgres unless you intentionally want provisioning:

bunx create-prisma@latest \
  --name smoke-app \
  --template hono \
  --provider postgresql \
  --no-prisma-postgres \
  --database-url "postgresql://USER:PASSWORD@HOST:PORT/DB" \
  --no-deploy

Do not deploy placeholder database URLs. If DATABASE_URL came from a placeholder default, omit it from deploy env and ask the user for a real production database.

Generated Deploy Script

When the deploy flow is selected, create-prisma can add:

{
  "scripts": {
    "compute:deploy": "bunx @prisma/cli@latest app deploy --prod --yes ..."
  }
}

Use the actual generated script from package.json; do not reconstruct it from memory. The script redeploys app code using generated flags and/or prisma.compute.ts. It does not create a new project, create a new database, run migrations, or seed data. If a scaffolded project does not have compute:deploy, use @prisma/cli app deploy directly.

Inspect the generated package.json, prisma.compute.ts, and README before editing deploy behavior.

Generated Files to Preserve

Preserve generated framework runtime files and prisma.compute.ts unless you are intentionally changing the deploy target. For framework-specific deploy/runtime details, read frameworks.md.

All Prisma 7 scaffolds:

  • use prisma.config.ts
  • load dotenv/config where the runtime supports it
  • generate Prisma Client into a template-local path such as src/generated/prisma
  • use @prisma/adapter-pg with a DATABASE_URL connection string for PostgreSQL

Addon Notes

create-prisma supports --skills, --mcp, and --extension. Those are separate from Compute deployment. Do not imply that enabling skills or MCP deploys the app.

Failure Handling

If --deploy is explicit and setup cannot authenticate, cannot run the Platform CLI, or cannot complete the integrated deploy, report that deploy failed and keep the scaffolded project. Do not delete the user's files.