
Zod
Define and validate TypeScript shapes for forms, API payloads, and env config so runtime errors surface before production.
Overview
Zod is an agent skill for the Build phase that teaches TypeScript-first schema validation with inferred types for APIs, forms, and runtime checks.
Install
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill zodWhat is this skill?
- TypeScript-first schemas with static type inference via z.infer
- Primitives, objects, arrays, composition, transforms, and async validation patterns
- safeParse/parse flows with structured ZodError handling
- Progressive disclosure sections from quick start through integrations and best practices
- Pairs with Drizzle, Prisma, and Next.js skills in the same toolchain catalog
- Progressive disclosure lists 11 topical sections plus entry summary and when_to_use
- Full token estimate ~5000 with entry point ~65 tokens
Adoption & trust: 608 installs on skills.sh; 53 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have TypeScript types and untyped JSON at runtime, so invalid input slips through until users or integrations break in production.
Who is it for?
Solo builders defining API contracts, env parsing, or form validation in TypeScript codebases.
Skip if: Teams that only need one-off regex checks with no shared schema layer, or projects not using TypeScript/JavaScript.
When should I use this skill?
Form validation, API payload validation, or runtime type checking with compile-time TypeScript types.
What do I get? / Deliverables
You get reusable Zod schemas, inferred types, and consistent parse/error handling you can drop into handlers, forms, and shared packages.
- Zod schema modules with inferred types
- Validation helpers using safeParse/parse and formatted errors
Recommended Skills
Journey fit
Schema design and parse-time validation are core backend and API-contract work during implementation. Backend subphase covers request/response validation, shared DTOs, and server-side type safety that Zod is built for.
How it compares
Library-focused procedural skill, not an MCP server or external validation SaaS.
Common Questions / FAQ
Who is zod for?
TypeScript solo builders and small teams who want runtime validation aligned with static types for APIs, forms, and config.
When should I use zod?
During Build when defining backend routes, shared DTOs, or client form schemas, especially alongside Drizzle, Prisma, or Next.js stacks in the same repo.
Is zod safe to install?
Review the Security Audits panel on this Prism page for install risk and file integrity; the skill is documentation-only and does not grant shell or network by itself.
SKILL.md
READMESKILL.md - Zod
{ "name": "zod", "version": "1.0.0", "category": "toolchain", "toolchain": "typescript", "tags": [ "zod", "validation", "typescript", "schema", "type-safety" ], "entry_point_tokens": 65, "full_tokens": 7468, "related_skills": [ "../../data/drizzle", "../../data/prisma", "../../../nextjs" ], "author": "claude-mpm-skills", "license": "MIT", "subcategory": "validation", "created": "2025-11-30", "updated": "2025-11-30", "repository": "https://github.com/bobmatnyc/claude-mpm-skills" } --- name: zod description: TypeScript-first schema validation library with static type inference for form validation, API validation, and runtime type checking with compile-time types. user-invocable: false disable-model-invocation: true progressive_disclosure: entry_point: - summary - when_to_use - quick_start sections: - primitives - objects_and_arrays - type_inference - validation_methods - schema_composition - transformations - error_handling - async_validation - advanced_types - integrations - best_practices token_estimates: entry: 65 primitives: 200 objects_and_arrays: 300 type_inference: 150 validation_methods: 250 schema_composition: 300 transformations: 400 error_handling: 250 async_validation: 200 advanced_types: 500 integrations: 1200 best_practices: 300 full: 5000 --- # Zod Validation Skill ## Summary TypeScript-first schema validation library with static type inference. Define schemas once, get runtime validation and compile-time types automatically. ## When to Use - Form validation with type-safe data - API request/response validation - Environment variable validation - Runtime type checking with TypeScript inference - tRPC procedure inputs/outputs - Database schema validation (Drizzle, Prisma) ## Quick Start ```typescript import { z } from 'zod'; // Define schema const UserSchema = z.object({ id: z.string().uuid(), email: z.string().email(), age: z.number().min(18), role: z.enum(['user', 'admin']) }); // Infer TypeScript type type User = z.infer<typeof UserSchema>; // Validate data const result = UserSchema.safeParse(data); if (result.success) { const user: User = result.data; } ``` <!-- SECTION: primitives --> ## Primitive Types ### Basic Types ```typescript import { z } from 'zod'; // String with validation const nameSchema = z.string() .min(2, "Too short") .max(50, "Too long") .trim(); const emailSchema = z.string().email(); const urlSchema = z.string().url(); const uuidSchema = z.string().uuid(); const regexSchema = z.string().regex(/^[A-Z]{3}$/); // Numbers const ageSchema = z.number() .int("Must be integer") .positive() .min(0) .max(120); const priceSchema = z.number() .positive() .multipleOf(0.01); // Currency precision // Boolean const isActiveSchema = z.boolean(); // Date const createdAtSchema = z.date() .min(new Date('2020-01-01')) .max(new Date()); const dateStringSchema = z.string().datetime(); // ISO 8601 const dateOnlySchema = z.string().date(); // YYYY-MM-DD ``` ### Special Types ```typescript // Literal values const roleSchema = z.literal('admin'); const statusSchema = z.literal('pending'); // Enums const ColorEnum = z.enum(['red', 'green', 'blue']); type Color = z.infer<typeof ColorEnum>; // 'red' | 'green' | 'blue' const NativeEnum = z.nativeEnum(MyEnum); // For TypeScript enums // Nullable and Optional const optionalString = z.string().optional(); // string | undefined const nullableString = z.string().nullable(); // string | null const nullishString = z.string().nullish(); // string | null | undefined // Default values const countSchema = z.number().default(0); const settingsSchema = z.object({ theme: z.string().default('light'), notifications: z.boolean().default(true) }); ``` <!-- SECTION: objects_and_arrays --> ## Objects and Arrays ### Object Schemas ```typescript // Basic object const UserSchema = z.o