What problem does it solve?
Prevents runtime type errors, inconsistent validation logic, and unsafe data flowing through TypeScript applications by centralizing schema definition, validation, and type inference with Zod. It helps teams catch input errors at system boundaries, produce actionable validation messages, and maintain a single source of truth for data shapes.
Core Features & Use Cases
- Schema Definition Best Practices: Guidance on primitives, enums, coercion for form/query data, and avoiding optional abuse to keep schemas strict and meaningful.
- Parsing & Validation Patterns: Recommendations for safeParse, parseAsync for async refinements, handling all issues, avoiding double validation, and validating at boundaries.
- Type Inference & Composition: Advice on z.infer, z.input/z.output distinctions, branded types for domain safety, discriminated unions, and composition utilities (extend, pick, omit, intersection, pipe, preprocess).
- Error Handling & UX: Techniques for custom messages, internationalization, flattening errors for forms, adding paths to refinement errors, and using superRefine for multiple issues.
- Performance & Production Concerns: Caching schemas, avoiding dynamic creation in hot paths, lazy loading large schemas, and recommending Zod Mini for bundle-sensitive frontends.
- Use Case Example: Validate incoming API JSON at the endpoint using safeParse, coerce query params to correct types, and infer downstream TypeScript types to eliminate defensive null checks.
Quick Start
Use the zod skill to validate incoming JSON at the API boundary with safeParse, coerce query/form strings to numbers/booleans, and infer types with z.infer for downstream code.