form-builder
Generate a complete, typed React Hook Form component from a plain-language description.
Source-of-Truth Grounding
Before generating code, always verify API options from local docs:
- Register validation options:
${CLAUDE_SKILL_DIR}/docs/docs/useform/register.mdx
- useForm options (mode, defaultValues, etc.):
${CLAUDE_SKILL_DIR}/docs/docs/useform.mdx — skip the first 79 lines (SelectNav navigation component, content starts at line 80)
MDX Component Glossary
<TypeText>T</TypeText> or <TypeText pre>T</TypeText> — inline type annotation. Read the text content as the TypeScript type.
<PrettyObject value={{key: 'type', ...}}/> — renders a type shape. Read the value prop as the type definition.
<TabGroup buttonLabels={["X", "Y"]}> — tabbed content with alternative views (e.g., TS vs JS). Read all tabs as variants.
<Admonition type="note|important|tip" title="..."> — callout block. Always read; contains critical rules or caveats.
<SelectNav options={[...]}> — navigation menu. Skip for content purposes.
<CodeArea> — code display component. Read the code content within.
<Popup message="..."> — tooltip hint. The message prop contains supplementary info.
- Ignore:
<div style={...}>, import ..., export ... statements.
$ARGUMENTS Handling
Arguments provided → parse field definitions → follow the Code Generation Workflow below.
No arguments → show the following examples and ask the user to describe their form:
Usage examples:
/react-ko-form:form-builder login form with email and password
/react-ko-form:form-builder registration with name, email, password (min 8), confirm password, and terms checkbox
/react-ko-form:form-builder contact form with name, email, phone (optional), and message (textarea)
Describe your form and I'll generate the complete TypeScript component.
Code Generation Workflow
Step 1 — Parse the input
Extract from the natural language description:
- Field names
- Field types (text, email, password, number, checkbox, textarea, select, URL, phone)
- Validation requirements (required, minLength, maxLength, pattern, min, max, validate)
- Optional vs required fields
Step 2 — Read local docs
Read both files to verify current API options before generating:
${CLAUDE_SKILL_DIR}/docs/docs/useform/register.mdx — validation rule options
${CLAUDE_SKILL_DIR}/docs/docs/useform.mdx (from line 80) — useForm options
Step 3 — Generate the component
Produce all of the following in order:
- TypeScript
interface for form field types
useForm<T>() hook setup with appropriate options
register() calls with validation rules
formState.errors error handling for each validated field
handleSubmit + onSubmit function
- Complete JSX form component
Complexity Limit
For forms with more than 8 fields: generate the TypeScript interface and useForm setup first, then ask the user to confirm before generating the full JSX.
Common Validation Patterns
| Field Type |
Validation Rules |
| email |
{ required: "Email is required", pattern: { value: /\S+@\S+\.\S+/, message: "Invalid email" } } |
| password |
{ required: "Password is required", minLength: { value: 8, message: "At least 8 characters" } } |
| confirm password |
{ validate: (value, formValues) => value === formValues.password || "Passwords do not match" } |
| phone |
{ pattern: { value: /^\+?[0-9\s\-()]{7,15}$/, message: "Invalid phone number" } } |
| number |
{ min: 0, max: 999, valueAsNumber: true } |
| URL |
{ pattern: { value: /^https?:\/\/.+/, message: "Invalid URL" } } |
| required checkbox |
{ required: "You must accept the terms" } |
| textarea |
{ required: "Message is required", maxLength: { value: 500, message: "Max 500 characters" } } |
Dynamic Fields (useFieldArray)
useFieldArray has no MDX documentation. When dynamic fields are requested:
- Read
${CLAUDE_SKILL_DIR}/examples/useFieldArray.ts and ${CLAUDE_SKILL_DIR}/examples/useFieldArrayArgument.ts
- Key API:
useFieldArray({ control, name }) returns { fields, append, remove, prepend, swap, move, insert, update, replace }
- Always use
field.id as key (not array index)
- Provide full default shape on
append(): append({ name: "", quantity: 1 })
- Register nested fields as:
register(`items.${index}.name`)
Output Example
Given: "login form with email and password"
import { useForm } from "react-hook-form";
interface LoginFormValues {
email: string;
password: string;
}
export function LoginForm() {
const {
register,
handleSubmit,
formState: { errors },
} = useForm<LoginFormValues>({ mode: "onBlur" });
const LoginFormValues) => console.log(data);
return (
<form
<div>
<label htmlFor="email">Email</label>
<input
id="email"
type="email"
{...register("email", {
required: "Email is required",
pattern: { value: /\S+@\S+\.\S+/, message: "Invalid email" },
})}
/>
{errors.email && <span>{errors.email.message}</span>}
</div>
{/* Repeat the pattern above for each field */}
<button type="submit">Submit</button>
</form>
);
}
Constraints
- Generate basic HTML elements only (no MUI, shadcn, Chakra, or other UI libraries)
- Always use TypeScript with generics (
useForm<FormType>)
- Always include error handling for each validated field
- File output: ask the user where to write the file; default to chat output
Cross-Skill References
- Unsure which API to use? Try
/react-ko-form:recommend
- Need detailed API usage? Try
/react-ko-form:guide <api-name>
Based on react-hook-form v7.x documentation.
Source: hamsurang/react-ko-form — distributed by TomeVault.
1---2name: form-builder3description: Generate complete React Hook Form code from natural language field definitions. Use when the user wants to scaffold a typed form with validation and error handling. Use when this capability is needed.4---56# form-builder78Generate a complete, typed React Hook Form component from a plain-language description.910## Source-of-Truth Grounding1112Before generating code, always verify API options from local docs:1314- Register validation options: `${CLAUDE_SKILL_DIR}/docs/docs/useform/register.mdx`15- useForm options (mode, defaultValues, etc.): `${CLAUDE_SKILL_DIR}/docs/docs/useform.mdx` — skip the first 79 lines (SelectNav navigation component, content starts at line 80)1617## MDX Component Glossary1819- `<TypeText>T</TypeText>` or `<TypeText pre>T</TypeText>` — inline type annotation. Read the text content as the TypeScript type.20- `<PrettyObject value={{key: 'type', ...}}/>` — renders a type shape. Read the `value` prop as the type definition.21- `<TabGroup buttonLabels={["X", "Y"]}>` — tabbed content with alternative views (e.g., TS vs JS). Read all tabs as variants.22- `<Admonition type="note|important|tip" title="...">` — callout block. Always read; contains critical rules or caveats.23- `<SelectNav options={[...]}>` — navigation menu. Skip for content purposes.24- `<CodeArea>` — code display component. Read the code content within.25- `<Popup message="...">` — tooltip hint. The `message` prop contains supplementary info.26- Ignore: `<div style={...}>`, `import ...`, `export ...` statements.2728## $ARGUMENTS Handling2930**Arguments provided** → parse field definitions → follow the Code Generation Workflow below.3132**No arguments** → show the following examples and ask the user to describe their form:3334```35Usage examples:36 /react-ko-form:form-builder login form with email and password37 /react-ko-form:form-builder registration with name, email, password (min 8), confirm password, and terms checkbox38 /react-ko-form:form-builder contact form with name, email, phone (optional), and message (textarea)3940Describe your form and I'll generate the complete TypeScript component.41```4243## Code Generation Workflow4445### Step 1 — Parse the input4647Extract from the natural language description:4849- Field names50- Field types (text, email, password, number, checkbox, textarea, select, URL, phone)51- Validation requirements (required, minLength, maxLength, pattern, min, max, validate)52- Optional vs required fields5354### Step 2 — Read local docs5556Read both files to verify current API options before generating:57581. `${CLAUDE_SKILL_DIR}/docs/docs/useform/register.mdx` — validation rule options592. `${CLAUDE_SKILL_DIR}/docs/docs/useform.mdx` (from line 80) — useForm options6061### Step 3 — Generate the component6263Produce all of the following in order:64651. TypeScript `interface` for form field types662. `useForm<T>()` hook setup with appropriate options673. `register()` calls with validation rules684. `formState.errors` error handling for each validated field695. `handleSubmit` + `onSubmit` function706. Complete JSX form component7172## Complexity Limit7374For forms with **more than 8 fields**: generate the TypeScript interface and `useForm` setup first, then ask the user to confirm before generating the full JSX.7576## Common Validation Patterns7778| Field Type | Validation Rules |79|---|---|80| email | `{ required: "Email is required", pattern: { value: /\S+@\S+\.\S+/, message: "Invalid email" } }` |81| password | `{ required: "Password is required", minLength: { value: 8, message: "At least 8 characters" } }` |82| confirm password | `{ validate: (value, formValues) => value === formValues.password \|\| "Passwords do not match" }` |83| phone | `{ pattern: { value: /^\+?[0-9\s\-()]{7,15}$/, message: "Invalid phone number" } }` |84| number | `{ min: 0, max: 999, valueAsNumber: true }` |85| URL | `{ pattern: { value: /^https?:\/\/.+/, message: "Invalid URL" } }` |86| required checkbox | `{ required: "You must accept the terms" }` |87| textarea | `{ required: "Message is required", maxLength: { value: 500, message: "Max 500 characters" } }` |8889## Dynamic Fields (useFieldArray)9091`useFieldArray` has no MDX documentation. When dynamic fields are requested:92931. Read `${CLAUDE_SKILL_DIR}/examples/useFieldArray.ts` and `${CLAUDE_SKILL_DIR}/examples/useFieldArrayArgument.ts`942. Key API: `useFieldArray({ control, name })` returns `{ fields, append, remove, prepend, swap, move, insert, update, replace }`953. Always use `field.id` as key (not array index)964. Provide full default shape on `append()`: `append({ name: "", quantity: 1 })`975. Register nested fields as: `` register(`items.${index}.name`) ``9899## Output Example100101Given: "login form with email and password"102103```tsx104import { useForm } from "react-hook-form";105106interface LoginFormValues {107 email: string;108 password: string;109}110111export function LoginForm() {112 const {113 register,114 handleSubmit,115 formState: { errors },116 } = useForm<LoginFormValues>({ mode: "onBlur" });117118 const onSubmit = (data: LoginFormValues) => console.log(data);119120 return (121 <form onSubmit={handleSubmit(onSubmit)}>122 <div>123 <label htmlFor="email">Email</label>124 <input125 id="email"126 type="email"127 {...register("email", {128 required: "Email is required",129 pattern: { value: /\S+@\S+\.\S+/, message: "Invalid email" },130 })}131 />132 {errors.email && <span>{errors.email.message}</span>}133 </div>134135 {/* Repeat the pattern above for each field */}136137 <button type="submit">Submit</button>138 </form>139 );140}141```142143## Constraints144145- Generate basic HTML elements only (no MUI, shadcn, Chakra, or other UI libraries)146- Always use TypeScript with generics (`useForm<FormType>`)147- Always include error handling for each validated field148- File output: ask the user where to write the file; default to chat output149150## Cross-Skill References151152- Unsure which API to use? Try `/react-ko-form:recommend`153- Need detailed API usage? Try `/react-ko-form:guide <api-name>`154155---156157Based on react-hook-form v7.x documentation.158159---160> Source: [hamsurang/react-ko-form](https://github.com/hamsurang/react-ko-form) — distributed by [TomeVault](https://tomevault.io).161<!-- tomevault:4.0:skill_md:2026-04-29 -->