Back to skills
SKILL.md
Zod
ASecurity> TypeScript-first schema validation with static type inference.
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added October 26, 2026
Works with
Security analysis
100/100npx -y skills add nhan03bit/ultrathink --skill zod --agent claude-codeAre you the author of Zod?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nhan03bit-zod)# Zod
> TypeScript-first schema validation with static type inference.
## When to Use
- Validating API request/response bodies
- Form validation with react-hook-form
- Environment variable validation
- Runtime type checking at system boundaries
## Core Patterns
### Schema Definition
```typescript
import { z } from "zod";
const UserSchema = z.object({
name: z.string().min(1).max(100),
email: z.string().email(),
age: z.number().int().positive().optional(),
role: z.enum(["admin", "user", "moderator"]),
tags: z.array(z.string()).default([]),
});
type User = z.infer<typeof UserSchema>;
```
### Validation
```typescript
// parse() throws on failure, safeParse() returns result object
const result = UserSchema.safeParse(data);
if (!result.success) {
console.log(result.error.flatten()); // { fieldErrors: { email: ["Invalid email"] } }
}
```
### Common Combinators
- `.transform()` — transform after validation
- `.refine()` — custom validation logic
- `.superRefine()` — multi-field validation with path
- `z.discriminatedUnion()` — tagged unions
- `z.intersection()` — combine schemas
- `.passthrough()` / `.strict()` — unknown key handling
### Integration
- **react-hook-form**: `zodResolver(schema)` in useForm
- **tRPC**: schemas as input/output validators
- **Next.js**: server action validation
- **Env vars**: `z.object({...}).parse(process.env)` at startup
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.