From harness-claude
Uses Prisma's generated types like XxxCreateInput, XxxWhereInput, enums, and validators for type-safe queries, service layers, DTOs, and payloads in TypeScript.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Use generated Prisma types like XxxCreateInput, XxxWhereInput, $Enums, and validator utilities
Provides expert guidance on Prisma ORM for TypeScript apps: schema design, migrations, Prisma Client queries, relations, edge deployment, and performance optimization.
Designs Prisma schemas with datasource, generator blocks, models, enums, field types, attributes, IDs, indexes, and native types for PostgreSQL, MySQL, SQLite. Useful for new projects or extending existing schemas.
Assists with Prisma schema helper operations: generates configurations, code, and best practices for backend database tasks in Node.js, Python, or Go. Auto-activates on 'prisma schema helper' mentions.
Share bugs, ideas, or general feedback.
Use generated Prisma types like XxxCreateInput, XxxWhereInput, $Enums, and validator utilities
npx prisma generate
This runs automatically after migrate dev but must be run manually after editing the schema without migrating.
@prisma/client:import { Prisma, User, Post, Role } from '@prisma/client';
User, Post — model types (the shape returned by queries)Role — enum typePrisma — namespace containing all input/output typesimport { Prisma } from '@prisma/client';
async function createUser(data: Prisma.UserCreateInput) {
return prisma.user.create({ data });
}
async function findUsers(where: Prisma.UserWhereInput) {
return prisma.user.findMany({ where });
}
$Enums export or directly:import { Role } from '@prisma/client';
// Use as a type
function isAdmin(role: Role): boolean {
return role === 'ADMIN';
}
// Use enum values
const defaultRole: Role = 'USER';
Prisma.UserGetPayload:type UserWithPosts = Prisma.UserGetPayload<{
include: { posts: true };
}>;
// UserWithPosts = User & { posts: Post[] }
select queries:type UserSummary = Prisma.UserGetPayload<{
select: { id: true; name: true; email: true };
}>;
// UserSummary = { id: string; name: string | null; email: string }
Prisma.validator to create reusable, type-checked query objects:const userWithPosts = Prisma.validator<Prisma.UserDefaultArgs>()({
include: { posts: true },
});
// Use in queries
const user = await prisma.user.findUnique({
where: { id },
...userWithPosts,
});
const userSelect = Prisma.validator<Prisma.UserSelect>()({
id: true,
email: true,
name: true,
});
type PublicUser = Prisma.UserGetPayload<{ select: typeof userSelect }>;
async function getPublicUser(id: string): Promise<PublicUser | null> {
return prisma.user.findUnique({ where: { id }, select: userSelect });
}
Prisma.UserScalarFieldEnum for dynamic field selection:const sortableFields = ['createdAt', 'name', 'email'] as const;
function buildOrderBy(field: (typeof sortableFields)[number]): Prisma.UserOrderByWithRelationInput {
return { [field]: 'desc' };
}
JsonValue types from Json fields:import { Prisma } from '@prisma/client';
// Prisma.JsonValue = string | number | boolean | null | Prisma.JsonObject | Prisma.JsonArray
function parseMetadata(json: Prisma.JsonValue): Record<string, unknown> {
if (typeof json === 'object' && json !== null && !Array.isArray(json)) {
return json as Record<string, unknown>;
}
return {};
}
Prisma generates TypeScript types in node_modules/.prisma/client/index.d.ts based on your schema. These types power autocompletion, compile-time checking, and the entire Prisma Client API.
Type categories:
User, Post) — plain objects representing a full database rowUserCreateInput, UserUpdateInput, UserWhereInput) — types for query argumentsUserGetPayload<T>) — types derived from specific select/include combinationsRole, Status) — string literal unions matching schema enumsUserScalarFieldEnum) — union of field name stringsUserCreateInput vs UserUncheckedCreateInput: The Create input uses relation fields (author: { connect: { id } }). The Unchecked variant uses raw foreign keys (authorId: string). Both produce the same SQL. Use the standard version for type safety; use the unchecked version when working with raw IDs.
Keeping types in sync: Types are generated into node_modules and are not committed to version control. Run prisma generate in CI before type-checking. Add it to your build pipeline:
{ "scripts": { "build": "prisma generate && tsc" } }
Zod integration: Use zod-prisma-types or prisma-zod-generator to auto-generate Zod schemas from your Prisma models. This eliminates manual synchronization between Prisma types and runtime validation:
generator zod {
provider = "zod-prisma-types"
}
https://prisma.io/docs/orm/prisma-client/type-safety