/kavo-skills:prisma-adapterfrom Kavo Developer Skills
Wires @kavo/prisma into a NestJS app — marker classes Prisma entities need, createInfrastructure options, case-insensitive filtering per database, and setup differences from TypeORM.
Ships in Kavo Developer Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
@kavo/prisma adapts Kavo to a Prisma Client. The engine, routes, query
grammar, DTO slots, and error shapes are identical to every other adapter —
only the wiring below differs.
npm install @kavo/core @kavo/nest @kavo/prisma
@prisma/client (^7.0.0) is a peer dependency. Prisma 7 projects should use
the prisma-client generator and a database driver adapter.
Prisma generates no runtime class for a model. prisma generate produces
types and a client with delegates (prisma.book), but nothing that survives
to runtime as a constructor — and @Kavo(Entity) needs a stable runtime
identity to key an entity by.
So each model needs a small marker class: an empty class whose name matches the Prisma model exactly.
// book.entity.ts
export class Book {
id!: number;
title!: string;
}
This is the shape of the trap. The natural guess — passing the delegate, the way you would pass an entity class with TypeORM — does not work:
@Kavo(prisma.book) // ✗ wrong — a delegate is not an identity
@Kavo(Book) // ✓ the marker class
Declare the fields anyway — they are what gives you type safety. At
runtime @kavo/prisma reads only .name off the class and takes all real
metadata from Prisma's DMMF, so an empty class Book {} still produces
working routes. But the declared fields are what type createCrud's generic
parameters, so an empty marker class collapses Entity to {} and every
typed surface built on it silently stops checking anything:
allowed.filterable/sortable/selectable, query.defaultSort, and the
DTO slot generics all stop rejecting misspelled field names at compile time.
Name-matching is what binds class to model, so a marker class named Books
for a model named Book will not resolve — that one fails loudly, as a
bootstrap ConfigurationException rather than a silent no-op. See ADR-0017
for the full rationale.
// app.module.ts
import { Module } from "@nestjs/common";
import { KavoModule } from "@kavo/nest";
import { createInfrastructure } from "@kavo/prisma";
import { PrismaClient } from "./generated/prisma/client";
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import metadata from "./generated/kavo-metadata";
import { Book } from "./book.entity.js";
import { BookController } from "./book.controller.js";
const adapter = new PrismaBetterSqlite3({ url: process.env.DATABASE_URL! });
const prisma = new PrismaClient({ adapter });
@Module({
imports: [
KavoModule.forRoot({
infrastructure: createInfrastructure(prisma, {
metadata,
entities: [Book],
}),
}),
],
controllers: [BookController],
})
export class AppModule {}
The controller itself is ordinary — nothing Prisma-specific reaches it:
@Kavo(Book)
@Controller("books")
export class BookController {}
createInfrastructure(client, options)| Option | Required | Meaning |
|---|---|---|
metadata | yes | the generated module emitted by kavo-prisma-generator |
entities | yes | Every marker class this Kavo root will use |
caseInsensitiveFilters | no | Defaults to true; see below |
entities must be complete, not just the models you decorate. It is the
lookup table that resolves a relation on one model back to the target
model's marker class — a missing entry surfaces when a relation is included,
not at bootstrap.
createPrismaKavo(client, options) is the same thing folded into a
createKavo call for programmatic (non-Nest) use.
caseInsensitiveFilters defaults to true, which makes ilike and
friends emit Prisma's mode: "insensitive". Only PostgreSQL and MongoDB
support it — MySQL, SQLite, and SQL Server reject it outright, so a query
that should have returned rows fails instead.
createInfrastructure(prisma, {
metadata,
entities: [Book],
caseInsensitiveFilters: false, // MySQL, SQLite, SQL Server
});
Note this default is the opposite of @kavo/mikroorm's, where the same
setting defaults to off — the two adapters can detect different amounts
about the database underneath them.
kavo-decoratorfilter/sort/fields/include wire grammar → query-grammardto-slotssoft-deleteWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
15 skills in this plugin
/composite-primary-keysReference for composite primary key support in @kavo/typeorm — the compositeIdFields metadata field, the ~-delimited route-id encoding, the creatable/updatable split, and every place composite keys don't yet work (other ORM adapters, many-to-many array-mutation, @kavo/graphql). Use when an entity has more than one @PrimaryColumn, or when a route id, association, or array-mutation write on such an entity behaves unexpectedly./dto-slotsReference for Kavo's six optional schema slots (create/update/patch/query/item/list) — entity-derived defaults, the schemaShapeKeys narrowing rule, and serialization order. Use when configuring a DTO class or validator on @Kavo's schema option, or answering "why isn't my field showing/hiding" or "what shape does this response have" questions./npx claudepluginhub kavo-labs/kavo --plugin kavo-skillsOther plugins' skills for the same job