agentleFS
AkaraChenAkaraChen/aghub/.agents/skills/project-form-patterns/SKILL.md

project-form-patterns

Skill271 starsChanged 3 months agoMITView on GitHub

Form implementation guidance for the aghub desktop app. Use when building or refactoring forms in `crates/desktop/src`, especially HeroUI v3 + React forms, RHF integration, validation, custom editors, and error presentation. Triggers: MCP forms, settings dialogs, create/edit panels, `TextField`, `FieldError`, `Select`, `react-hook-form`, key-value editors, validation behavior.

The file

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. About 0 are common, 14 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow these rules when building forms in this project.

    line 8
  2. Distinctive:

    Check the official docs first, not memory and not bundled/local docs, when form behavior is in question.

    line 12
  3. Distinctive:

    Use local skill docs only as a convenience after confirming the official API.

    line 18
  4. Very specific:

    Prefer react-hook-form for non-trivial forms.

    line 22
  5. Very specific:

    Use Controller for HeroUI Select and any custom controlled widgets.

    line 23
  6. Distinctive:

    Keep one form state. Do not create a second derived validation state unless there is a concrete need the form library cannot express.

    line 24
  7. Very specific:

    When RHF controls validation, set HeroUI form fields to validationBehavior="aria".

    line 28
  8. Distinctive:

    Do not rely on HeroUI/native validation defaults together with RHF.

    line 29
  9. Very specific:

    Do not invent unsupported props.

    line 37
  10. Distinctive:

    Keep the official anatomy:

    line 38
  11. Very specific:

    Use ErrorMessage for collection-style or custom editors that are not true form fields, including key/value editors, tag selectors, and …

    line 49
  12. Distinctive:

    Do not inject per-row error UI into tight horizontal layouts unless the design explicitly calls for it.

    line 56
  13. Distinctive:

    Keep row layout simple:

    line 60
  14. Distinctive:

    no extra wrappers that change flex behavior unless necessary

    line 63
  15. Distinctive:

    Prefer aggregate error text below the whole editor over inline row errors.

    line 64
  16. Distinctive:

    If you must show row-level issues, redesign the layout first.

    line 66
  17. Very specific:

    Prefer onPress for HeroUI buttons.

    line 70
  18. Very specific:

    Use type="button" for non-submit buttons inside forms.

    line 71
  19. Very specific:

    After form changes, run bun run build in crates/desktop when possible and separate unrelated existing build failures from the changes you …

    line 73
  20. Very specific:

    Do not mix RHF validation with a parallel validationErrors state for the same fields.

    line 77
  21. Distinctive:

    Do not depend on HeroUI default native validation when you expect RHF errors to drive the UI.

    line 78
  22. Distinctive:

    Do not push validation messages into each key/value row unless you intentionally redesign that editor.

    line 79
  23. Distinctive:

    Do not trust remembered HeroUI APIs for forms without checking the official site first.

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

aghub Form Patterns

Follow these rules when building forms in this project.

Source of Truth

  • Check the official docs first, not memory and not bundled/local docs, when form behavior is in question.
  • For HeroUI, prefer the official site:
    • https://v3.heroui.com/docs/react/components/form
    • https://v3.heroui.com/docs/react/components/text-field
    • https://v3.heroui.com/docs/react/components/field-error
    • https://v3.heroui.com/docs/react/components/select
  • Use local skill docs only as a convenience after confirming the official API.

Default Stack

  • Prefer react-hook-form for non-trivial forms.
  • Use Controller for HeroUI Select and any custom controlled widgets.
  • Keep one form state. Do not create a second derived validation state unless there is a concrete need the form library cannot express.

Validation Behavior

  • When RHF controls validation, set HeroUI form fields to validationBehavior="aria".
  • Do not rely on HeroUI/native validation defaults together with RHF. Native validation can steal focus and submission flow while bypassing the error UI you expect from RHF.
  • Let RHF own validation rules and submission blocking.

Error Rendering

  • For HeroUI text fields, use:
    • isInvalid={Boolean(fieldState.error)}
    • Conditionally render <FieldError>{fieldState.error.message}</FieldError> inside the same TextField.
  • Do not invent unsupported props. In particular, do not assume TextField supports an errorMessage prop.
  • Keep the official anatomy:
<TextField isInvalid={Boolean(fieldState.error)} validationBehavior="aria">
	<Label>Name</Label>
	<Input {...inputProps} />
	{fieldState.error && <FieldError>{fieldState.error.message}</FieldError>}
</TextField>
  • For non-form or custom composite controls, prefer HeroUI ErrorMessage instead of hand-rolled error text.
  • Use ErrorMessage for collection-style or custom editors that are not true form fields, including key/value editors, tag selectors, and similar composite controls.

Custom Editors

  • Custom widgets like AgentSelector, EnvEditor, HttpHeaderEditor, and KeyPairEditor should still be registered in RHF through Controller.
  • For custom editors that manage arrays or compound values, compute validation from the current field value and surface one aggregated error below the editor when possible.
  • For that aggregated error, prefer HeroUI ErrorMessage.
  • Do not inject per-row error UI into tight horizontal layouts unless the design explicitly calls for it.

Key/Value Editors

  • Keep row layout simple:
    • two inputs
    • one delete button
    • no extra wrappers that change flex behavior unless necessary
  • Prefer aggregate error text below the whole editor over inline row errors. This avoids breaking spacing and alignment.
  • Implement that aggregate error with HeroUI ErrorMessage, not a custom <p> block.
  • If you must show row-level issues, redesign the layout first; do not bolt error blocks into a row that was designed as a single-line control.

Practical Rules

  • Prefer onPress for HeroUI buttons.
  • Use type="button" for non-submit buttons inside forms.
  • Preserve existing visual patterns in this repo; do not restyle forms while adding validation.
  • After form changes, run bun run build in crates/desktop when possible and separate unrelated existing build failures from the changes you made.

Anti-Patterns

  • Do not mix RHF validation with a parallel validationErrors state for the same fields.
  • Do not depend on HeroUI default native validation when you expect RHF errors to drive the UI.
  • Do not push validation messages into each key/value row unless you intentionally redesign that editor.
  • Do not trust remembered HeroUI APIs for forms without checking the official site first.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.