zod-schemas

Define Zod schemas for runtime validation and TypeScript type inference.

Updated Jan 6, 2026
One-click install
npx skills add https://github.com/cr8or-space/spine --skill zod-schemas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-schemas
Source: https://github.com/cr8or-space/spine/tree/main/.claude/skills/zod-schemas
Command: npx skills add https://github.com/cr8or-space/spine --skill zod-schemas

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod provides runtime validation with automatic TypeScript type inference. Define the schema once and get both validation and types.

Core Features & Use Cases

  • Schema definition with z.object, z.infer for types, and parse/safeParse for validating input data.
  • Pattern composition and extension: merging, picking, omitting, and discriminated unions to model complex data shapes.
  • Error handling and transformation: safeParse, format, and flatten for user-friendly error reporting, plus transform/coerce for data shaping.
  • Use cases across domains: validating API payloads, validating form inputs, and ensuring data integrity in domain models.
  • Real-world example: define a UserSchema with id, name, email, age, and status, infer a User type, validate input, and handle errors.

Quick Start

Install zod, define a base schema, infer TypeScript types, and validate data at runtime.

Frequently Asked Questions about zod-schemas

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

FAQPage Schema
How do I validate API payloads in TypeScript with automatic type inference?

Validate API payloads using Zod schemas to define data shapes once and automatically infer TypeScript types. Applying z.object with parse or safeParse ensures runtime validation and type inference for consistent API payloads.

What's the best way to handle runtime data validation errors for form inputs?

Handle runtime data validation errors for form inputs using safeParse to avoid exceptions, then format and flatten the returned error object. This approach produces user-friendly error reporting for invalid form inputs.

How do I model complex domain models using discriminated unions and schema composition?

Model complex domain models by merging, picking, omitting, and applying discriminated unions to Zod schemas. Pattern composition and extension allow you to validate data integrity across varied domain model shapes.

Can I transform and coerce data shapes during runtime validation?

Transform and coerce data shapes during runtime validation using Zod's transform and coerce features. Applying these alongside z.object allows you to shape input data dynamically while ensuring type-safe runtime validation.

Does this approach to runtime validation work for ensuring data integrity across systems?

Yes, Zod schema design works for ensuring data integrity across systems by validating API payloads, form data, and domain models. Defining a base schema once guarantees consistent data shapes across diverse systems.