prisma-8
它能做什么
这份指南为你的智能体提供使用 Prisma 8 的最新指导。Prisma 8 是一套围绕数据契约构建的数据库工具包。适合在 Prisma 8 上开发应用、并希望智能体正确使用当前版本的开发者。
适用场景
- ✓当你编辑数据契约文件,或运行生成契约产物的命令的时候。
- ✓当你需要在 Prisma 8 项目中规划或应用数据库迁移的时候。
- ✓当你在 Prisma 8 项目中编写数据库查询或设置数据库连接的时候。
技能链接
https://github.com/prisma/orm/blob/main/skills/prisma-8/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在这个 Prisma 8 项目中为我的契约添加一个新字段,并规划相应的迁移。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先确认项目确实使用 Prisma 8,然后使用随已安装版本附带的参考文件。这些文件的优先级高于智能体对 Prisma 的记忆。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prisma 8 (Prisma 8)
Edit your data contract. Prisma handles the rest.
Prisma 8 moves fast, and your training data about it is very likely outdated. This skill ships inside the installed Prisma packages, so it describes the exact version this project has — treat it and its reference files as the source of truth, over anything you remember about Prisma.
Pre-conditions
Check these before acting on anything below. Halt on the first one that fails and tell the user what is missing.
- The project is on Prisma 8.
prisma.config.tsexportsdefinePrismaConfig({ orm: ... }), andpackage.jsondepends on@prisma/orm-postgres,@prisma/orm-sqlite, or@prisma/orm-mongo. A project withschema.prismaand@prisma/clientis Prisma 7 or earlier; this skill does not apply to it, and its instructions will break such a project. - The skill matches the installed version. Compare
metadata.library_versionin this file's frontmatter with the installed@prisma/orm-*version inpackage.json. If they differ, runprisma skills syncand re-read this file before continuing. - The contract artefacts exist.
contract.jsonandcontract.d.tssit next to the contract source named byprisma.config.ts. If they are missing or older than the source, runprisma contract emitfirst; every query and migration instruction below assumes current artefacts.
Import paths in the references. The reference files spell façade imports as @internal/<target>/<subpath> and @internal/extension-<name>/<subpath>. In an application those packages are published as @prisma/orm-<target>/<subpath> (@prisma/orm-postgres/runtime, @prisma/orm-mongo/config, @prisma/orm-sqlite/runtime) and @prisma/orm-extension-<name>/<subpath> (@prisma/orm-extension-pgvector/control). Write the @prisma/orm-* name in user code; the two spellings are the same package. Paths already written as @prisma/orm-* in the references are exact. The metadata.library_version in this file's frontmatter is the version it was published with; if it does not match the project's installed Prisma packages, run prisma skills sync and re-read.
Never reset or drop a database
Never reset or drop a database to fix a migration, marker or contract problem, and never propose it. A database can always be moved to the contract you want. When its migration history does not need to be kept (a local, development, staging or preview database), reconcile it with prisma db update. When it changes only through migrations, as production should, author the migrations that bring it there. A deploy that says there is no migration path, or MIGRATION.MARKER_MISMATCH, is covered in references/migrations.md § A database whose marker is not in the migration graph.
Prisma 8 is a contract-first data layer. This skill routes every Prisma 8 task to the right reference file — open the reference before writing code; do not answer from this file alone.
The canonical model (one paragraph)
You author a data contract (a contract.prisma file, or a TypeScript builder). The framework emits machine-readable artifacts (contract.json, contract.d.ts) and gives you two runtime surfaces on SQL targets: a typed SQL query builder (db.sql.<ns>.<table>) and a typed ORM client (db.orm.<ns>.<Model>). On MongoDB targets only the ORM lane exists, and its keys are collection storage names (db.orm.users) rather than PSL model names — references/queries.md § MongoDB ORM addressing covers the rule. Migrations are planned from the contract diff; you review them, optionally edit the migration.ts for data transforms, and apply.
Three steps the user does:
- Edit your data contract. (
references/contract.md) - The system plans the migrations for you. (
references/migrations.md) - If you need data migrations, you edit
migration.tsand execute it. (references/migrations.md)
Everything else — queries, runtime wiring, build integration, debugging, feedback — sits on top of those three.
One cross-cutting migration fact: migration plan does not chain from the newest migration on disk. Its origin is --from, else the db ref, else an empty database — so a project with no ref keeps planning from scratch. Over existing migrations the CLI refuses that (MIGRATION.PLAN_ORIGIN_UNKNOWN) instead of writ
常见问题
它适用于旧版 Prisma 项目吗?
不适用。该技能只适用于 Prisma 8 项目,其指令会破坏 Prisma 7 或更早版本的项目。
如果技能版本与我安装的版本不一致怎么办?
该技能说明,应先运行 prisma skills sync,并重新读取文件,然后再继续。
开始之前必须具备什么?
契约产物,例如 contract.json 和 contract.d.ts,必须存在且为最新的;如果缺失,智能体会先运行 prisma contract emit。
详情
作者的原始描述
Use when working in a project that depends on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo (Prisma 8, formerly Prisma Next): editing contract.prisma or a contract.ts builder, running `prisma contract emit`, planning or applying migrations, editing migration.ts, writing db.orm / db.sql / db.query queries, wiring db.ts or middleware, integrating a build tool, using the Supabase extension or RLS, or reading a dotted error code such as MIGRATION.HASH_MISMATCH. Use when the user asks "what is Prisma 8", "where do I start", or compares it to another ORM. Use when the user asks to u
repo: prisma/orm
热度
- GitHub 星标
- 48k
- 排名
- #6313
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
adr-review
48k教你的智能体以新鲜的视角审阅架构决策记录,然后重写,让新读者也能清楚理解其中的决定。
ast-visitor-pattern
48k教你的智能体一种代码模式,用于处理在多个位置被使用的联合类型,使新增的变体能被编译器捕获。
markdown-no-artificial-line-wraps
48k帮你的智能体把整段文字写在同一行中,让文字在屏幕上自然换行,并保持文件改动清晰。
multiline-commit-messages
48k向你的智能体展示一种在 shell 中安全编写多行 git 提交信息的方法,使信息不会出现乱码。