zod-4

Migrate Zod 3 schemas to Zod 4 APIs and validators in TypeScript projects.

Updated Mar 10, 2025
One-click install
npx skills add https://github.com/alvaldes/alvaldes.dots --skill zod-4-alvaldes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-4
Source: https://github.com/alvaldes/alvaldes.dots/tree/main/opencode/skill/zod-4
Command: npx skills add https://github.com/alvaldes/alvaldes.dots --skill zod-4-alvaldes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrate Zod 3 schemas to Zod 4 by adopting the updated validators and APIs.

Core Features & Use Cases

  • Updated API surface: includes top-level validators like z.email(), z.uuid(), z.url(), new constraints such as .min(1), and object schema enhancements.
  • Migration guidance: concrete examples showing side-by-side Zod 3 vs Zod 4 patterns for common schemas (primitives, objects, unions, transforms).
  • Testing and debugging support: parsing and safeParse patterns, error handling with updated messages.

Quick Start

Convert existing Zod v3 schemas to v4 by replacing deprecated APIs with their new equivalents, ensuring parsing and error behavior align with v4.

Frequently Asked Questions about zod-4

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Zod 3 schemas to Zod 4?

Migrate Zod 3 schemas to Zod 4 by replacing deprecated APIs with new equivalents like z.email(), z.uuid(), and z.url(), ensuring parsing and error behavior align with the updated version.

What are the new top-level validators in Zod 4?

Zod 4 introduces top-level validators such as z.email(), z.uuid(), and z.url(), along with new constraints like .min(1) and object schema enhancements for updated API surface.

Can I use this to update API schemas and TypeScript form validation?

Yes, this migration applies to developers upgrading TypeScript projects, validating forms, API schemas, and data models across codebases using Zod 4.

What is the best way to handle error changes when upgrading Zod?

The best way to handle error changes is by adopting updated safeParse patterns and error handling with updated messages, using concrete side-by-side Zod 3 vs Zod 4 examples as guidance.

Does upgrading to Zod 4 change how object schemas and transforms work?

Yes, upgrading to Zod 4 includes object schema enhancements and requires adopting updated validators for primitives, objects, unions, and transforms to align with the new API surface.

Why does my Zod 3 schema break after upgrading to Zod 4?

Zod 3 schemas break because Zod 4 updates the API surface with new top-level validators and constraints, requiring migration of deprecated patterns to updated equivalents.