| name | form-system |
| description | Enforces Head Shakers form system conventions when creating or modifying forms using the custom TanStack Form integration. This skill covers useAppForm hook usage, field components, focus management, validation patterns, and accessibility requirements. |
Form System Skill
Purpose
This skill enforces the Head Shakers form system conventions automatically during form development. It ensures consistent patterns for form hooks, field components, focus management, validation, server action integration, and accessibility.
Activation
This skill activates when:
- Creating forms with
useAppFormhook - Using field components (
TextField,TextareaField,SelectField,SwitchField,CheckboxField,ComboboxField,TagField) - Implementing focus management with
withFocusManagement - Setting up form validation with Zod schemas
- Creating custom form dialogs or form-based features
- Using
form.AppFieldfor field rendering - Using
form.SubmitButtonorform.AppFormwrappers - Using
useStorefrom@tanstack/react-formfor form value access - Using
formOptionsfrom@tanstack/form-corefor reusable form configurations - Implementing field listeners or programmatic field operations
- Integrating forms with
useServerActionhook
Workflow
- Detect form work (imports from
@/components/ui/formoruseAppForm) - Load
references/Form-System-Conventions.md - Generate/modify code following all conventions
- Scan for violations of form patterns
- Auto-fix all violations (no permission needed)
- Report fixes applied
Key Patterns
Form Setup
- Use
useAppFormhook from@/components/ui/form - Wrap form components with
withFocusManagementHOC - Configure validation with
validators: { onSubmit: zodSchema } - Use
revalidateLogicfor validation timing - Handle invalid submissions with
onSubmitInvalidandfocusFirstError - Always set
canSubmitWhenInvalid: true
Field Rendering
- Use
form.AppFieldwith field components (TextField, etc.) - Each field supports
label,description,isRequired,focusRef, andtestIdprops - Use field
listenersfor side effects (onChange, onBlur)
Form Submission
- Wrap
form.handleSubmit()in event handler withe.preventDefault()ande.stopPropagation() - Integrate with
useServerActionhook for server actions - Use
form.SubmitButtonwrapped inform.AppFormfor automatic loading state
Accessing Form Values
- Use
useStorefrom@tanstack/react-formfor reactive access - Access via
useStore(form.store, (state) => state.values.fieldName) - Never access form values directly during render
Programmatic Operations
- Use
form.setFieldValue()to update field values - Use
form.validateField()to trigger validation - Use field listeners for dependent field updates
Server Action Options
toastMessagesfor loading/success/error toastsisDisableToast: truefor background operationsonSuccesscallback for post-submission logic
References
references/Form-System-Conventions.md- Complete form system conventions