thecarlo/carlo-marketplace
zod
plugins/zod/skills/zod/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/thecarlo/carlo-marketplace/blob/main/plugins/zod/skills/zod/SKILL.md -a claude-code --skill zodInstallation paths:
.claude/skills/zod/# Zod
This skill provides guidance for implementing type-safe validation using Zod v4 in TypeScript applications. It covers schema design, error handling, type inference, and migration from Zod 3.
## Zod 4 Requirements
This skill is exclusively for **Zod 4**, which introduced breaking changes from Zod 3. All examples and recommendations use Zod 4 syntax.
### Installation
```bash
npm install zod@^4.0.0
```
### Critical Zod 4 Changes
If you encounter Zod 3 code or examples, be aware of these breaking changes:
**Error Customization - Use `error` not `message`**
```typescript
z.string().min(5, { error: 'Too short.' });
z.string().min(5, { message: 'Too short.' });
```
**String Formats - Use top-level functions**
```typescript
z.email();
z.uuid();
z.url();
z.iso.date();
z.string().email();
```
**Object Methods - Use dedicated functions**
```typescript
z.strictObject({ name: z.string() });
z.looseObject({ name: z.string() });
z.object({ name: z.string() }).strict();
z.object({ name: z.string() }).passthrough();
```
**Error Formatting - Use top-level functions**
```typescript
z.flattenError(error);
z.treeifyError(error);
z.prettifyError(error);
error.flatten();
error.format();
```
**Function Schemas - New syntax**
```typescript
const myFn = z.function({
input: [z.string()],
output: z.number(),
});
const myFn = z.function().args(z.string()).returns(z.number());
```
**Enums - Unified API**
```typescript
enum Color {
Red = 'red',
Green = 'green',
}
z.enum(Color);
z.nativeEnum(Color);
```
**Deprecated APIs to avoid:**
- `invalid_type_error` and `required_error` parameters (use `error` function instead)
- `.merge()` on objects (use `.extend()` or object spread)
- `.deepPartial()` (removed, anti-pattern)
- `z.promise()` (rarely needed, just await the promise)
- Single-argument `z.record()` (now requires both key and value schemas)
### Key Improvements in Zod 4
- **Performance**: Dramatically faster parsing and validation
- **Error handling**: Unifi