zod-patterns

Community

Type-first Zod validation, eliminate schema drift.

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 using satisfies 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.coerce for type coercion and refine for dependent type validation (e.g., endDate after startDate).
  • 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 satisfies that 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 required

Components

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.
View Source Repository