Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

react-hook-form

FreeNo executable scriptsNot checked

React Hook Form 7 forms and validation.

PyModelby PyModel★ 52 GitHub stars

About this skill

React Hook Form Best Practices

Comprehensive performance optimization guide for React Hook Form applications. Contains 45 rules across 8 categories, prioritized by impact to guide form development, automated refactoring, and code generation.

When to Apply

Reference these guidelines when:

  • Writing new forms with React Hook Form
  • Configuring useForm options (mode, defaultValues, validation)
  • Subscribing to form values with watch/useWatch
  • Integrating controlled UI components (MUI, shadcn, Ant Design)
  • Managing dynamic field arrays with useFieldArray
  • Reviewing forms for performance issues

Rule Categories by Priority

Priority Category Impact Prefix
1 Form Configuration CRITICAL formcfg-
2 Field Subscription CRITICAL sub-
3 Controlled Components HIGH ctrl-
4 Validation Patterns HIGH valid-
5 Field Arrays MEDIUM-HIGH array-
6 State Management MEDIUM formstate-
7 Integration Patterns MEDIUM integ-
8 Advanced Patterns LOW adv-

Quick Reference

1. Form Configuration (CRITICAL)

  • formcfg-validation-mode - Choose validation mode from UX and validation cost
  • formcfg-revalidate-mode - Choose post-submit revalidation deliberately
  • formcfg-default-values - Always provide defaultValues for form initialization
  • formcfg-async-default-values - Use async defaultValues for server data
  • formcfg-should-unregister - Choose shouldUnregister from submission semantics
  • formcfg-useeffect-dependency - Avoid useForm return object in useEffect dependencies

2. Field Subscription (CRITICAL)

  • sub-usewatch-over-watch - Use useWatch instead of watch for isolated re-renders
  • sub-watch-specific-fields - Watch specific fields instead of entire form
  • sub-usewatch-with-getvalues - Combine useWatch with getValues for timing safety
  • sub-deep-subscription - Subscribe deep in component tree where data is needed
  • sub-avoid-watch-in-render - Avoid calling watch() in render for one-time reads
  • sub-usewatch-default-value - Provide defaultValue to useWatch for initial render
  • sub-useformcontext-sparingly - Use useFormContext sparingly for deep nesting

3. Controlled Components (HIGH)

  • ctrl-usecontroller-isolation - Use useController for re-render isolation
  • ctrl-avoid-double-registration - Avoid double registration with useController
  • ctrl-controller-field-props - Wire Controller field props correctly for UI libraries
  • ctrl-single-usecontroller-per-component - Split controlled fields when isolation helps
  • ctrl-local-state-combination - Combine local state with useController for UI-only state

4. Validation Patterns (HIGH)

  • valid-resolver-caching - Define schema outside component for resolver caching
  • valid-dynamic-schema-factory - Use schema factory for dynamic validation
  • valid-error-message-strategy - Render field errors with ErrorMessage (7.88+) or optional chaining
  • valid-trigger-should-touch - Mark fields touched when triggering validation (7.87+)
  • valid-inline-vs-resolver - Prefer resolver over inline validation for complex rules
  • valid-delay-error - Use delayError to debounce rapid error display
  • valid-native-validation - Consider native validation for simple forms
  • valid-form-level-validate - Validate cross-fields with the form-level validate option (7.72+)

5. Field Arrays (MEDIUM-HIGH)

  • array-use-field-id-as-key - Use field.id as key in useFieldArray maps
  • array-complete-default-objects - Provide complete default objects for field array operations
  • array-separate-crud-operations - Separate sequential field array operations
  • array-unique-fieldarray-per-name - Use single useFieldArray instance per field name
  • array-virtualization-formprovider - Use FormProvider for virtualized field arrays

6. State Management (MEDIUM)

  • formstate-destructure-formstate - Destructure formState properties before render
  • formstate-useformstate-isolation - Use useFormState for isolated state subscriptions
  • formstate-getfieldstate-for-single-field - Use getFieldState and getErrors for single-field reads
  • formstate-subscribe-to-specific-fields - Subscribe to specific field names in useFormState
  • formstate-avoid-isvalid-with-onsubmit - Align submit gating with validation mode

7. Integration Patterns (MEDIUM)

  • integ-shadcn-form-import - Build shadcn fields with Controller and Field
  • integ-shadcn-select-wiring - Wire shadcn Select with onValueChange instead of spread
  • integ-mui-controller-pattern - Use Controller for Material-UI components
  • integ-value-transform - Transform values at Controller level for type coercion
  • integ-typed-submit-server-action - Submit with a typed handleSubmit result or Server Action (7.84+)

8. Advanced Patterns (LOW)

  • adv-formprovider-memo - Memoize FormProvider children only after profiling
  • `adv-devtools-perform
Full SKILL.md on GitHub

Install react-hook-form in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

references/adv-devtools-performance.mdreferences/adv-formprovider-memo.mdreferences/adv-opaque-types.mdreferences/adv-testing-wrapper.mdreferences/array-complete-default-objects.mdreferences/array-separate-crud-operations.mdreferences/array-unique-fieldarray-per-name.mdreferences/array-use-field-id-as-key.mdreferences/array-virtualization-formprovider.mdreferences/ctrl-avoid-double-registration.mdreferences/ctrl-controller-field-props.mdreferences/ctrl-local-state-combination.mdreferences/ctrl-single-usecontroller-per-component.mdreferences/ctrl-usecontroller-isolation.mdreferences/formcfg-async-default-values.mdreferences/formcfg-default-values.mdreferences/formcfg-revalidate-mode.mdreferences/formcfg-should-unregister.mdreferences/formcfg-useeffect-dependency.mdreferences/formcfg-validation-mode.mdreferences/formstate-avoid-isvalid-with-onsubmit.mdreferences/formstate-destructure-formstate.mdreferences/formstate-getfieldstate-for-single-field.mdreferences/formstate-subscribe-to-specific-fields.mdreferences/formstate-useformstate-isolation.mdreferences/integ-mui-controller-pattern.mdreferences/integ-shadcn-form-import.mdreferences/integ-shadcn-select-wiring.mdreferences/integ-typed-submit-server-action.mdreferences/integ-value-transform.mdreferences/sub-avoid-watch-in-render.mdreferences/sub-deep-subscription.mdreferences/sub-useformcontext-sparingly.mdreferences/sub-usewatch-default-value.mdreferences/sub-usewatch-over-watch.mdreferences/sub-usewatch-with-getvalues.mdreferences/sub-watch-specific-fields.mdreferences/valid-delay-error.mdreferences/valid-dynamic-schema-factory.mdreferences/valid-error-message-strategy.md

FAQ

What does the react-hook-form skill do?

React Hook Form 7 forms and validation.

How do I install the react-hook-form skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the react-hook-form skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare react-hook-form with