form
Skill2 starsChanged 14 days agoMITView on GitHub
Build or extend a form the agent-craft way — zod schema and error keys first, react-hook-form logic, shadcn Field/FieldGroup markup, a control chooser, and submit through a Result-returning server action. Use whenever the user asks for a form, sign-up/login/checkout/contact/settings screen, input validation, a multi-step wizard, or a submit flow, and whenever a task adds two or more inputs that get submitted together, even if they only say "add a couple of fields".
4 other projects use a version of this.
Adopted by
Most recently taken up by
- lilly-builds/ads-cookingtheir own version, first seen Oct 20, 2026
- build-dezineer/skills-nuxt4-tw-webapptheir own version, first seen Oct 13, 2026
- IamK77/Skilltheir own version, first seen Oct 12, 2026
- gabriellst/codmtheir own version, first seen Aug 26, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- gabriellst/codm★ 4same name
- IamK77/Skill★ 2same name
- build-dezineer/skills-nuxt4-tw-webapp★ 0same name
- lilly-builds/ads-cooking★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- templates/CLAUDE.mdCLAUDE.md
- componentSkill
- conventionsSkill
- debugSkill
- featureSkill
- nextjs-pageSkill
- planSkill
- reviewSkill
- serviceSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Every form rule lives here.
- Distinctive: line 13
Present step 2 and wait for confirmation: before building UI.
- Very specific: line 117
Every field validates per the schema.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
agent-craft Form
Every form rule lives here. Load agent-craft:conventions for the rules that apply to all code, and agent-craft:service when the submit action doesn't exist yet.
Gates
- Schema and error keys before any markup. The schema drives the type, the fields, the resolver, and the server validation.
- Present step 2 and wait for confirmation before building UI.
- No raw
div+space-y-*form markup when the project has Field primitives. - No
try/catchin the submit handler. It reads aResult; the action already caught. - No generic form wrapper or field factory. Each form is written out; two similar forms are cheaper than one configurable one.
1. Form library or not
| Situation | Approach |
| 2+ fields, validation rules, or submit state | react-hook-form + zod (this skill) |
| A single input (search box, inline rename) | Plain state or a form action; say so and stop |
Reuse the repo's existing form pattern, schema location, and Field components.
2. Schema first
- Export a zod schema from the feature's
lib/(lib/contact-schema.ts); the form and the action both import it. Derive the type:type ContactValues = z.infer<typeof contactSchema>. - Field validation messages live in the schema (an i18n key, or the copy itself in a single-language app).
- Submit failures are error keys declared in the action (
agent-craft:service, step 6), named by reason when known.
Present the schema, the fields with their defaults, and the submit error keys. Wait for confirmation.
3. Choose controls
| Need | Control |
| Simple text | Input |
| Dropdown, predefined options | Select |
| Searchable dropdown | Combobox |
| Boolean in settings | Switch |
| Boolean in a form | Checkbox |
| Single choice, few options | RadioGroup |
| 2–5 options as buttons | ToggleGroup |
| Multi-line text | Textarea |
| One-time code | InputOTP |
- A button inside an input uses
InputGroup+InputGroupAddonwithInputGroupInput, never aButtonpositioned over anInput. - Related checkboxes, radios, or switches sit in
FieldSet+FieldLegend.
4. Build the form
One file, 'use client', markup and logic together:
// components/contact-form.tsx
'use client';
export const ContactForm = () => {
const form = useForm<ContactValues>({
defaultValues: { email: '', message: '' },
mode: 'onTouched', // validate after first blur, then live; onChange only for per-keystroke feedback
resolver: zodResolver(contactSchema),
});
const { errors, isSubmitting } = form.formState;
const handleSubmit = async (values: ContactValues) => {
const result = await submitContact(values);
if (!result.ok) {
form.setError('root', { message: errorCopy[result.errorKey] });
return;
}
form.reset();
};
return (
<form onSubmit={form.handleSubmit(handleSubmit)}>
<FieldGroup>
<Field data-invalid={!!errors.email}>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" type="email" aria-invalid={!!errors.email} {...form.register('email')} />
{errors.email ? <FieldError>{errors.email.message}</FieldError> : null}
</Field>
<Field data-invalid={!!errors.message}>
<FieldLabel htmlFor="message">Message</FieldLabel>
<Textarea id="message" aria-invalid={!!errors.message} {...form.register('message')} />
{errors.message ? <FieldError>{errors.message.message}</FieldError> : null}
</Field>
{errors.root ? <p role="alert">{errors.root.message}</p> : null}
<Button type="submit" disabled={isSubmitting}>
Send
</Button>
</FieldGroup>
</form>
);
};- Invalid and disabled need both attributes:
data-invalid/data-disabledonField(styles the label and description),aria-invalid/disabledon the control. registerorController, whichever the repo uses. Controlled shadcn components (Select,Checkbox) needController.isSubmittingguards against double submit; no extra flag.- Over 60 lines: move a repeated field block into a private component above the form in the same file.
5. File layout
components/contact-form.tsx # 'use client' — markup + useForm + submit
lib/contact-schema.ts # zod schema + type, shared by form and action
actions/submit-contact.ts # 'use server' — validate, call http, return Result; declares ContactErrorKeyA reader of the form opens at most the schema and the action.
6. Verify
- Every field validates per the schema; an invalid field shows on the right
Fieldwith both attributes set. - Submit shows the disabled state while
isSubmitting, then success, and each error key from step 2. rg "toast|setError" <form file>shows only resolved copy, never a string literal.rg "space-y-" <form file>returns nothing.- The repo's
typecheckandlintscripts pass.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

