zod-4

Apply Zod v4 schema patterns for validation and migration from Zod v3.

Updated Aug 8, 2025
One-click install
npx skills add https://github.com/Albarracin-sg/MIS-DOTFILES --skill zod-4-albarracin-sg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-4
Source: https://github.com/Albarracin-sg/MIS-DOTFILES/tree/main/tools/opencode/skill/zod-4
Command: npx skills add https://github.com/Albarracin-sg/MIS-DOTFILES --skill zod-4-albarracin-sg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod 4 introduces breaking changes from v3; this reference guides migration and provides pattern updates for runtime validation.

Core Features & Use Cases

  • Updated primitives and top-level validators (z.email, z.uuid, z.url) for Zod v4
  • Object schemas, arrays/tuples, unions, and refinements with clear migration notes
  • Practical examples to convert existing Zod v3 schemas to Zod v4 and validate data at runtime

Quick Start

Explain how to apply a basic Zod v4 schema to validate a user object and run safeParse.

Frequently Asked Questions about zod-4

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

FAQPage Schema
How do I migrate schemas from Zod v3 to Zod v4?

Zod v4 migration requires updating top-level validators to z.email and z.url, then adjusting object schemas, arrays, and refinements to resolve breaking changes. Practical examples guide converting existing Zod v3 schemas effectively.

What are the breaking changes in Zod 4 validation?

Zod 4 breaking changes affect top-level validators like z.email, z.uuid, and z.url, plus object schemas, arrays, tuples, and refinements. These updates require adjusting API usage to maintain runtime validation.

How do I validate a user object with Zod v4 safeParse?

To validate a user object with Zod v4 safeParse, apply a basic Zod v4 schema to the object and run the safeParse method. This executes runtime validation and returns structured error handling guidance for common scenarios.

Does Zod 4 provide top-level validators for UUID and URL formats?

Yes, Zod 4 provides top-level validators for UUID and URL formats via z.uuid and z.url. These updated primitives replace older string-based patterns, offering dedicated runtime validation for TypeScript projects.

What is the best way to handle refinements in Zod 4?

The best way to handle refinements in Zod 4 is to apply updated schema patterns that accommodate breaking changes from v3. Clear migration notes and practical examples guide implementing refinements across common validation tasks.

Can I use Zod 4 for array and tuple validation in TypeScript?

Yes, you can use Zod 4 for array and tuple validation in TypeScript. It supports arrays, tuples, and unions with specific migration notes to ensure updated API usage and proper runtime validation across these structures.