skills/zod-v4/SKILL.md
Zod v4 TypeScript schema design, Zod 3 to 4 migration, validation boundaries, errors, codecs, JSON Schema/OpenAPI, metadata, Zod Mini/Core, RHF/tRPC/Hono/Next integrations, and rule-aware audits for Zod 4.4.3.
npx skillsauth add bjornmelin/dev-skills zod-v4Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Rule-first Zod v4.4.3 guidance for TypeScript. Start with the highest-risk matching rule, then load the linked reference only when deeper API detail is needed.
bun add zod@^4.4.3
import { z } from "zod";
const User = z.object({
name: z.string().min(1, { error: "Required" }),
email: z.email({ error: "Invalid email" }),
});
type User = z.infer<typeof User>;
| Task | Start Here |
| --- | --- |
| v3 migration or deprecated API cleanup | rules/_index.md, then references/migration-v3-to-v4.md |
| User input, env, HTTP, DB, queue, or JSON boundaries | parse-*, schema-*, and references/codecs-v4.md |
| Current schema APIs, string formats, records, template literals, XOR, defaults | references/schema-surface-v4.md |
| UI/API/CLI error messages | error-*, migrate-error-*, and references/errors-v4.md |
| Object composition, strictness, or refined schemas | object-* rules |
| JSON Schema/OpenAPI export | jsonschema-*, meta-*, and references/json-schema-v4.md |
| Bidirectional wire/internal transforms | codec-* and references/codecs-v4.md |
| React Hook Form, tRPC, Hono, or Next.js actions | references/ecosystem-*.md |
| Zod Mini, package exports, or library-author work | references/package-surfaces-v4.md |
| Repo audit before a migration | references/audit.md and scripts/zod-audit.ts |
safeParse for untrusted input, parseAsync
for async refinements/transforms, and never trust JSON.parse output.z.enum, z.object
plus z.strictObject or z.looseObject, unified { error }, top-level
error formatters, and z.toJSONSchema.z.record(valueSchema) are valid in Zod 4.4.3; treat them as local
style or migration-advisory findings, not package-invalid code.z.codec, z.decode,
z.encode, and z.invertCodec for reversible wire/internal mappings.zod/v4/core only for library tooling: app code normally imports
from zod; bundle-sensitive app code can use zod/mini; schema tooling and
library adapters should read references/package-surfaces-v4.md.| Priority | Category | Prefix |
| --- | --- | --- |
| 1 | Migration + deprecations | migrate- |
| 2 | Parsing + boundaries | parse- |
| 3 | Error handling | error- |
| 4 | Objects + composition | object- |
| 5 | Schema definitions | schema- |
| 6 | Metadata + registries | meta- |
| 7 | JSON Schema/OpenAPI | jsonschema- |
| 8 | Codecs | codec- |
| 9 | Package surfaces | package- |
Start with rules/_index.md. Each rule file has the failure mode, compact
bad/good examples, and linked references when nuance matters.
Resolve skill_dir as the directory containing this skill before running
bundled scripts.
Run the Zod-specific report-only scanner:
bun "$skill_dir/scripts/zod-audit.ts" --root . --format text
Useful commands:
bun "$skill_dir/scripts/zod-audit.ts" --list-rules
bun "$skill_dir/scripts/zod-audit.ts" --list-checks
bun "$skill_dir/scripts/zod-audit.ts" --explain migrate-top-level-string-formats
Use --fail-on warn|error|info only after reviewing whether advisory rules are
appropriate for the target repo.
Use the shared dependency-free scanner for broad AI-stack migration signals:
python3 "$skill_dir/scripts/ai_stack_scan.py" --root . --family zod-v4 --pretty
Treat scanner output as private local evidence. Verify each signal against the current code and Zod docs/source before editing.
bun "$skill_dir/scripts/build-rules-index.ts"
bun "$skill_dir/scripts/check-skill-integrity.ts"
Load a schema from a local module and exercise parse, decode/encode, or JSON Schema behavior:
bun "$skill_dir/scripts/zod-run.ts" --module src/schemas/user.ts --export User --mode safeParse --input '{"name":"A","email":"[email protected]"}'
bun "$skill_dir/scripts/zod-run.ts" --module src/schemas/date.ts --export IsoDate --mode encode --input '"2026-05-13T00:00:00.000Z"'
bun "$skill_dir/scripts/zod-run.ts" --module src/schemas/user.ts --export User --mode toJSONSchema --io input --target openapi-3.0
zod-run.ts imports the target module, so avoid modules with heavy side
effects.
references/index.mdreferences/migration-v3-to-v4.mdreferences/schema-surface-v4.mdreferences/errors-v4.md, references/error-formatting-v4.mdreferences/metadata-registries-v4.md, references/json-schema-v4.mdreferences/codecs-v4.mdreferences/package-surfaces-v4.mdreferences/ecosystem-react-hook-form.md, references/ecosystem-trpc.md, references/ecosystem-hono.md, references/ecosystem-nextjs-server-actions.mdreferences/audit.mdassets/templates/rule-template.mddevelopment
Pre-PR multi-model review, parallel opus and codex exec adversarial lanes, then adversarial verification of merged findings. Read-only. Use before shipping nontrivial diffs.
tools
Independent gpt-5.6 diff review via the Codex CLI, normal or steerable adversarial with JSON findings. Use before shipping nontrivial changes.
development
Delegate implementation, investigation, or bulk work to gpt-5.6 codex via pinned codex exec. Use for clear-spec builds, migrations, debugging, or any task MODELS.md routes to codex.
development
Adversarial pre-mortem: imagine the plan failed, work backwards to surface risky assumptions + irreversible bets, then harden them. Proactively offer it (after the current request; confirm first) before a hard-to-reverse or one-way-door call (API, schema, framework, a hire), an all-upside plan, or unvalidated assumptions. Also on request.