React Principles logoReact Principles
Scaffoldingv0.2.0

/reactprinciples-form

Scaffold a React Hook Form + Zod form following React Principles form-validation recipe. Invoke when the user says "create a form", "scaffold a validation form", or mentions React Hook Form and Zod. Generates a Zod schema (or reuses an existing one with .omit/.pick/.extend), a typed form component with zodResolver, field error display, and integration with a React Query mutation. Handles both create and edit form variants.

Allowed tools:ReadWriteGlobWebFetch

Install

$npx skills add sindev08/react-principles-skills

Installs all skills from the repo. To copy only this skill manually, use the button below.

open_in_newView on GitHub

React Principles — Form Scaffold

You scaffold a React Hook Form + Zod form following the Form Validation with Zod recipe.

Step 0 — Load the live recipe (required)

Do this before anything else. The cookbook is the single source of truth and changes over time — never scaffold from memory or from the fallback summary below while the live recipe is reachable.

  1. If the reactprinciples MCP server is available, call its get_recipe tool with slug form-validation.
  2. Otherwise fetch: https://www.reactprinciples.dev/cookbook/form-validation/llms.txt

The fetched recipe contains the principle, rules, canonical pattern code, and implementation examples — treat its rules as requirements, not suggestions. If both sources are unreachable (offline), use the fallback summary at the bottom of this file and tell the user you are working from a potentially outdated summary.

When to invoke

Inputs needed

Ask the user for:

  1. Form purpose — create, edit, or both
  2. Resource name — e.g., User, Product. Used for component naming
  3. Fields — list of field names with their Zod types (e.g., name: string min 1, email: string email)
  4. Mutation hook — which React Query mutation will the form call (e.g., useCreateUser, useUpdateUser)
  5. Locationsrc/features/<feature>/components/

What to read first

Read existing form components and schemas in the user's project:

src/features/examples/components/UserForm.tsx       # create form
src/features/examples/components/UserEditForm.tsx   # edit form with pre-populated values
src/shared/utils/validators.ts                       # shared Zod schemas
src/features/examples/hooks/useCreateUser.ts         # mutation hook pattern

Check if there's already a shared schema in src/shared/utils/validators.ts for this resource. If yes, reuse it via .omit() / .pick() / .extend() rather than duplicating.

How to scaffold

Derive the schema and the form component from the pattern and implementation code in the recipe you fetched in Step 0, adapted to the user's resource and fields:

After generating

Tell the user:

  1. The file path created
  2. Whether they need to add the schema to src/shared/utils/validators.ts
  3. Whether the mutation hook (useCreate<Resource>, useUpdate<Resource>) exists — if not, suggest using reactprinciples-query skill
  4. Import path: import { <Resource>Form } from "@/features/<feature>/components/<Resource>Form"

What you should NOT do

Fallback summary (only if Step 0 fails)

May be outdated — the live recipe always wins.

Reference

See Form Validation with Zod recipe and existing forms in src/features/examples/components/.