prisma-type-settings
2
总安装量
2
周安装量
#64483
全站排名
安装命令
npx skills add https://github.com/madsnyl/t3-template --skill prisma-type-settings
Agent 安装分布
amp
2
gemini-cli
2
github-copilot
2
codex
2
kimi-cli
2
cursor
2
Skill 文档
Prisma 7 Type Settings (TypeScript)
You are an expert in TypeScript types for Prisma 7 and how to structure them cleanly.
Activation cues
Use this skill when the user asks to:
- create query payload types (with
select/include) - define API response types for endpoints
- standardize types in
types/by domain - avoid duplication and keep types aligned with Prisma schema
Core rules
- Prefer Prisma-generated types over hand-written shapes.
- Use
Prisma.validator()to define reusableselect/includeobjects with exact types. - Use
Prisma.<Model>GetPayload<typeof args>for derived result types. - Keep types domain-scoped: files live in
types/<domain>/...(never one giant types file).
(See Prisma type safety + validator docs in references/PRISMA7_CORE_REFERENCES.md.)
Folder conventions
Use this structure unless user already has another:
types/billing/invoice.types.ts
projects/project.select.ts(query arg objects)project.types.ts(payload/result types)
users/user.types.ts
Naming conventions
XSelect/XIncludefor arg objectsXListItem,XDetail,XWith...for payload typesXCreateInput,XUpdateInputfor DTO-ish shapes (only if needed)
Output format
When creating types, provide:
- File path(s) under
types/<domain>/... - Exported
select/includeobjects - Exported
GetPayloadtypes - A short example query using those exports
Examples
Example: reusable selection + payload type
// types/projects/project.select.ts
import { Prisma } from "generated/prisma";
export const projectListSelect = Prisma.validator<Prisma.ProjectSelect>()({
id: true,
name: true,
slug: true,
createdAt: true,
workspace: {
select: { id: true, name: true },
},
});
// types/projects/project.types.ts
import { Prisma } from "generated/prisma";
import { projectListSelect } from "./project.select";
export type ProjectListItem = Prisma.ProjectGetPayload<{
select: typeof projectListSelect;
}>;
// usage
const projects = await prisma.project.findMany({
where: { workspaceId },
select: projectListSelect,
});
Example: include payload for a detail view
// types/projects/project.types.ts
import { Prisma } from "generated/prisma";
export const projectDetailArgs = Prisma.validator<Prisma.ProjectDefaultArgs>()({
include: {
workspace: true,
projectMembers: {
include: { user: { select: { id: true, email: true } } },
},
},
});
export type ProjectDetail = Prisma.ProjectGetPayload<typeof projectDetailArgs>;
Additional resources
- For complete Prisma docs details, see reference.md