Zod schema validation best practices for type safety, parsing, and error handling. This skill should be used when defining z.object schemas, using z.string validations, safeParse, or z.infer. This skill does NOT cover React Hook Form integration patterns (use react-hook-form skill) or OpenAPI client generation (use orval skill).
A comprehensive guide for using Zod effectively in TypeScript applications. This skill provides 42 rules across 8 categories, organized by impact to help AI agents and developers write better validation code.
Zod is a TypeScript-first schema declaration and validation library. This skill covers best practices for:
z.any(), proper string validationssafeParse(), async validation, error handlingz.infer, distinguishing input/output typesThe skill is automatically loaded when working with Zod code. Reference specific rules:
See rules/parse-use-safeparse.md for safeParse best practices
Read SKILL.md for a quick reference, or AGENTS.md for the full compiled guide.
zod/
├── SKILL.md # Quick reference with rule index
├── AGENTS.md # Full compiled guide (all rules)
├── metadata.json # Version, categories, references
├── README.md # This file
└── rules/
├── _sections.md # Category definitions
├── _template.md # Rule template
├── schema-*.md # Schema definition rules
├── parse-*.md # Parsing rules
├── type-*.md # Type inference rules
├── error-*.md # Error handling rules
├── object-*.md # Object schema rules
├── compose-*.md # Composition rules
├── refine-*.md # Refinement rules
└── perf-*.md # Performance rules
| Priority | Category | Rules | Impact | |----------|----------|-------|--------| | 1 | Schema Definition | 6 | CRITICAL | | 2 | Parsing & Validation | 6 | CRITICAL | | 3 | Type Inference | 5 | HIGH | | 4 | Error Handling | 5 | HIGH | | 5 | Object Schemas | 6 | MEDIUM-HIGH | | 6 | Schema Composition | 5 | MEDIUM | | 7 | Refinements & Transforms | 5 | MEDIUM | | 8 | Performance & Bundle | 5 | LOW-MEDIUM |
z.infer, never duplicate types manuallyCategory:other