shadcn-agents-form-validator
Installation
SKILL.md
shadcn ui : Form Validator (Agent / Validator)
This skill is an AGENT skill. It does NOT teach the Form API. It validates a react-hook-form + zod + shadcn Form composition against an eight-point checklist and emits a structured verdict.
The shadcn Form layer is a thin wrapper over FormProvider from react-hook-form. Most "my form is broken" reports trace to ONE of eight integration mistakes. ALWAYS run the eight-point check in order. NEVER skip a point because "it looks fine" : six of the eight failure modes are silent (no console error, no thrown exception, only wrong behaviour at submit).
Quick Reference : The Validator Workflow
Given a form code block C (a useForm call plus the JSX tree under <Form>), execute :
- Parse the zod schema to extract the canonical set of field paths (top-level keys, dotted paths for nested objects, indexed paths for arrays).
- Parse the
useForm<...>call to confirmresolver: zodResolver(schema)is present anddefaultValuescovers every schema path. - Walk every
<FormField name="..." />in the JSX tree. For each, record : thenamevalue, whether the rendered control usesregisterorController(via thefieldrender-prop), and whether a<FormMessage />is present in the FormItem. - Cross-check the FormField name set against the zod schema path set. Flag every mismatch (typo, missing field, orphan field).
- Classify each rendered control (Input, Textarea, Select, Checkbox, RadioGroup, Switch, Combobox, DatePicker) and verify the correct binding mechanism (register-class vs Controller-class).
- Verify the submit handler is
form.handleSubmit(onValid)and not a rawonSubmit. - Verify the JSX tree has exactly one
<Form>(one FormProvider) wrapping the form. Flag duplicated FormProvider or nested<Form>. - Emit verdict with pass / fail per checkpoint and the canonical fix per failure.