skills/zod-to-form-core/SKILL.md
Schema walker and processor registry for Zod v4 form generation Use when: You want per-field validation instead of whole-form validation. Also: zod, zod-v4, forms, form-generation, schema, schema-walker, processor-registry, react-hook-form, schema-driven, form-schema, zod-registry.
npx skillsauth add pradeepmouli/zod-to-form zod-to-form-coreInstall 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.
Schema walker and processor registry for Zod v4 form generation
Requires Zod v4 — uses _zod.def, _zod.bag, and z.registry() APIs.
Does NOT work with Zod v3 (which uses _def internals).
Key concepts:
z.registry<FormMeta>() stores per-schema field configshadcn preset maps to controlled components with field expressionsimport { z } from 'zod';
import { walkSchema } from '@zod-to-form/core';
const schema = z.object({
name: z.string().min(1).describe('Your full name'),
age: z.number().int().min(0),
newsletter: z.boolean().default(false)
});
const fields = walkSchema(schema);
console.log(fields.map((f) => ({ key: f.key, component: f.component })));
Use this skill when:
createOptimizerscreateOptimizersdefineConfig — defineConfig is the typed entry point; bare object literals lose generic inference on components.overridesunknown → use validateConfig — validates and narrows to ZodFormsConfignormalizeFormValues — HTML inputs produce "" for unset optional fields, which Zod rejects; this is the single mandatory normalization stepwalkSchemawalkSchemaregisterDeepregisterDeepregisterFlatregisterFlatDo NOT use when:
createOptimizers)defineConfig is a no-op at runtime without a preset; skip it when config comes from JSON or dynamic import (defineConfig)validateConfig)normalizeFormValues)walkSchema)walkSchema)registerDeep)registerDeep)registerFlat)API surface: 49 functions, 20 types, 4 constants
9 configuration interfaces — see references/config.md for details.
Configuration: canonicalizeConfig (Serialize a CodegenConfig to a canonical string suitable for
hashing into a cache key), defineConfig (Identity helper that returns its argument typed as ZodFormsConfig), validateConfig (Validates an unknown value as a ZodFormsConfig at runtime), resolveFieldConfig (Merge global field config with per-schema field config overrides), normalizeConfig (Normalize a validated config by migrating deprecated top-level fields to their canonical locations), ComponentPreset (Preset name for built-in component library mappings), ConfigDefaults (Default generation settings applied to all schemas unless overridden per-schema)
Optimization: createOptimizers (Create an optimizer registry by merging custom optimizers with builtins), createSchemaLiteCollector (Create a new SchemaLiteCollector instance), FormOptimizer (An optimizer function that mutates a FormField after the processor has run), FormOptimizerContext (Context shared across all optimizers during a walkSchema run), SchemaLiteCollector (Mutable accumulator that builds a lite Zod schema for submit-time validation), builtinOptimizers (The default optimizer registry — L1 (decompose) + L2 (native rules) chains merged per type)
utils: inferLabel (Convert a camelCase or snake_case key to a human-readable Title Case label)
Utils: joinPath (Join a parent path and a child key with a dot separator), createBaseField (Create a base FormField with sensible defaults), getEmptyDefault (Returns a type-safe empty default value for a FormField based on its zodType
and structure), normalizeFieldKey (Normalise a concrete field key to the bracket notation used in config), collectFieldSections (Collect section groupings from fields and a config override lookup)
Normalization: normalizeFormValues (Normalize raw HTML form values for Zod parsing)
Schema Walking: walkSchema (Walk a Zod schema and produce a FormField[] tree), WalkResult (The result returned by walkSchema() when an optimization level is specified)
Registry: createProcessors (Create a custom processor registry by merging with built-in processors), builtinProcessors (The default processor registry — maps every Zod v4 def) **Registration:** registerDeep(Register a schema and all its nested fields in a registry using a path-structured FieldConfig tree),registerFlat(Register flat dot-path field configs against a schema's registry) **Processors:**processArray(Processz), processTuple (Process z), processBoolean(Processz), processMap (Process z), processSet(Processz), processCrossRef (Process a cross-reference field — a schema annotated in the form registry with refType), processDate (Process z), processEnum(Processz), processLiteral (Process z), processFallback(Fallback processor for Zod types without a dedicated handler),processFile(Processz), processNumber (Process z), processObject(Processz), processIntersection (Process z), processRecord(Processz), processString (Process z), processTemplateLiteral(Processz), processUnion (Process z), processDiscriminatedUnion(Processz), processDefault (Process z), processLazy(Processz), processNullable (Process z), processOptional(Processz), processPipe (Process z), processReadonly(Processz)
Loader: loadSchema (Load a single named Zod schema export from a TypeScript or JavaScript
file), loadSchemaModule (Load a schema file and return the entire module namespace, leaving the
choice of which export to use to the caller), resolveSchemaExportNames (Return the sorted list of named Zod schema exports in a schema file), loadConfig (Load and validate a component config file (z2f), resolveDefaultConfigPath(Walk the standard config-file naming candidates incwdand return the first that exists),loadDefaultConfig(Load and validate the default config file fromcwd by auto-discovering standard naming candidates (z2f)
Types: FormField (Intermediate representation of a single form field produced by walkSchema), FormFieldOption (An individual option in a Select, RadioGroup, or similar enum-driven component), FormFieldConstraints (Structural constraints extracted from Zod's _zod), FormProcessor(A processor function that mutates aFormFieldin-place based on the Zod schema it handles),FormProcessorContext(Runtime context passed to every processor during a walkSchema traversal),FormMeta(Per-schema annotation stored in az), ProcessParams (Optional parameters passed to each processor alongside the schema, context, and field), NativeRules (Native HTML and RHF validation rules extracted from Zod constraints), ValidationStrategy (Specifies how a field's validation is handled at submit and change time)
types: FieldExpression (Known RHF field expression strings that can be used as values in props), ZodFormRegistry (Zod v4 registry parameterized with FormMeta)
config: ComponentOverride (Per-component metadata override), StripIndexSignature (Strips index signatures from a type, keeping only explicitly declared keys), SHADCN_OVERRIDES (shadcn preset — Radix-based components need controlled mo...), DEFAULT_OVERRIDES (Default HTML preset — no controlled components by default)
optimizers: SchemaLiteInfo (Metadata for codegen to reconstruct the lite schema in a...)
Load these on demand — do NOT read all at once:
references/functions.md for full signatures, parameters, and return typesreferences/types.mdreferences/variables.mdreferences/config.md for all settings and defaultstools
Use when working with zod-to-form (core, react, cli, codegen, vite).
tools
Vite plugin for zod-to-form — transforms ?z2f imports into generated form components and optionally replaces <ZodForm> JSX call sites with generated components at build time Use when: You want `import SignupForm from './signup.schema?z2f'` to Just Work in a.... Also: vite, vite-plugin, zod, zod-v4, codegen, forms, form-generation, schema-driven, react-hook-form, build-plugin, jsx-transform.
development
Runtime <ZodForm> renderer for Zod v4 schemas Use when: You need form rendering in storybook, playgrounds, or low-traffic admin UIs —.... Also: zod, zod-v4, react, forms, form-generation, react-hook-form, schema-driven, dynamic-forms, form-renderer, hookform-resolver, zod-form-renderer.
development
Browser-safe code generation for Zod v4 form components Use when: Building a custom codegen pipeline that assembles `FormField[]` and needs the.... Also: zod, zod-v4, codegen, forms, form-generation, react-hook-form, schema-driven, template-generation, browser-safe, component-codegen, schema-to-tsx.