About zod
zod is a development skill for projects using Zod schemas and validation. It covers schema design, inferred types, errors, JSON Schema, performance compilation, and migration from Zod 3 to Zod 4.
Key features
- 01Design runtime validation schemas
- 02Handle inferred types and parsing errors
- 03Work with JSON Schema and metadata
- 04Use Zod Mini and Zod Core
- 05Guide Zod 3 to Zod 4 migrations
Use cases
- 01Validating API or form inputs
- 02Parsing environment and persisted data
- 03Generating JSON Schema or OpenAPI contracts
- 04Migrating a project to Zod 4
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill zodAfter installing, type/zodin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/effects-errors.mdmetadata-jsonschema-migration.mdschema-api.mdsetup-core.mdsource-map.mdDetails
From the project READMEZod
Use this skill when work touches Zod validation, schema design, type inference, error handling, JSON Schema, AOT compilation, Zod Mini, Zod Core, or Zod 3 to Zod 4 migration.
Snapshot: [email protected] / @zod/[email protected] (verified 2026-10-01). Stay on Zod 4 latest. Do not use canary. Refresh from source-map.md if versions differ.
Workflow
- Inspect the local Zod surface before changing code:
- Package versions for
zod, optional@zod/mini, validation adapters, form libraries, API layers, code generators, and TypeScript. - Imports:
zod,zod/v4,zod/mini,@zod/mini,zod/v4/core,zod/compile, orzod/v3. - Schema role: untrusted boundary validation, API contract, form values, environment parsing, persistence, JSON Schema/OpenAPI, hot-path compile, library integration, or migration.
- Type flow: where
z.input<>,z.output<>, andz.infer<>are consumed, especially around transforms, codecs, coercion, defaults, and preprocessors.
- Package versions for
- Refresh docs when the user asks for latest/current behavior, the installed version is unclear, or the work touches migration-sensitive APIs. Start from source-map.md.
- For installation, imports, parse/
validate/compile, inference, package variants, and boundary design, use setup-core.md. - For schema primitives, string formats, objects, records, arrays, unions, recursive schemas, functions, brands,
z.toZod, and instance property checks, use schema-api.md. - For refinements,
.check(), transforms, pipes, preprocess, codecs, defaults, prefaults, catch values, and errors, use effects-errors.md. - For metadata, registries, JSON Schema conversion, Zod Mini, Zod Core, library-author support, and Zod 4 / 4.5 / 4.6 migration checks, use metadata-jsonschema-migration.md.
- Implement in the existing project style:
- Match local import conventions unless a version boundary requires a different subpath.
- Prefer explicit boundary schemas over broad
z.any()or unchecked casts. - Keep parsing and transformation behavior visible at API, form, environment, and storage boundaries.
- Do not introduce canary-only behavior. npm
canaryis stale relative tolatest.
Zod Judgment
- Treat schemas as runtime contracts, not just TypeScript type factories.
- Use
safeParsefor recoverable user/input failures andparsewhen invalid data is exceptional. - Use
.validate()/z.validate()when you only need a boolean type guard and do not want aZodError. - Use
parseAsync,safeParseAsync, orvalidateAsyncwhenever any refinement, transform, or codec path is async. - Distinguish
z.input<>fromz.output<>when usingcoerce,preprocess,transform,pipe,codec,default,prefault, orcatch. Runtimez.input(schema)/z.output(schema)project codec/pipe halves. - Prefer top-level Zod 4 string format APIs (
z.email(),z.uuid(),z.hash("sha256"),z.creditCard(),z.iban(),z.iso.datetime()) over deprecated method forms when writing new code. - Remember that
z.object()strips unknown keys by default; usez.strictObject(),z.looseObject(), or.catchall()deliberately.__proto__is always stripped. - For enum-keyed records, Zod 4 checks exhaustiveness. Use
z.partialRecord()for optional enum-keyed maps. - Prefer object spread or
.extend()for object composition; use.safeExtend()when extending schemas with refinements. - Use codecs for bidirectional serialization and transforms for one-way parsing.
- Compile hot object/array/union paths with
z.compile()(orimport "zod/compile"in apps). Compile the final schema. Do not compile in libraries. - Validate class instances in place with
z.instanceof(C).properties({ ... }), notz.object(). - For library authors, use
zod/v4/coreand top-level parse helpers when supporting both Zod and Zod Mini. New libraries should peer onzod@^4.0.0only.
Verification
Prefer the repo's existing checks. For meaningful Zod work, include the relevant subset:
- Typecheck for inferred input/output types, schema composition, brands,
z.toZod<T>(), and library generic constraints. - Focused tests for valid input, invalid input, unknown keys, defaults/prefaults, transforms, codecs, async paths, and error paths.
- Runtime smoke for boundary parsers such as API handlers, env loaders, forms, server actions, CLIs, and persistence adapters.
- Compile checks on hot schemas: valid inputs stay fast; invalid inputs still produce the same issues; derived schemas (
.extend(),.refine()) are recompiled if they need the fast path. - Snapshot or contract tests for JSON Schema/OpenAPI output when schema metadata or conversion behavior changes.
- Migration checks for deprecated Zod 3 APIs, 4.5/4.6 soundness fixes (datetime seconds, string code points,
z.emoji(), JSON Schema bounds), object defaults, enum records, functions, and removed internals.