协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
enhance-web-forms【开发与工程】Build or upgrade web forms: accessible structure, schema-driven validation, client↔server parity. Use when "improve this form", "form validation", "accessible form", "multi-step form", "form error handling", or "the form UX is bad".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: MIXED. Schema and state-machine judgment [HIGH freedom]; a11y probes and playwright walks [LOW freedom — run exactly].
Forms are where users hand you their data and where apps most often feel broken: unlabeled fields, validation that fires on every keystroke, errors screen readers never announce, a submit button that does nothing visible for three seconds, and no recovery when the request fails. This skill fixes all of that on real forms in the repo.
A form is done when it is accessible, validated on both sides, gives feedback for every state, and recovers from failure. Compile-clean is not done.
Before any browser interaction, read protocol-browser-anti-stall and apply it.
Inventory: signup uses raw
<form>+ inlineif (!email); API validates with zod. Structure:htmlForlabels;autocomplete="email";aria-invalid+ summary. Parity: share the zod schema; validate on blur/submit; map "email taken" to the field. States: submit disables +aria-busy; values preserved on 500; dirty-nav warn.
enhance-web-ux; WCAG sweep → audit-accessibilitycat package.json | grep -iE "react-hook-form|formik|@tanstack/react-form|final-form|zod|yup|valibot|superstruct"
rg -n "<form|onSubmit|useForm|handleSubmit" -g "*.{tsx,jsx,vue,svelte}" -l
Record: form library (or native), validation/schema library, UI/component library, and the list of forms to enhance (auth, checkout, settings, contact, search, etc.). If there are no forms, bow out.
Follow /research: Context7 for the detected form/validation library's current API;
Firecrawl for current form UX/a11y guidance dated to now. Prioritize forms by traffic and
risk (auth, payment, destructive actions first).
For each form, verify/fix:
<label htmlFor> or aria-label; placeholder
is not a label.autocomplete — type="email|tel|url|number", inputmode,
autocomplete="email|current-password|cc-number|..." for autofill.<fieldset> + <legend> (radio groups, address blocks).required / aria-required.aria-describedby; invalid fields get
aria-invalid="true"; a form-level error summary with links to fields on submit failure.rg -n "placeholder=" -g "*.{tsx,jsx}" # placeholders masquerading as labels?
rg -n "aria-describedby|aria-invalid|htmlFor|aria-label" -g "*.{tsx,jsx}" -c
Wire the full state machine for each form and submit:
| State | Required behavior |
|---|---|
| Idle | Clean, submit enabled/disabled per validity policy |
| Validating | Inline field feedback (see Phase 3 timing) |
| Submitting | Submit shows spinner/label swap + disabled + aria-busy; prevent double-submit |
| Success | Confirmation (toast/inline/redirect); reset or lock as appropriate |
| Error | Preserve entered values; surface the failure; keep the user's place; retry path |
| Empty/optional | Sensible defaults; empty state for dependent selects |
Also handle:
design-motion conventions
(reduced-motion safe). Don't animate layout in a way that shifts fields.console. Confirm screen-reader names via the accessibility snapshot.
Screenshots to .playwright-mcp/.## Forms Enhancement — report
**Stack:** form=[..] · validation=[..] · UI=[..]
**Forms upgraded:** [list]
**Structure:** labels/types/autocomplete/fieldsets fixed on [N] forms
**Validation:** shared schema SSOT · client↔server parity · blur+submit timing
**States:** submitting/success/error/multi-step/unsaved-guard wired
**A11y:** error summary + aria-describedby/aria-invalid + focus management (evidence)
**Verification:** build ✓ · console clean ✓ · flows walked (screenshots [paths])
audit-accessibility — deep WCAG audit (run to verify the a11y work)audit-ux — form usability heuristics, microcopy, cognitive loadaudit-fe-api — validate the submit request/response contract against the backendbackend-error-handling — server-side validation + structured error responsesdesign-motion — reduced-motion-safe micro-feedback for error/successenhance-web-ux — broader page/flow UX beyond the form itself