forms — Claude Code rule: forms and setup
This rule standardizes form structure, input groups, option sets, and validation states. Use it when building interfaces with several kinds of controls.
LicenseRef-Proprietary ★ 7,523 updated 2026-10-29
.claude/rules/forms.mdWhat forms does
The rule organizes forms with FieldGroup and Field, while related controls go inside FieldSet with FieldLegend. It maps common needs to specific components: text fields use Input, predefined choices use Select, searchable choices use Combobox, and multi-line text uses Textarea. Sets with 2–7 choices use ToggleGroup.
An InputGroup must contain InputGroupInput or InputGroupTextarea. A button placed in a field belongs in InputGroupAddon, rather than being positioned beside a raw input. Validation and disabled styling use two layers: data-invalid with aria-invalid, or data-disabled with disabled. Leaving out one side breaks the intended state styling.
What it helps with
- structure a form with
FieldGroupandField - pick controls for search, selection, or OTP input
- replace active button lists with
ToggleGroup - place an action button inside an input group
- mark invalid and disabled controls consistently
Example prompts for the agent
- Apply the
formsrule and build a login form withFieldGroupandField. - Replace these three stateful buttons with a
ToggleGroup. - Review the form states and add
data-invalidwitharia-invalidfor errors, thendata-disabledwithdisabledfor locked controls.
How to install forms
Manually: put the files in place
.claude/rules/forms.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/forms.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/forms.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/forms.mdManually: put the files in place
.clinerules/forms.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about forms
How do I install forms in Claude Code?
Place the rule file at .claude/rules/forms.md.
What does the forms rule do?
It defines form structure, maps input needs to UI components, and sets patterns for option groups, input actions, validation, and disabled states.
How should an invalid field be marked?
Put data-invalid on Field and aria-invalid on its control. Disabled fields use data-disabled together with disabled.