docs/plans/agent-native/005-skill-generate-after-schema-change.md
prisma generate After Schema ChangesThe most common agent failure loop in Prisma projects: edit schema.prisma, then write client
code against models/fields the generated client does not have yet, then misdiagnose the type
errors. Fix it twice over: a skill that teaches the rule, and a Claude Code plugin whose hook
makes it automatic.
Content:
schema.prisma (or schema folder files), run
prisma generate before touching client code. TypeScript errors like "Property 'newModel'
does not exist on type 'PrismaClient'" almost always mean a stale generated client, not a
schema mistake.migrate dev regenerates; plain generate does not touch
the database) — a decision table for schema-edit → which command.prisma generate --watch, prisma dev) and their trade-offs.output, the Prisma 7 default ../generated/prisma)
and why stale imports of an old output path produce the same symptoms.A plugin (skills + hooks bundle) so the rule needs no recall at all:
PostToolUse matching Edit|Write; the hook command checks whether the touched
file matches **/*.prisma (and the project has a prisma.config.ts or prisma/ directory)
and, if so, runs prisma generate --no-hints, surfacing errors back to the agent.
Debounce/short-circuit when generate is already running (watch mode, prisma dev).prisma/skills is an Agent Skills catalog, not a Claude Code plugin marketplace (no
.claude-plugin/ manifest today). Options:
.claude-plugin/marketplace.json to prisma/skills so it serves both ecosystems from
one repo (skills stay npx skills add-able; Claude Code users add the marketplace).prisma/claude-plugin repo.Recommend option 1 — one repo to keep in sync with ORM releases. Confirm with the skills repo maintainers; the hook must remain useful when only the skills (not the plugin) are installed.
prisma-generate-workflow skill (name per repo conventions) +
marketplace manifest and hook script if option 1 is chosen.migrate dev vs generate correctly per the decision table..prisma file in a Claude Code session triggers a generate run whose
failure output reaches the agent; non-Prisma projects are untouched (matcher guards).