forms-architect
Architect-level form architecture — where form state lives, one validation schema shared by client and server, error mapping and focus behaviour, multi-step and draft persistence, submission idempotency, and the accessibility contract every field owes. Use when building or auditing forms.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- forms-architect
- license
- MIT
- metadata
- { "crusor-path": "website-architect/frontend-development-architect/forms-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "developer.mozilla.org/Forms; html.spec.whatwg.org/form-control-infrastructure; zod.dev", "crusor-triggers": "forms, form validation, form state, react hook form, zod schema, multi-step form, input validation, submit", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level form architecture — where form state lives, one validation schema shared by client and server, error mapping and focus behaviour, multi-step and draft persistence, submission idempotency, and the accessibility contract every field owes. Use when building or auditing forms.
- compatibility
- Framework-agnostic; schema validation (zod/valibot/yup)
03 SKILL.md 正文
Forms Architect
A form is a contract between a schema, a UI, and a server. Most form bugs are that contract being written three times in three places.
When to use
- Any form with more than two fields, validation, or a server round-trip.
- Forms that lose data, double-submit, or show errors in the wrong place.
- Multi-step flows, drafts, and wizards.
When NOT to use
- A single search box — plain input plus URL state is enough.
Decision 1 — One schema, two enforcers
- The validation schema (zod/valibot) is the single definition; the client uses it for UX, the server uses it for truth.
- Server is authoritative; client validation is a courtesy that never replaces it.
- Schema errors map to field paths the UI already knows — no string matching.
- Cross-field rules (password confirm, date ranges) live in the schema, not in handlers.
Decision 2 — State ownership
| State | Home |
|---|---|
| field values, dirty/touched | form library (react-hook-form / conform / native) |
| server errors | returned from submit, mapped into the same field errors |
| draft persistence | localStorage/session, versioned and expiring |
| URL-carried steps | route params for multi-step flows |
- Avoid a global store for form state; it outlives the form and leaks between records.
- Reset semantics are explicit: after success, after route change, after "start over".
Decision 3 — Errors are UI
- Validate on blur and on submit; re-validate on change only after the first error (no shouting while typing).
- Errors appear next to the field, are announced (
aria-live,aria-invalid,aria-describedby), and move focus to the first invalid field on submit. - One error message per field, in the user's language, actionable.
- Submit-level errors (network, 409 conflict) appear at the top with a link to the offending field.
Decision 4 — Submission
- Disable-and-label the submit button while in flight; never allow double submit.
- Idempotency key on create/charge operations; retries must be safe.
- Success, partial success, and failure are three distinct states with distinct UI.
- Unsaved-changes guard before navigation for long forms.
Decision 5 — Multi-step and drafts
- Each step validates its own slice; the whole form validates at the end.
- Progress is recoverable: refresh mid-flow returns to the same step.
- Back navigation never loses entered data.
- Drafts expire and are never silently merged across accounts.
Failure modes at scale
- Validation duplicated in the client and server, drifting until one accepts what the other rejects.
- Errors rendered as a toast only — the user cannot tell which field.
- Form state in a global store: opening the same form for another record shows the previous record's data.
- Double submission creating duplicate orders.
- Multi-step forms that lose everything on refresh.
Verification receipts
- Schema shared between client and server (one import, not two copies).
- Submit-invalid test: focus lands on the first error; message announced.
- Double-submit test: one request, disabled state visible.
- Refresh mid-flow: same step, same data.
- Server-error mapping test: 422 field errors land on the right fields.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.