zod-patterns
CommunityType-first Zod validation, eliminate schema drift.
Software Engineering#type safety#typescript#validation#data integrity#schema#zod#branded types#parse don't validate
Authoraitchwhy
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill enforces a TypeScript-first approach to data validation with Zod, ensuring that TypeScript types are the single source of truth for API contracts. It prevents schema drift, improves type safety, and reduces runtime errors by validating data against explicit types.
Core Features & Use Cases
- Core Pattern (
satisfies): Guides on usingsatisfies z.ZodType<T>to validate Zod schemas against TypeScript types at compile time, catching discrepancies early. - Branded Types: Integrates Zod with TypeScript branded types for compile-time safe identifiers (e.g.,
UserId), preventing accidental type misuse. - Transforms & Refinements: Provides patterns for complex validation logic, including
z.coercefor type coercion andrefinefor dependent type validation (e.g.,endDateafterstartDate). - Use Case: A developer is defining an API request payload. They can use this skill to define the TypeScript type first, then create a Zod schema that
satisfiesthat type, ensuring that any changes to the type are automatically reflected in schema validation.
Quick Start
Define a TypeScript type 'Product' with 'id', 'name', and 'price' fields, then create a Zod schema 'productSchema' that satisfies this type, including validation for each field.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: zod-patterns Download link: https://github.com/aitchwhy/dotfiles/archive/main.zip#zod-patterns Please download this .zip file, extract it, and install it in the .claude/skills/ directory.