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'.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Using Zod?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/xonovex-using-zod)
---
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