prisma-next-debug
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrisma Next — Debug
Prisma Next — 调试
Edit your data contract. Prisma handles the rest.
When a Prisma Next call fails, the framework returns a structured envelope. The agent's job is to read the envelope, route on the , and chain to the right authoring skill for the actual fix. This skill teaches the envelope shapes and the routing — it does not duplicate sibling-skill workflows.
code编辑你的数据契约,其余工作由Prisma处理。
当Prisma Next调用失败时,框架会返回一个结构化信封。该工具的作用是读取信封内容,根据进行路由,并关联到对应的修复技能。本技能仅讲解信封结构和路由逻辑,不会重复其他兄弟技能的工作流。
codeWhen to Use
使用场景
- User pastes an error envelope (CLI failure, runtime exception, output).
--json - User says "my query won't typecheck", "my migration won't apply", "my emit failed", "the runtime crashed".
- User mentions a stable code (,
PN-CLI-*,PN-MIG-*,PN-RUN-*,PN-SCHEMA-*,MIGRATION.*,CONTRACT.*,LINT.*,BUDGET.*,PLAN.*).RUNTIME.* - User mentions: Studio, EXPLAIN, query log, prepared statements, drift, hash mismatch, capability, planner.
- 用户粘贴了错误信封(CLI失败、运行时异常、输出)。
--json - 用户反馈诸如“我的查询无法类型检查”、“我的迁移无法应用”、“emit失败”、“运行时崩溃”等问题。
- 用户提到了稳定错误代码(如、
PN-CLI-*、PN-MIG-*、PN-RUN-*、PN-SCHEMA-*、MIGRATION.*、CONTRACT.*、LINT.*、BUDGET.*、PLAN.*)。RUNTIME.* - 用户提到以下内容:Studio、EXPLAIN、查询日志、预准备语句、架构漂移、哈希不匹配、功能、规划器。
When Not to Use
不适用场景
- User wants to author a query / model / migration → the matching authoring skill.
- User wants to prevent errors (lints, budgets, type-level guards) → .
prisma-next-runtime - User wants the framework changed because the surface itself is the problem (no envelope to route on, capability genuinely missing) → .
prisma-next-feedback
- 用户想要编写查询/模型/迁移 → 使用对应的编写技能。
- 用户想要预防错误(代码检查、预算控制、类型级防护) → 使用。
prisma-next-runtime - 用户想要修改框架本身(因为没有可路由的信封、确实缺失功能) → 使用。
prisma-next-feedback
Key Concepts
核心概念
Two envelope shapes
两种信封结构
Prisma Next emits two distinct envelopes depending on which seam threw. Read which one you have before routing.
1. CLI envelope — produced by commands (emit, db init/update/verify/sign/schema, migration plan/apply/show/status, init). Shape (see in ):
prisma-next ...CliErrorEnvelopepackages/1-framework/1-core/errors/src/control.tsjson
{
"ok": false,
"code": "PN-MIG-2001",
"domain": "MIG",
"severity": "error",
"summary": "Unfilled migration placeholder",
"why": "...",
"fix": "...",
"where": { "path": "...", "line": 42 },
"meta": { "slot": "..." },
"docsUrl": "https://prisma-next.dev/..."
}The full code is . Domains in use: , , , , . Severity is — exits 0 when its diagnostics are , so route on severity + code together, not on exit code alone.
PN-<domain>-<NNNN>CLIMIGRUNCONSCHEMAerror | warn | infomigration statuswarn2. Runtime envelope — thrown by the in-process runtime when executing a query (see in ):
RuntimeErrorEnvelopepackages/1-framework/1-core/framework-components/src/execution/runtime-error.tsts
{ name: 'RuntimeError', code: 'BUDGET.TIME_EXCEEDED', category: 'BUDGET', severity: 'error', message: '...', details: { ... } }categoryPLAN | CONTRACT | LINT | BUDGET | RUNTIMEcodedetailsdetailsmeta3. SQL driver errors — surface as / (see ). Fields on : , (Postgres SQLSTATE, e.g. ), , , , , . These are not codes — route on and the constraint metadata. SQL driver errors are typically wrapped by middleware before reaching the user, but raw-SQL paths can surface them directly.
SqlQueryErrorSqlConnectionErrorpackages/2-sql/1-core/errors/SqlQueryErrorkind: 'sql_query'sqlState'23505'constrainttablecolumndetailcausePN-*sqlStatePrisma Next会根据错误抛出的位置,生成两种不同的信封。在路由前请先确认你拿到的是哪一种。
1. CLI信封 — 由命令生成(如emit、db init/update/verify/sign/schema、migration plan/apply/show/status、init)。结构参考中的:
prisma-next ...packages/1-framework/1-core/errors/src/control.tsCliErrorEnvelopejson
{
"ok": false,
"code": "PN-MIG-2001",
"domain": "MIG",
"severity": "error",
"summary": "Unfilled migration placeholder",
"why": "...",
"fix": "...",
"where": { "path": "...", "line": 42 },
"meta": { "slot": "..." },
"docsUrl": "https://prisma-next.dev/..."
}完整代码格式为。当前使用的领域包括:、、、、。严重程度分为 — 当诊断结果为时,命令会返回0,因此需要结合严重程度+错误代码进行路由,而不能仅依赖退出码。
PN-<domain>-<NNNN>CLIMIGRUNCONSCHEMAerror | warn | infowarnmigration status2. 运行时信封 — 当执行查询时,由进程内运行时抛出。结构参考中的:
packages/1-framework/1-core/framework-components/src/execution/runtime-error.tsRuntimeErrorEnvelopets
{ name: 'RuntimeError', code: 'BUDGET.TIME_EXCEEDED', category: 'BUDGET', severity: 'error', message: '...', details: { ... } }categoryPLAN | CONTRACT | LINT | BUDGET | RUNTIMEcodedetailsmeta3. SQL驱动错误 — 以 / 形式呈现(参考)。的字段包括:、(Postgres SQLSTATE,例如)、、、、、。这些错误没有代码 — 需要根据和约束元数据进行路由。SQL驱动错误通常会被中间件包装后再返回给用户,但原生SQL路径可能会直接暴露这些错误。
SqlQueryErrorSqlConnectionErrorpackages/2-sql/1-core/errors/SqlQueryErrorkind: 'sql_query'sqlState'23505'constrainttablecolumndetailcausePN-*sqlStateWrapped errors and meta.code
meta.code包装错误与meta.code
meta.codeSome commands re-wrap a downstream error into a () envelope and stash the original code on . The most important case: wraps (which has codes like , , ) via . The envelope you see is with . Always check when is — that's where the routing-quality information lives.
PN-RUN-3000errorRuntimemeta.codemigrateMigrationToolsErrorMIGRATION.HASH_MISMATCHMIGRATION.STALE_CONTRACT_BOOKENDSMIGRATION.AMBIGUOUS_TARGETmapMigrationToolsErrorcode: 'PN-RUN-3000'meta.code: 'MIGRATION.HASH_MISMATCH'meta.codecodePN-RUN-3000部分命令会将下游错误重新包装为()信封,并将原始代码存储在中。最常见的场景是:命令通过包装(错误代码包括、、)。此时你看到的信封是,而。当错误代码为时,务必检查 — 这里才是路由的关键信息。
PN-RUN-3000errorRuntimemeta.codemigratemapMigrationToolsErrorMigrationToolsErrorMIGRATION.HASH_MISMATCHMIGRATION.STALE_CONTRACT_BOOKENDSMIGRATION.AMBIGUOUS_TARGETcode: 'PN-RUN-3000'meta.code: 'MIGRATION.HASH_MISMATCH'PN-RUN-3000meta.codeHow to ask for the full envelope
如何获取完整信封
If the user only pasted the human summary, ask for output (machine envelope) or re-run with (CLI prints the full structured fields). and are global flags on every CLI command.
--json-v--json-v如果用户只粘贴了人工总结的内容,请要求他们提供输出(机器可读信封)或使用参数重新运行命令(CLI会打印完整的结构化字段)。和是所有CLI命令的全局参数。
--json-v--json-vRouting — script teardown and closed client
路由 — 脚本销毁与客户端关闭
These symptoms are not envelopes — route on the message text and chain to § Running as a script (teardown).
PN-*prisma-next-runtime| Symptom | Next move |
|---|---|
| The runtime client does not expose |
| Script hangs after queries print / process won't exit | On Postgres the façade-owned |
| The client was closed via |
这些症状不属于信封 — 需要根据消息文本进行路由,并关联到的*Running as a script (teardown)*章节。
PN-*prisma-next-runtime| 症状 | 下一步操作 |
|---|---|
| 运行时客户端不提供 |
| 查询执行完成后脚本挂起/进程无法退出 | 在Postgres中,框架维护的 |
| 客户端已通过 |
Routing — symptom and code → next move
路由 — 症状与代码 → 下一步操作
The single source of truth: read the envelope, find the row by (or for wrapped errors), follow the next move.
codemeta.code| Code | Where it surfaces | Next move |
|---|---|---|
| Most | Run |
| | Add |
| | Re-run |
| | Pass |
| | Add the descriptors named in |
| | Inspect |
| | Re-run with the missing/invalid flags listed in |
| | Edit |
| Reading a migration package | Restore from version control or scaffold a fresh package with |
| Loading | Use |
| Building a data-transform query plan | Pass the same |
| | DB has no marker yet. Run |
| | Marker disagrees with contract hash. Either migrate forward ( |
| Runtime startup | Contract target ≠ config target; align them (see |
| | Inspect |
| | Same as 3004. |
| | Inspect |
| | Re-run with |
| | Read |
| | Live schema does not satisfy contract. |
| | Informational; exit 0. No action needed unless |
| | Read |
| Runtime, when the | Tune |
| Runtime, when the | Fix the query (add a |
| Runtime, executing a precompiled plan | The contract the plan was built against does not match the runtime contract. Re-emit, rebuild, redeploy. |
| Runtime, marker check before executing | Same family as |
| Runtime, when an | Cancellation, not a bug; surface to the caller. |
| Raw-SQL paths surfacing a driver error | Inspect |
TypeScript error mentioning a capability (e.g. | Authoring-time, before any envelope fires | Capability gates are declared in the contract ( |
TypeScript error mentioning a missing field/method on | Authoring-time | Re-emit ( |
If the envelope's is not in this table, follow the envelope's field literally — it's the framework's first-party next move. If is empty or unhelpful, escalate via .
codefixfixprisma-next-feedback唯一的权威来源:读取信封内容,根据(或包装错误的)找到对应行,执行下一步操作。
codemeta.code| 代码 | 出现场景 | 下一步操作 |
|---|---|---|
| 大多数 | 运行 |
| | 在 |
| | 修复 |
| | 通过 |
| | 将 |
| | 检查 |
| | 根据 |
| | 编辑 |
| 读取迁移包 | 从版本控制中恢复,或使用 |
| 加载 | 使用 |
| 构建数据转换查询计划 | 将相同的 |
| | 数据库尚未标记。运行 |
| | 标记与契约哈希不一致。可以选择向前迁移( |
| 运行时启动 | 契约目标与配置目标不一致;请对齐两者(参考 |
| | 检查 |
| | 与3004处理方式相同。 |
| | 检查 |
| | 添加 |
| | 读取 |
| | 实时架构不符合契约要求。 |
| | 仅为提示信息;命令返回0。除非 |
| | 同时查看 |
| 运行时,当 | 调整 |
| 运行时,当 | 修复查询(添加 |
| 运行时,执行预编译计划时 | 生成计划时使用的契约与运行时契约不一致。重新emit、重建并重新部署。 |
| 运行时,执行前的标记检查 | 与 |
| 运行时, | 属于取消操作,而非错误;请将此信息返回给调用方。 |
| 原生SQL路径暴露的驱动错误 | 检查 |
TypeScript错误提到功能缺失(例如 | 编写阶段,尚未生成信封 | 功能限制在契约中声明( |
TypeScript错误提到 | 编写阶段 | 重新emit( |
如果信封中的不在此表中,请严格按照信封的字段执行 — 这是框架提供的官方下一步操作。如果为空或无帮助,请通过升级问题。
codefixfixprisma-next-feedbackCommon Pitfalls
常见误区
- Reading only , not the rest of the envelope.
summary,code,severity,why,fix/meta, and (for CLI errors)detailsare all load-bearing. The agent routes onwhere; the user seescode.summary - Ignoring .
severityemits warn-level diagnostics and exits 0. An agent that only checks exit code misses every concurrent-migration warning.migration status - Skipping on
meta.code. That envelope is a wrapper — the real code lives onPN-RUN-3000.meta.code - Treating drift as something to silence with .
db signwrites the marker from the current contract hash, but it requires schema verification to pass first. Rundb signbefore reaching fordb verify.db sign - Re-running after a partial failure without inspecting state.
migrateshows the live shape;db schema --db <url>shows where the marker actually is.migration status --db <url> --json
- 仅读取,忽略信封的其他内容。
summary、code、severity、why、fix/meta以及(CLI错误的)details都是关键信息。工具根据where进行路由,而用户通常只看到code。summary - 忽略。
severity会输出warn级诊断信息,并且返回0。仅检查退出码的工具会错过所有并发迁移的警告。migration status - 跳过的
PN-RUN-3000。 这个信封是包装器 — 真实的错误代码在meta.code中。meta.code - 使用来掩盖架构漂移。
db sign会根据当前契约哈希写入标记,但前提是架构验证必须通过。在使用db sign前,请先运行db sign。db verify - 部分失败后未检查状态就重新运行。
migrate会显示实时架构;db schema --db <url>会显示标记的实际位置。migration status --db <url> --json
What Prisma Next doesn't do yet
Prisma Next目前未支持的功能
- Studio / GUI database browser. No first-party Studio. Workaround: for a CLI tree of the live schema, or use a third-party tool (TablePlus, DataGrip,
prisma-next db schema) against yourpsql. If you need a built-in GUI, file a feature request viaDATABASE_URL.prisma-next-feedback - First-class query logger middleware. No built-in "log every query" middleware ships with the framework. Workaround: write a small custom middleware that wraps each operation (see for middleware composition). If you need a built-in query log, file a feature request via
prisma-next-runtime.prisma-next-feedback - integration. No first-class
EXPLAINon plans. Workaround: write the EXPLAIN as a raw query (.explain()EXPLAIN ANALYZE ...`db.sql.raw\prisma-next-queries; seeprisma-next-feedback`.). If you need first-class EXPLAIN, file a feature request via - Prepared-statement caching as a user-facing surface. Adapters prepare under the hood for parameterized queries, but you cannot pre-prepare and re-execute a statement by name. Workaround: use TypedSQL (see ). If you need prepared statements as a first-class API, file a feature request via
prisma-next-queries.prisma-next-feedback
- Studio / GUI数据库浏览器。 暂无官方Studio。替代方案:使用查看CLI格式的实时架构树,或使用第三方工具(TablePlus、DataGrip、
prisma-next db schema)连接你的psql。如果需要内置GUI,请通过DATABASE_URL提交功能请求。prisma-next-feedback - 一流的查询日志中间件。 框架未内置“记录所有查询”的中间件。替代方案:编写一个小型自定义中间件包装每个操作(参考的中间件组合)。如果需要内置查询日志,请通过
prisma-next-runtime提交功能请求。prisma-next-feedback - EXPLAIN集成。 计划中没有一流的方法。替代方案:将EXPLAIN作为原生查询编写(
.explain()EXPLAIN ANALYZE ...`db.sql.raw\prisma-next-queries;参考prisma-next-feedback`提交功能请求。)。如果需要一流的EXPLAIN支持,请通过 - 面向用户的预准备语句缓存。 适配器会为参数化语句在底层进行预准备,但你无法通过名称预准备和重新执行语句。替代方案:使用TypedSQL(参考)。如果需要将预准备语句作为一流API,请通过
prisma-next-queries提交功能请求。prisma-next-feedback
Asking for help when the envelope doesn't route
当信封无法路由时寻求帮助
- Re-run with (or
-vfor machine output) to get the full envelope.--json - If the envelope is genuinely uninformative — empty , missing
fix, genericmeta— that's a framework affordance gap; route tosummarywith the envelope, the contract source (sanitised), and the reproduction steps.prisma-next-feedback
- 使用(或
-v获取机器可读输出)重新运行命令,获取完整信封。--json - 如果信封确实信息不足 — 为空、缺少
fix、meta泛化 — 这属于框架的功能缺口;请将信封、契约源(已脱敏)和复现步骤提交给summary。prisma-next-feedback
Checklist
检查清单
- Identified which envelope shape (,
CliErrorEnvelope,RuntimeErrorEnvelope).SqlQueryError - Read every field — ,
code,severity,why,fix(ormeta),detailsif present.where - If is
code, also readPN-RUN-3000.meta.code - Routed on to the next move (and chained to the matching authoring skill where the table says so).
code - Re-verified with the relevant CLI command (,
db verify,migration status --json,contract emit).migrate - Did not confabulate a Studio / EXPLAIN / query-log API — used the documented workaround and routed unmet capability gaps to .
prisma-next-feedback
- 识别信封类型(、
CliErrorEnvelope、RuntimeErrorEnvelope)。SqlQueryError - 读取所有字段 — 、
code、severity、why、fix(或meta)、details(如果存在)。where - 如果是
code,同时读取PN-RUN-3000。meta.code - 根据路由到下一步操作(并按照表格说明关联到对应的编写技能)。
code - 使用相关CLI命令重新验证(、
db verify、migration status --json、contract emit)。migrate - 未虚构Studio / EXPLAIN / 查询日志API — 使用文档中的替代方案,并将未满足的功能缺口路由到。
prisma-next-feedback