agentleFS
MohammadShehadehMohammadShehadeh/agent-skills/skills/form/SKILL.md

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

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. gabriellst/codm★ 4same name
    2. IamK77/Skill★ 2same name
    3. build-dezineer/skills-nuxt4-tw-webapp★ 0same name
    4. 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.

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
  1. Very specific:

    Every form rule lives here.

    line 8
  2. Distinctive:

    Present step 2 and wait for confirmation: before building UI.

    line 13
  3. Very specific:

    Every field validates per the schema.

    line 117

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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/catch in the submit handler. It reads a Result; 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

SituationApproach
2+ fields, validation rules, or submit statereact-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

NeedControl
Simple textInput
Dropdown, predefined optionsSelect
Searchable dropdownCombobox
Boolean in settingsSwitch
Boolean in a formCheckbox
Single choice, few optionsRadioGroup
2–5 options as buttonsToggleGroup
Multi-line textTextarea
One-time codeInputOTP
  • A button inside an input uses InputGroup + InputGroupAddon with InputGroupInput, never a Button positioned over an Input.
  • 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-disabled on Field (styles the label and description), aria-invalid / disabled on the control.
  • register or Controller, whichever the repo uses. Controlled shadcn components (Select, Checkbox) need Controller.
  • isSubmitting guards 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 ContactErrorKey

A 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 Field with 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 typecheck and lint scripts pass.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.