원클릭으로
zod-v4
Zod v4 coding guidelines and migration reference. ALWAYS read this when using Zod validation library
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Zod v4 coding guidelines and migration reference. ALWAYS read this when using Zod validation library
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | zod-v4 |
| description | Zod v4 coding guidelines and migration reference. ALWAYS read this when using Zod validation library |
Every schema MUST have inferred type above it:
export type User = z.infer<typeof User>
export const User = z.object({...})
Requirements:
/** */), never //String validations are standalone functions:
// WRONG: z.string().email()
// RIGHT: z.email(), z.url(), z.uuid(), z.ip()
Use error param sparingly - Zod's defaults are excellent:
// WRONG: z.email({error: "Invalid email"}) // Redundant!
// RIGHT: z.email() // Zod says "Invalid email"
// RIGHT: Only for business logic:
z.string().refine((val) => /[A-Z]/.test(val), {
error: 'Must contain uppercase',
})
z.number() for general numbersz.int() for integers only (not z.number().int())z.int32(), z.float64() for specific typesz.object() - strips unknowns (default)z.strictObject() - rejects extrasz.looseObject() - allows extrasUse .check() for advanced validation, .refine() for simple validation:
Migration steps:
.superRefine() → .check() for advanced validation with multiple issues.check(): val → ctx.value, ctx.addIssue() → ctx.issues.push()z.ZodIssueCode.custom → 'custom' stringinput: ctx.value to issue object.refine() for simple boolean validation with single errorz.prettifyError() - Human-readable formatz.treeifyError() - Tree structure formatDefine function schemas with input/output types:
z.function({
input: [z.string()],
output: z.number(),
})
z.record(keyType, valueType)
z.iso.datetime() - ISO 8601 datetimez.iso.date() - ISO 8601 date.default() applies to output; use .prefault() for v3 behaviorz.file().min(1024).max(5*1024*1024).mime(['image/jpeg'])z.pipe(z.string(), z.number()) for transformations.check(async (val) => {...}) for async validationz.array(z.email()) or z.email().array().optional(), .nullable(), .nullish()| v3 | v4 |
|---|---|
| z.string().email() | z.email() |
| {message: "err"} | {error: "err"} |
| .strict() | z.strictObject() |
| .format() | z.treeifyError() |
| z.string().datetime() | z.iso.datetime() |
| .args().returns() | {input:[...], output:...} |
| .superRefine() | .check() |
| ctx.addIssue() | ctx.issues.push() |
| z.ZodIssueCode.custom | 'custom' |
import * as z from 'zod'
/** User registration */
export type UserReg = z.infer<typeof UserReg>
export const UserReg = z.object({
email: z.email(),
password: z
.string()
.min(8)
.refine((pwd) => /[A-Z]/.test(pwd) && /\d/.test(pwd), { error: 'Need uppercase & number' }),
age: z.number().min(18),
})
/** Function with input/output types */
export type ProcessUser = z.infer<typeof ProcessUser>
export const ProcessUser = z.function({
input: [UserReg],
output: z.object({
id: z.string(),
createdAt: z.iso.datetime(),
}),
})
Guide for running inline Python scripts with uv. This should be used when the user says "use inline python"
Guide for running inline TypeScript scripts with Bun. This should be used when the user says "use inline typescript"
Git commit guidelines for incremental commits. Read this when user asks you to auto commit as you go