zod

Installation
SKILL.md

Zod

CRITICAL: Your training data for Zod is unreliable. APIs change between versions and your memorized patterns may be wrong or deprecated. You MUST fetch and read the live documentation before writing any code. Never assume — verify against current docs first.

Zod is a TypeScript-first schema validation library with automatic static type inference. Define a schema once and get both runtime validation and compile-time types from the same source.

Version note: These best practices target Zod v4 (stable, installed via npm install zod). The top-level error utilities (z.flattenError(), z.prettifyError(), z.treeifyError()) are v4-only — in v3 these were instance methods (error.flatten()). See the migration guide when upgrading.

Documentation

Key Capabilities

Zod has built-ins for things developers commonly reach for external packages to handle:

  • String format validation: built-in validators for email, URL, UUID, CUID, datetime (ISO 8601), IP addresses, MAC addresses, JWTs, and hashes — no separate validator package needed
  • Coercion: use z.coerce.number() / z.coerce.string() etc. to automatically cast inputs (e.g. form strings to numbers) — no manual casting step required
  • Transforms: .transform() on any schema converts parsed values in one step — no need for a separate transformation layer
Related skills

More from mikkelkrogsholm/dev-skills

Installs
10
GitHub Stars
2
First Seen
Mar 2, 2026