@tank/zod-patterns

Design Zod validation patterns for TypeScript data at application boundaries.

1|1|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/tankpkg/packages --skill tank-zod-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: @tank/zod-patterns
Source: https://github.com/tankpkg/packages/tree/main/skills/zod-patterns
Command: npx skills add https://github.com/tankpkg/packages --skill tank-zod-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill removes guesswork from TypeScript data validation by showing how to turn untrusted input into trusted, typed values with Zod.

Core Features & Use Cases

It covers schema primitives and composition, transforms and pipes, refinements, coercion, error handling, type inference, branded and recursive schemas, and Zod 4 features such as metadata registries, JSON Schema conversion, file schemas, stringbool, and template literals. It also shows how to apply those patterns in React Hook Form, tRPC, Next.js, Express, Hono, environment variable parsing, and library comparisons across Zod, Valibot, ArkType, Yup, and TypeBox.

Quick Start

Ask for a Zod schema pattern guide for your TypeScript use case, including validation, type inference, error handling, and framework integration.

Frequently Asked Questions about @tank/zod-patterns

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

FAQPage Schema
How do I validate environment variables with Zod in a TypeScript application?

You validate environment variables with Zod by defining a schema that parses process.env, turning untrusted strings into typed configuration objects with runtime checks and custom error formatting. This ensures invalid or missing variables fail fast at startup.

Can I use Zod schemas with React Hook Form for TypeScript type inference?

Yes, Zod integrates with React Hook Form using resolver adapters. You define a Zod schema for your form data, and TypeScript type inference automatically generates the form values interface, ensuring your runtime validation logic stays synchronized with your static types.

How does Zod handle recursive schemas and nested data validation?

Zod handles recursive schemas using lazy evaluation with z.lazy, allowing you to validate deeply nested JSON structures or tree data. This pattern ensures runtime parsing correctly validates self-referential objects while maintaining accurate TypeScript type inference.

Does Zod support converting schemas to JSON Schema for API documentation?

Yes, Zod 4 supports JSON Schema conversion through metadata registries. You register your Zod schemas and convert them into standard JSON Schema output, enabling seamless API documentation generation and integration with external tools.

What is the best way to handle custom error formatting in Zod for tRPC APIs?

The best way to handle custom error formatting in Zod for tRPC is using the zodErrorMap function to intercept and restructure validation issues. This allows you to return localized, user-friendly error messages directly through your tRPC procedure responses.

How do Zod transforms and pipes work for coercing untrusted input?

Zod transforms and pipes work by chaining schema operations that coerce untrusted input into trusted values. You apply transforms to modify parsed data types, then pipe them through subsequent schemas to enforce strict runtime validation before the data reaches your application boundaries.