Skip to content
Back to skills

Using Zod

ASecurity

Use when writing or editing Zod 4.0+ schemas that validate data at runtime in TypeScript. Triggers on `.ts` files with `zod` imports, API input validation, `z.infer`, `z.uuid()`, `z.email()`, `z.iso.datetime()`, defaults, or refinements, even when the user doesn't say 'Zod'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentstypescriptgoapi

Works with

  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill using-zod --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Using Zod?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Using Zod
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-using-zod/badge)](https://www.skillsdirectory.com/skills/xonovex-using-zod)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: using-zod
description: "Use when writing or editing Zod 4.0+ schemas that validate data at runtime in TypeScript. Triggers on `.ts` files with `zod` imports, API input validation, `z.infer`, `z.uuid()`, `z.email()`, `z.iso.datetime()`, defaults, or refinements, even when the user doesn't say 'Zod'."
---

# Zod Coding Guidelines

Validate external data with Zod schemas and derive application types from the validated shape.

## Requirements

- Zod ≥ 4.0

## Essentials

- **Use v4 validators** - `z.uuid()`, `z.email()`, `z.iso.datetime()` (not `z.string().uuid()`), see [references/migration-v4.md](references/migration-v4.md)
- **Name schemas PascalCase** - e.g. `UserSchema`, see [references/schema-organization.md](references/schema-organization.md)
- **Module-level schemas** - Define for reuse, keep close to usage, see [references/schema-organization.md](references/schema-organization.md)
- **Multi-step validation** - Chain `.transform()` into `.pipe()` before `.default()`, see [references/validation-patterns.md](references/validation-patterns.md)

## Gotchas

- `optional()` makes a field accept `undefined`; `nullable()` accepts `null`. They're orthogonal, combine with `.nullish()` for both
- Refinements (`.refine`) don't narrow the output type: TypeScript still sees the broader input type unless you pair with `.transform`

## Progressive Disclosure

### Guidelines

- Read [references/schema-organization.md](references/schema-organization.md) - Load when naming or placing schemas across modules or files
- Read [references/validation-patterns.md](references/validation-patterns.md) - Load when composing multi-step validation with `.transform()` and `.pipe()`

### Migration from Zod v3

- Read [references/migration-v4.md](references/migration-v4.md) - Load when migrating from Zod v3, replacing z.string().uuid() patterns, or using deprecated validators

Files in this skill

  • SKILL.md1.8 KB
  • eval-output.json3.2 KB
  • eval-trigger.json5.5 KB
  • moon.yml86 B
  • references/migration-v4.md700 B
  • references/schema-organization.md325 B
  • references/validation-patterns.md456 B
  • sources.json1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.