
prisma-next-debug
Read a Prisma Next structured error envelope and route to the right recovery — code, domain, severity, why, fix, meta. Use for error, exception, my emit failed, my query won't typecheck, my query crashed, my migration won't apply, MIGRATION.HASHMISMATCH, BUDGET.ROWSEXCEEDED, BUDGET.TIMEEXCEEDED, RUNTIME.ABORTED, PLAN.HASHMISMATCH, CONTRACT.MARKERMISSING, PN-RUN-3001, PN-RUN-3002, PN-RUN-3030, PN-MIG-2001, PN-CLI-4011, PN-SCHEMA-0001, drift, capability missing, planner conflict, prisma studio, EXPLAIN, query log, db.end, db.close, script won't exit, hangs, close connection, pool.end, client is closed.
- Installs
- 2.1K
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/prisma/prisma-next --skill prisma-next-debug- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads prisma-next-debug automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Prisma Next — Debug
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 code, 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.
When to Use
- User pastes an error envelope (CLI failure, runtime exception,
--jsonoutput). - 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.
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.
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 prisma-next ... commands (emit, db init/update/verify/sign/schema, migration plan/apply/show/status, init). Shape (see CliErrorEnvelope in packages/1-framework/1-core/errors/src/control.ts):
{
"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 PN-<domain>-<NNNN>. Domains in use: CLI, MIG, RUN, CON, SCHEMA. Severity is error | warn | info — migration status exits 0 when its diagnostics are warn, so route on severity + code together, not on exit code alone.
2. Runtime envelope — thrown by the in-process runtime when executing a query (see RuntimeErrorEnvelope in packages/1-framework/1-core/framework-components/src/execution/runtime-error.ts):
{ name: 'RuntimeError', code: 'BUDGET.TIME_EXCEEDED', category: 'BUDGET', severity: 'error', message: '...', details: { ... } }
category is one of PLAN | CONTRACT | LINT | BUDGET | RUNTIME (the prefix of code). details holds the structured context (details is the runtime envelope's equivalent of the CLI envelope's meta).
3. SQL driver errors — surface as SqlQueryError / SqlConnectionError (see packages/2-sql/1-core/errors/). Fields on SqlQueryError: kind: 'sql_query', sqlState (Postgres SQLSTATE, e.g. '23505'), constraint, table, column, detail, cause. These are not PN-* codes — route on sqlState and the constraint metadata. SQL driver errors are typically wrapped by middleware before reaching the user, but raw-SQL paths can surface them directly.
Wrapped errors and meta.code
Some commands re-wrap a downstream error into a PN-RUN-3000 (errorRuntime) envelope and stash the original code on meta.code. The most important case: migrate wraps MigrationToolsError (which has codes like MIGRATION.HASH_MISMATCH, MIGRATION.STALE_CONTRACT_BOOKENDS, MIGRATION.AMBIGUOUS_TARGET) via mapMigrationToolsError. The envelope you see is code: 'PN-RUN-3000' with meta.code: 'MIGRATION.HASH_MISMATCH'. Always check meta.code when code is PN-RUN-3000 — that's where the routing-quality information lives.
How to ask for the full envelope
If the user only pasted the human summary, ask for --json output (machine envelope) or re-run with -v (CLI prints the full structured fields). --json and -v are global flags on every CLI command.
Routing — script teardown and closed client
These symptoms are not PN-* envelopes — route on the message text and chain to prisma-next-runtime § Running as a script (teardown).
| Symptom | Next move |
|---|---|
TypeError: db.end is not a function | The runtime client does not expose db.end() — that's the node-postgres pool API (pool.end()). The right call is await db.close(). See prisma-next-runtime § Running as a script (teardown). |
| Script hangs after queries print / process won't exit | On Postgres the façade-owned pg.Pool keeps the event loop alive. Call await db.close() before the script returns, or await using db = postgres<Contract>(...) at the top of a script module (do NOT put await using inside a request handler — block-scoped, would close per-request). See prisma-next-runtime § Running as a script (teardown). |
Error('Postgres client is closed') / Error('SQLite client is closed') / Error('Mongo client is closed') | The client was closed via db.close() (terminal state). Remove the early close(), reorder so close() runs last after all queries, or construct a new db if reconnection is intended. See prisma-next-runtime § Running as a script (teardown). |
Routing — symptom and code → next move
The single source of truth: read the envelope, find the row by code (or meta.code for wrapped errors), follow the next move.
| Code | Where it surfaces | Next move |
|---|---|---|
PN-CLI-4001 Config file not found | Most prisma-next commands | Run prisma-next init, or pass --config <path>. |
PN-CLI-4002 Contract configuration missing | contract emit, db * | Add contract: { ... } to prisma-next.config.ts. See prisma-next-contract. |
PN-CLI-4003 Contract validation failed | contract emit, db * | Re-run pnpm prisma-next contract emit after fixing the contract source named in where.path. See prisma-next-contract. |
PN-CLI-4005 Database connection is required | db *, migrate, migration status | Pass --db <url> or set db.connection in prisma-next.config.ts. |
PN-CLI-4011 Missing extension packs in config | contract emit (e.g. contract uses pgvector.Vector(...) but config does not list the pgvector pack) | Add the descriptors named in meta.missingExtensions to extensions in prisma-next.config.ts. See prisma-next-contract. |
PN-CLI-4020 Migration planning failed | db init, db update | Inspect meta.conflicts. Recovery is per-conflict — chain to prisma-next-migrations. |
PN-CLI-5002/5003/5004/… Init errors | prisma-next init | Re-run with the missing/invalid flags listed in meta.missingFlags or meta.allowed. |
PN-MIG-2001 Unfilled migration placeholder | node migrations/app/<dir>/migration.ts (self-emit) or migrate | Edit migration.ts, replace the named placeholder("<slot>") with a real query closure, self-emit. See prisma-next-migrations. |
PN-MIG-2002 migration.ts not found | Reading a migration package | Restore from version control or scaffold a fresh package with migration plan. |
PN-MIG-2003 Invalid default export | Loading migration.ts | Use export default class extends Migration { ... } (or factory () => ({ ... })). See prisma-next-migrations. |
PN-MIG-2005 dataTransform contract mismatch | Building a data-transform query plan | Pass the same endContract reference to both dataTransform(endContract, …) and the query-builder context. |
PN-RUN-3001 Database not signed | db verify, runtime startup | DB has no marker yet. Run prisma-next db init --db <url> (baseline empty DB) or db update --db <url> (apply contract directly). |
PN-RUN-3002 Hash mismatch | db verify, runtime startup | Marker disagrees with contract hash. Either migrate forward (migrate / db update), or — if the DB is correct after a manual fix-up — db sign. See prisma-next-migrations. |
PN-RUN-3003 Target mismatch | Runtime startup | Contract target ≠ config target; align them (see meta.expected / meta.actual). |
PN-RUN-3004 Schema verification failed | db verify (full mode) | Inspect meta.verificationResult. Run db update to reconcile, or adjust contract. |
PN-RUN-3010 Schema verification failed (CLI surface) | db verify schema-only | Same as 3004. |
PN-RUN-3020 Migration runner failed | migrate, db update, db init | Inspect meta for the conflict; reconcile schema drift, then re-run. Previously applied migrations are preserved. |
PN-RUN-3030 Destructive changes require confirmation | db update (interactive prompt fires; non-interactive returns this code) | Re-run with -y (or --yes) to apply, or --dry-run to preview. Only db update has this flow — migrate does not gate destructive ops on a flag. |
PN-RUN-3000 (wrapper) | migrate, others wrapping MigrationToolsError | Read meta.code. Cases: MIGRATION.HASH_MISMATCH (re-emit: node migrations/app/<dir>/migration.ts); MIGRATION.AMBIGUOUS_TARGET (concurrent migrations — prisma-next-migration-review); MIGRATION.STALE_CONTRACT_BOOKENDS (re-run migration plan); MIGRATION.NO_INVARIANT_PATH / MIGRATION.UNKNOWN_INVARIANT (prisma-next-migration-review); MIGRATION.PATH_UNREACHABLE / MIGRATION.MARKER_MISMATCH (run migrate --show --db $URL to inspect the path, then migration plan --from <from> --to <target> or migration list to audit the graph — see prisma-next-migration-review). |
PN-SCHEMA-0001 | db verify schema check | Live schema does not satisfy contract. meta.verificationResult has the diff. Run db update or adjust the contract. |
MIGRATION.UP_TO_DATE / .DATABASE_BEHIND | migration status info diagnostics | Informational; exit 0. See prisma-next-migration-review. |
MIGRATION.MISSING_INVARIANTS | migration status info diagnostic | The live marker reached the destination hash structurally but doesn't carry all invariants the target ref requires. Run migrate --to <name> --db $URL to take a path that covers the missing invariants. See prisma-next-migration-review. |
MIGRATION.NO_MARKER / .MARKER_NOT_IN_HISTORY / .DIVERGED / CONTRACT.AHEAD / CONTRACT.UNREADABLE | migration status warn diagnostics (exit 0; CI gates parse --json) | Read severity and code. prisma-next-migration-review covers the diamond/diverged/marker-out-of-history flows. |
BUDGET.ROWS_EXCEEDED / BUDGET.TIME_EXCEEDED | Runtime, when the budgets middleware is active | Tune budgets({ maxRows, maxLatencyMs, ... }) or rewrite the query. See prisma-next-runtime. |
LINT.SELECT_STAR / LINT.NO_LIMIT / LINT.DELETE_WITHOUT_WHERE / LINT.UPDATE_WITHOUT_WHERE / LINT.READ_ONLY_MUTATION | Runtime, when the lints middleware is active | Fix the query (add a WHERE / LIMIT / explicit columns), or relax the lint config. See prisma-next-runtime. |
PLAN.HASH_MISMATCH | Runtime, executing a precompiled plan | The contract the plan was built against does not match the runtime contract. Re-emit, rebuild, redeploy. |
CONTRACT.MARKER_MISSING / CONTRACT.MARKER_MISMATCH | Runtime, marker check before executing | Same family as PN-RUN-3001 / PN-RUN-3002 but raised in-process by the runtime rather than a CLI. Recovery is the same. |
RUNTIME.ABORTED (details.phase = encode|decode|stream|beforeExecute|afterExecute|onRow) | Runtime, when an AbortSignal fires mid-execute | Cancellation, not a bug; surface to the caller. |
SqlQueryError (no PN- code) | Raw-SQL paths surfacing a driver error | Inspect sqlState + constraint + table + column. Postgres 23505 = unique violation, 23503 = foreign-key violation, etc. Fix the data or the schema. |
TypeScript error mentioning a capability (e.g. returning() not on the type, include of a many-relation off a many-load) | Authoring-time, before any envelope fires | Capability gates are declared in the contract (capabilities block, namespaced by target/family), not in prisma-next.config.ts. Route to prisma-next-contract for capability declaration and to prisma-next-queries for which method gates on which capability. Re-emit (pnpm prisma-next contract emit) after enabling. |
TypeScript error mentioning a missing field/method on db.orm.<Model> or a stale Contract shape | Authoring-time | Re-emit (pnpm prisma-next contract emit); confirm db.ts instantiates with postgres<Contract, TypeMaps>(...) (the type parameters propagate the contract types). See prisma-next-runtime and prisma-next-contract. |
If the envelope's code is not in this table, follow the envelope's fix field literally — it's the framework's first-party next move. If fix is empty or unhelpful, escalate via prisma-next-feedback.
Common Pitfalls
- Reading only
summary, not the rest of the envelope.code,severity,why,fix,meta/details, and (for CLI errors)whereare all load-bearing. The agent routes oncode; the user seessummary. - Ignoring
severity.migration statusemits warn-level diagnostics and exits 0. An agent that only checks exit code misses every concurrent-migration warning. - Skipping
meta.codeonPN-RUN-3000. That envelope is a wrapper — the real code lives onmeta.code. - Treating drift as something to silence with
db sign.db signwrites the marker from the current contract hash, but it requires schema verification to pass first. Rundb verifybefore reaching fordb sign. - Re-running
migrateafter a partial failure without inspecting state.db schema --db <url>shows the live shape;migration status --db <url> --jsonshows where the marker actually is.
What Prisma Next doesn't do yet
- Studio / GUI database browser. No first-party Studio. Workaround:
prisma-next db schemafor a CLI tree of the live schema, or use a third-party tool (TablePlus, DataGrip,psql) against yourDATABASE_URL. If you need a built-in GUI, file a feature request viaprisma-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
prisma-next-runtimefor middleware composition). If you need a built-in query log, file a feature request viaprisma-next-feedback. EXPLAINintegration. No first-class.explain()on plans. Workaround: write the EXPLAIN as a raw query (db.sql.raw\EXPLAIN ANALYZE ...`; seeprisma-next-queries). If you need first-class EXPLAIN, file a feature request viaprisma-next-feedback`.- 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
prisma-next-queries). If you need prepared statements as a first-class API, file a feature request viaprisma-next-feedback.
Asking for help when the envelope doesn't route
- Re-run with
-v(or--jsonfor machine output) to get the full envelope. - If the envelope is genuinely uninformative — empty
fix, missingmeta, genericsummary— that's a framework affordance gap; route toprisma-next-feedbackwith the envelope, the contract source (sanitised), and the reproduction steps.
Checklist
- Identified which envelope shape (
CliErrorEnvelope,RuntimeErrorEnvelope,SqlQueryError). - Read every field —
code,severity,why,fix,meta(ordetails),whereif present. - If
codeisPN-RUN-3000, also readmeta.code. - Routed on
codeto the next move (and chained to the matching authoring skill where the table says so). - 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.
FAQ
What does the prisma-next-debug skill do?
Read a Prisma Next structured error envelope and route to the right recovery — code, domain, severity, why, fix, meta. Use for error, exception, my emit failed, my query won't typecheck, my query crashed, my migration won't apply, MIGRATION.HASHMISMATCH, BUDGET.ROWSEXCEEDED, BUDGET.TIMEEXCEEDED, RUNTIME.ABORTED, PLAN.HASHMISMATCH, CONTRACT.MARKERMISSING, PN-RUN-3001, PN-RUN-3002, PN-RUN-3030, PN-MIG-2001, PN-CLI-4011, PN-SCHEMA-0001, drift, capability missing, planner conflict, prisma studio, EXPLAIN, query log, db.end, db.close, script won't exit, hangs, close connection, pool.end, client is closed.
How do I install prisma-next-debug?
Run npx skills add https://github.com/prisma/prisma-next --skill prisma-next-debug in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/prisma-next-debug/ (personal) or .claude/skills/prisma-next-debug/ (project).
Which AI agents can use prisma-next-debug?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is prisma-next-debug safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains prisma-next-debug?
It is published by prisma in prisma/prisma-next, and it is an official skill from the maker of the technology it covers. It has 2,055 recorded installs.
More from prisma/prisma-next
prisma-next
prisma/prisma-next
Route a vague Prisma Next prompt to the right specific skill. Use for "help me with Prisma Next", "what is Prisma Next", "explain Prisma Next", "I'm new to PN", "where do I start", "what can I do with Prisma Next", "what can I do next with Prisma", "just ran createprisma", "tour of Prisma Next", "Prisma Next overview", and comparison questions like "Prisma Next vs Prisma 7", "PN vs Drizzle", "PN vs Kysely", "PN vs TypeORM". Do NOT use when the prompt clearly matches a workflow skill — adoption / quickstart / first-touch orientation / brownfield introspection, schema / contract editing, migration authoring (db update / migration plan / migrate), migration review on deploy / concurrent migrations, queries / db.orm / db.sql / TypedSQL, Supabase / RLS / role binding, runtime / db.ts / middleware wiring, build / Vite plugin / Next.js plugin, debug / structured error envelopes / PN- error codes, or feedback / bug report / feature request — load that sibling skill directly.
prisma-next-migrations
prisma/prisma-next
Author Prisma Next migrations — choose db update vs migration plan, edit the framework-rendered migration.ts (replace placeholder sentinels with dataTransform closures), recover from MIGRATION.HASHMISMATCH or PN-MIG-2001 unfilled placeholder. Use for prisma migrate dev, prisma migrate deploy, prisma db push, db update, db update --dry-run, migration plan, migrate, migration new, migration show, db verify, db sign, data migration, this.dataTransform, dataTransform, placeholder, generated migration.ts, edit migration.ts, MIGRATION.HASHMISMATCH, schema drift.
prisma-next-queries
prisma/prisma-next
Write Prisma Next queries for Postgres, SQLite, or Mongo — pick a lane (Postgres/SQLite db.orm. + db.sql. ; Mongo db.orm. + db.query.from(...) pipeline builder), filter / project / sort / paginate, eager-load with .include(...), Postgres/SQLite db.transaction(...), Postgres/SQLite ORM .aggregate(...), Mongo aggregations via query builder, namespace-aware accessors (db.orm. . , db.sql. . ). Triggers: query, where, match, select, project, orderBy, take, skip, include, lookup, first, all, count, aggregate, group, create, update, delete, upsert, returning, transaction, db.close, script teardown, variant, polymorphism, drizzle-style, kysely-style. Notes: .all() is a Thenable (just await it), iterators are single-use (RUNTIME.ITERATORCONSUMED), Postgres count is number while sum/avg/min/max are number null, ranges use chained .where() or and(...) (no .between(...)).
prisma-next-migration-review
prisma/prisma-next
Review what Prisma Next migrations will run on merge or deploy, render the migration graph, resolve concurrent / diamond-convergence conflicts, and configure environment refs for CI. Use for "what migrations are going to run", "what runs on deploy", merge conflict, diamond convergence, concurrent migrations, migration status, ref management, staging, production, MIGRATION.DIVERGED, MIGRATION.NOMARKER, MIGRATION.MARKERNOTINHISTORY, prisma migrate status, prisma migrate diff, prisma migrate resolve.
prisma-next-runtime
prisma/prisma-next
Wire the Prisma Next runtime — db.ts setup using postgres (...) from @prisma-next/postgres/runtime, sqlite (...) from @prisma-next/sqlite/runtime, or mongo (...) from @prisma-next/mongo/runtime; middleware composition (telemetry from @prisma-next/middleware-telemetry; lints and budgets), DATABASEURL config, per-environment branching, switching between Postgres, SQLite, and Mongo façades. Use for db.ts, postgres(), sqlite(), mongo(), middleware, telemetry, lints, budgets, DATABASEURL, .env, connection pool, poolOptions, dev vs prod config, transactions, db.transaction, read replicas, multi-database, script won't exit, hangs, close connection, db.end, db.close, pool.end, [Symbol.asyncDispose], await using.
prisma-next-build
prisma/prisma-next
Wire Prisma Next into the project's build system with the right build-tool plugin — Vite today via @prisma-next/vite-plugin-contract-emit (Vite 7 / 8); Next.js / Webpack / esbuild / Rollup / Turbopack are named as gaps rather than fabricated. Always offers the Vite plugin proactively when the project is using Vite. Use for vite plugin, vite-plugin, vite.config.ts, prismaVitePlugin, contract emit on save, HMR, hot reload contract, dev server, Next.js plugin, next plugin, withPrismaNext, webpack plugin, esbuild plugin, rollup plugin, build integration, dev server plugin, vite 7, vite 8.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.