zod

Validate untrusted runtime inputs with Zod 4 schemas and structured errors.

15|2|Updated May 23, 2026
One-click install
npx skills add https://github.com/VKirill/antigravity-for-claude-code --skill zod-vkirill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod
Source: https://github.com/VKirill/antigravity-for-claude-code/tree/main/skills/zod
Command: npx skills add https://github.com/VKirill/antigravity-for-claude-code --skill zod-vkirill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Zod eliminates the gap between TypeScript’s compile-time types and untrusted runtime data by validating API payloads, env vars, and form inputs while producing precise, per-field error reports.

Core Features & Use Cases

  • Runtime schema validation: Define Zod 4 schemas for objects and primitives, then parse or safely parse untrusted input without silent failures.
  • Transforms, refinements, and async validation: Normalize and convert values (e.g., coerce env/query data), enforce cross-field rules, and run async checks safely with parseAsync/safeParseAsync.
  • Discriminated unions and composition: Model tagged unions/state machines with z.discriminatedUnion, compose schemas with extend/merge/pick/omit/partial, and reuse types via z.infer.

Quick Start

Ask the AI to build a Zod 4 schema for my request body with strict mode, safeParse error flattening, and a typed output using z.infer.

Frequently Asked Questions about zod

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

FAQPage Schema
How do I validate API request payloads and environment variables at runtime in TypeScript?

Runtime schema validation parses untrusted API payloads and environment variables into typed outputs using safeParse, preventing silent failures and producing structured per-field errors. Zod 4 schemas define strict object boundaries to ensure data integrity at application edges.

What is the best way to model tagged unions and state machines with schema composition?

Schema composition models tagged unions and state machines using z.discriminatedUnion, allowing you to compose schemas via extend, merge, pick, omit, and partial. You can reuse the inferred TypeScript types with z.infer to maintain consistent typing across validated states.

How do I handle async validation and cross-field rules with runtime schema parsing?

Async validation and cross-field rules are handled using parseAsync or safeParseAsync with refinements. Refinements enforce custom constraints across multiple fields, while async checks safely execute external validation logic without blocking synchronous schema parsing operations.

Can I normalize and convert untrusted input data during the schema validation process?

Transforms normalize and convert untrusted input data during schema validation, allowing you to coerce environment or query data into correct types. This ensures the typed output matches expected formats while applying strict validation rules simultaneously.

How do I flatten safeParse errors into precise per-field error reports?

safeParse errors are flattened into precise per-field error reports using error.flatten(), converting nested validation failures into structured lists. This exposes specific field-level issues for API responses or form validation feedback.