agentleFS
davision0102davision0102/fabrik/.agents/skills/add-form/SKILL.md

add-form

Skill3 starsChanged 3 days agoMITView on GitHub

Créer un formulaire avec validation (contact, inscription, newsletter, paramètres). À utiliser dès qu'un formulaire a plus d'un champ ou des règles de validation.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. felipemenezes098/ui-flx★ 47same 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 repository12 other files it gives its agents.

The file

Files
SKILL.md

Ajouter un formulaire

Pour un champ unique sans règle (une recherche), un simple useState suffit. Au-delà, utiliser react-hook-form et zod.

1. Installer (la première fois)

npm install react-hook-form zod @hookform/resolvers
npx shadcn@latest add label

2. Modèle

import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { z } from 'zod'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Textarea } from '@/components/ui/textarea'

const schema = z.object({
  email: z.email('Adresse e-mail invalide'),
  message: z.string().min(10, 'Au moins 10 caractères'),
})

type Values = z.infer<typeof schema>

export function ContactForm() {
  const {
    register,
    handleSubmit,
    reset,
    formState: { errors, isSubmitting, isSubmitSuccessful },
  } = useForm<Values>({ resolver: zodResolver(schema) })

  async function onSubmit(values: Values) {
    // Envoyer les données ici (API, service de formulaires…)
    console.log(values)
    reset()
  }

  return (
    <form onSubmit={handleSubmit(onSubmit)} noValidate className="grid gap-5">
      <div className="grid gap-2">
        <Label htmlFor="email">E-mail</Label>
        <Input
          id="email"
          type="email"
          aria-invalid={!!errors.email}
          {...register('email')}
        />
        {errors.email && (
          <p className="text-sm text-destructive">{errors.email.message}</p>
        )}
      </div>

      <div className="grid gap-2">
        <Label htmlFor="message">Message</Label>
        <Textarea
          id="message"
          aria-invalid={!!errors.message}
          {...register('message')}
        />
        {errors.message && (
          <p className="text-sm text-destructive">{errors.message.message}</p>
        )}
      </div>

      <Button
        type="submit"
        disabled={isSubmitting}
        className="justify-self-start"
      >
        {isSubmitting ? 'Envoi…' : 'Envoyer'}
      </Button>
      {isSubmitSuccessful && (
        <p className="text-sm text-muted-foreground">Merci, message envoyé !</p>
      )}
    </form>
  )
}

Règles

  • Chaque champ a un <Label> relié par htmlFor / id.
  • aria-invalid sur un champ en erreur : les composants ui/ affichent alors la bordure rouge tout seuls.
  • Messages d'erreur courts, en français, sous le champ.
  • Le site est statique : pour recevoir les messages sans serveur, utiliser un service de formulaires (Formspree, Web3Forms…) ou une fonction serverless.
  • Ajouter un test (skill add-test) qui vérifie l'affichage d'une erreur et l'envoi valide.

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.