zod
Original:🇺🇸 English
Translated
Portable Zod schema design and validation guidance. Default to `zod/mini` for new work and preserve established classic `zod` surfaces. Use when Codex needs to create, extend, refactor, or review Zod schemas; choose strict or loose object contracts; model nullability, unions, intersections, recursion, or runtime-validated values; or debug surprising Zod behavior and serialization boundaries.
2installs
Sourcecorneliusio/skills
Added on
NPX Install
npx skill4agent add corneliusio/skills zodTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Zod
Specification
The words , , , , , , , , , and are interpreted as described in RFC 2119.
MUSTMUST NOTREQUIREDSHALLSHALL NOTSHOULDSHOULD NOTRECOMMENDEDMAYOPTIONALUse this skill to design or review Zod schemas.
- Default to for new work.
zod/mini - Preserve an existing classic surface when the file or repo already established it.
zod - Read references/variant-guide.md when the import or API surface is unclear, or when you need the exact mini-vs-classic rules.
- Read references/patterns.md for compact -first examples.
zod/mini
Workflow
- Detect the local surface.
bash
rg -n "from 'zod/mini'|from \"zod/mini\"|from 'zod'|from \"zod\"" .
rg -n '"zod"' package.json bun.lock pnpm-lock.yaml package-lock.json yarn.lock- Stay on the file or repo's established surface.
- If none exists, start with .
import * as z from 'zod/mini' - Do not migrate between and
zodunless the user explicitly asks.zod/mini
- Define the boundary.
- Parse untrusted input at I/O boundaries.
- Use for expected invalid input.
safeParse - Use when invalid input should throw.
parse
- Choose exact contract semantics.
- Prefer for internal contracts.
z.strictObject(...) - Use only when extra keys are intentional.
z.looseObject(...) - Choose ,
optional,nullable, andnullexplicitly.undefined
- Compose.
- Prefer base schemas plus ,
intersection, and literal tags.union - Use for recursion.
lazy - Keep , manual
custom, and similar escape hatches narrow.any
- Normalize only when useful.
- Normalize messy raw values before parsing the narrower schema the caller needs.
- Re-parse at the consumption boundary only when that local contract is stricter than the upstream payload contract.
- Check serialization boundaries.
- Keep returned, stored, and transmitted payloads data-only.
- Keep functions, helper objects, closures, and other behavior-bearing values local.
Rules
- Treat Zod as a runtime contract system, not just a typing tool.
- Prefer composition over mutation-style schema building.
- Prefer readable operational errors over raw issue dumps.