.agents/skills/zod-to-form-runtime/SKILL.md
This skill should be used when the user asks to "set up zod-to-form", "create a form from a Zod schema", "add ZodForm to my project", "render a form from schema", "schema to form", "auto-generate form fields", "use zod-to-form runtime", "install zod-to-form", "dynamic form generation", "useZodForm hook", "ZodForm component", "form builder from zod", or wants to generate React forms from Zod v4 schemas at runtime using the ZodForm component. Covers installation, ZodForm props, metadata annotations via z.registry(), component customization, and the useZodForm hook.
npx skillsauth add pradeepmouli/zod-to-form zod-to-form-runtimeInstall 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.
Set up schema-driven React form generation using @zod-to-form/react. This skill covers installation, basic and advanced usage of the <ZodForm> component, metadata annotations, component customization, and the useZodForm hook.
Apply this skill when a project needs to render React forms directly from Zod v4 schemas at runtime — no build step or code generation required. Best suited for rapid prototyping, admin panels, and CRUD forms where schemas change frequently and forms should update instantly.
zod@^4.0.0) — Zod v3 is not supportedpnpm add @zod-to-form/core @zod-to-form/react zod react react-hook-form @hookform/resolvers
Replace pnpm add with npm install or yarn add as appropriate for the project.
import { z } from 'zod';
const userSchema = z.object({
name: z.string().min(1, 'Name is required'),
email: z.string().email('Invalid email'),
role: z.enum(['admin', 'editor', 'viewer']),
bio: z.string().optional(),
newsletter: z.boolean().default(false),
});
<ZodForm>import { ZodForm } from '@zod-to-form/react';
function UserForm() {
return (
<ZodForm
schema={userSchema}
onSubmit={(data) => console.log(data)} // typed as z.infer<typeof userSchema>
>
<button type="submit">Save</button>
</ZodForm>
);
}
<ZodForm> walks the schema, infers input types, derives labels from field names, wires zodResolver validation, and renders the form. No manual field mapping is needed.
Key props: schema (required), onSubmit, onValueChange, mode, defaultValues, components, componentConfig, formRegistry, processors, className, children. See references/api-reference.md for the complete props table with types.
Control rendering with Zod v4's native .meta() and z.registry():
import { z } from 'zod';
import type { FormMeta } from '@zod-to-form/core';
const formRegistry = z.registry<FormMeta>();
const schema = z.object({
name: z.string().meta({ title: 'Full Name' }),
bio: z.string().optional(),
});
formRegistry.register(schema.shape.bio, {
fieldType: 'textarea',
order: 1,
gridColumn: 'span 2',
});
<ZodForm schema={schema} formRegistry={formRegistry} onSubmit={handleSubmit}>
<button type="submit">Save</button>
</ZodForm>
import { shadcnComponentMap } from '@zod-to-form/react/shadcn';
<ZodForm schema={schema} components={shadcnComponentMap} onSubmit={handleSubmit}>
<button type="submit">Save</button>
</ZodForm>
Use a shared component config to keep shadcn as the base while overriding specific field types. The same config file works with the CLI — see references/shared-config.md.
// src/config/form-components.ts
import { defineComponentConfig } from '@zod-to-form/cli';
export default defineComponentConfig({
components: '@/components/ui',
fieldTypes: {
DatePicker: { component: 'MyDatePicker' },
Textarea: { component: 'MyRichTextEditor' },
},
fields: {
bio: { fieldType: 'Textarea', props: { rows: 6 } },
},
});
Pass shadcn as the base and the config for overrides:
import { shadcnComponentMap } from '@zod-to-form/react/shadcn';
import componentConfig from '@/config/form-components';
<ZodForm
schema={schema}
components={shadcnComponentMap}
componentConfig={componentConfig}
onSubmit={handleSubmit}
>
<button type="submit">Save</button>
</ZodForm>
Fields matched by the config get custom components; everything else renders with shadcn defaults.
Pass a componentConfig prop to map field types to custom components. This same config format works with the CLI codegen path — define the config once and use it in both paths. See references/shared-config.md for the full config shape, type-safe patterns, and resolution priority.
import componentConfig from '@/config/form-components';
<ZodForm schema={schema} componentConfig={componentConfig} onSubmit={handleSubmit}>
<button type="submit">Save</button>
</ZodForm>
For full control over the React Hook Form instance:
import { useZodForm } from '@zod-to-form/react';
function AdvancedForm() {
const { form, fields } = useZodForm(schema, {
mode: 'onChange',
onValueChange: (values) => console.log(values),
});
// Full access to RHF: form.watch(), form.setValue(), form.formState, etc.
return <pre>{JSON.stringify(fields, null, 2)}</pre>;
}
All major Zod types are supported — including nested objects (fieldset groups), arrays (repeaters with add/remove), and discriminated unions (select revealing variant fields). See references/api-reference.md for the full Zod-type-to-component mapping table.
The runtime renderer and CLI codegen share @zod-to-form/core — the same walker produces the same FormField[] tree. A component config file can drive both paths to produce functionally identical forms. See references/shared-config.md for details.
references/shared-config.md — Shared component config format for runtime + CLI parityreferences/api-reference.md — Complete API surface for @zod-to-form/reacttools
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
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.