Prisma relational
Skill ahtishamshahzad/agent_dev_flow/.ai/skills/database/prisma-relational
Use to plan Prisma over PostgreSQL/MySQL — expressing the approved schema in the Prisma schema, migration workflow, client usage patterns (select scope, N+1 avoidance, transactions), and where Prisma's abstractions end (raw SQL escape hatch).From its SKILL.md
npx -y skills add ahtishamshahzad/agent_dev_flow --skill prisma-relationalAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.5 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Prisma (Relational)
Purpose
Express the approved relational schema through Prisma and use its client well: schema-as-source, generated types, disciplined queries, and a clear line where raw SQL takes over. The schema design comes from relational-schema-design; this skill is its Prisma expression.
When to Use
- After Prisma + a relational DB were approved (
database-selection). - Not for schema design decisions (upstream) or Drizzle/Mongoose projects.
Inputs
- Approved schema design (entities, constraints, types, relations).
- Migration/environment workflow expectations (
database-migrations).
Discovery Questions
- Does the schema use features Prisma models natively (enums, composite uniques, referential actions) vs ones needing raw SQL in migrations (partial indexes, CHECK constraints, triggers)?
- Where do generated types flow (service layer boundaries —
../../backend/backend-api-architecturesays entities ≠ DTOs)? - What query hot paths exist (drives select/include discipline)?
Responsibilities
- Express the design in
schema.prisma: types, relations with explicit referential actions (onDelete),@@unique/@@index, enums — mapping every constraint the design demands; what Prisma's DSL can't express (CHECKs, partial indexes) goes into migration SQL deliberately, not dropped. - Own the migration workflow with
database-migrations:migrate devin development, generated SQL reviewed like code,migrate deployin environments; nodb pushbeyond throwaway prototyping; drift detection in CI. - Set client usage patterns:
select/includescoped to need — no default full-entity fetches leaking through APIs (../../backend/rest-api-designpayload discipline);- relation loading strategy per hot path — avoid N+1 (batched
include, or restructured queries); $transactionfor multi-write invariants (transactionsowns the boundaries);- pagination via cursor patterns on stable keys;
- singleton client with pool sizing matched to deployment (
database-performance).
- Define the raw-SQL escape hatch policy:
$queryRaw(parameterized only —database-security) for reporting/bulk/window queries where the client abstraction fights; typed and reviewed. - Keep generated client/types out of domain contracts: repository/service boundary maps Prisma models → domain/DTO shapes.
Required Workflow
- Translate the approved design into
schema.prisma; list what needs raw-SQL migration additions. - Wire the migration workflow (dev/deploy/CI drift check).
- Define client patterns (select scope, N+1 strategy, transactions, pagination).
- Set the raw-SQL policy and pool config.
- Verify constraints landed in SQL (inspect generated migrations) — not just in the DSL.
Decision Rules
- The generated migration SQL is the truth — review it; the DSL is shorthand.
- Any constraint Prisma can't express still ships (raw SQL in the migration) — the design isn't negotiable downward to the tool.
db pushnever touches shared environments.- N+1s hide behind lazy convenience: hot paths get explicit query shape review (
database-performance).
Rules
- All raw queries parameterized; string interpolation into SQL is a defect.
- Migration files are immutable once applied beyond dev (
database-migrations). - Client version and engine pinned; upgrades follow
../../dependency-audit.
Anti-Patterns
- Designing the schema in Prisma DSL ad hoc, skipping the design skill.
- Dropping CHECK/partial-index requirements because the DSL lacks them.
findManywith noselect, notake— full rows, unbounded.- Prisma models serialized straight out of controllers.
- Per-request
new PrismaClient()exhausting connections.
Validation Checklist
- Design fully expressed (DSL + raw-SQL supplements listed).
- Migration workflow wired; generated SQL reviewed; CI drift check.
- Client patterns set: select scope, N+1 plan, transactions, pagination.
- Raw-SQL policy (parameterized, reviewed) recorded.
- Pool sizing matched to deployment.
- Models mapped to DTOs at the boundary.
Definition of Done
The approved schema fully expressed through Prisma (with deliberate raw-SQL supplements), a reviewed migration workflow, recorded client usage patterns that prevent N+1/overfetch/connection exhaustion, and a parameterized-only raw-SQL policy.
Related Skills
database-selection, relational-schema-design, database-migrations, transactions, indexing, database-performance, database-security, seed-data, ../../backend/backend-api-architecture.
Related Knowledge
../../../knowledge/ (hot paths, environment workflow).
Related References
../../../references/database/prisma/ (patterns, when populated).
Context Loading Guidance
- Requires: approved schema design, migration workflow expectations, hot paths.
- Does not require: re-deciding schema/database choices, app feature code.
- May load:
database-migrations(workflow),transactions(boundaries). - Stop when: schema expression + workflow + client patterns are recorded.
Token Efficiency Guidance
Work from the schema-design table; don't paste the whole schema.prisma into discussion — reference models by name and show only contested mappings.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.