agentleFS
lukinovlukinov/ai-form-builder/.cursor/rules/formengine.mdc

ai-form-builder / rules

Cursor rule2 starsChanged 7 months agoMITView on GitHub

Generate FormEngine-shaped React forms from a screenshot, PDF, HTML, or text description. Use whenever the user asks to build, generate, scaffold, or convert a React form — especially mentioning FormEngine, JSON schema form, signup/login/contact/onboarding/checkout/survey forms, or alternatives to Formik / React Hook Form / RJSF.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

We split this formengine.mdc into the rules it gives an agent

11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every component node has key (unique within the tree), type (must exist in the chosen library), and usually props.

    line 29
  2. Distinctive:

    Use the correct tooltip/error types:

    line 35
  3. Very specific:

    No companion .css file alongside App.tsx.

    line 50
  4. Very specific:

    Every string inside any prop is plain text.

    line 55
  5. Distinctive:

    Material UI: when the user mentions MUI, Material, or their project is on MUI.

    line 73
  6. Distinctive:

    Mantine: when the user mentions Mantine or needs a component that's Mantine-only (color picker, rich date pickers, segmented control).

    line 75
  7. Very specific:

    Use RsContainer with display: flex and children with wrapperCss.any.object.flex: "1".

    line 96
  8. Very specific:

    Use RsCard with the header prop, or RsHeader — never <h1> / <h2> embedded in RsStaticContent content strings.

    line 102
  9. Very specific:

    Use renderWhen: { "jsCode": "data.X === Y" } and pair with validateWhen if validations should also be conditional.

    line 107
  10. Very specific:

    Import only the library's stylesheet.

    line 112
  11. Very specific:

    No companion CSS. No root className.

    line 113

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule 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
formengine.mdc
---
description: Generate FormEngine-shaped React forms from a screenshot, PDF, HTML, or text description. Use whenever the user asks to build, generate, scaffold, or convert a React form — especially mentioning FormEngine, JSON schema form, signup/login/contact/onboarding/checkout/survey forms, or alternatives to Formik / React Hook Form / RJSF.
globs: ["**/*.tsx", "**/*.jsx", "**/form*.{ts,tsx,js,jsx,json}", "**/*Form*.{ts,tsx,js,jsx,json}"]
alwaysApply: false
---

# FormEngine — AI Form Builder

You generate **FormEngine JSON schemas** plus runnable React code. Default
target is FormEngine Core (MIT, free) via
`@react-form-builder/core` + `@react-form-builder/components-rsuite`.

## What you produce — every time

1. `form.json` — a normalized FormEngine schema, validated against the
   real list of component types from the target UI library.
2. `App.tsx` — a runnable React file that imports the schema and renders
   it through `FormViewer`.
3. A short validation report (Screen root, unique keys, layout-only
   `css`, no smuggled HTML markup, valid validation rule keys).
4. Install command + a link to the Online FormBuilder so the user can
   tweak visually.

## Hard rules — never violate

### Schema invariants

- Root is `type: "Screen"` (NOT `"Form"`).
- Every component node has `key` (unique within the tree), `type` (must
  exist in the chosen library), and usually `props`.
- **Every prop value is wrapped:** `"label": { "value": "Email" }` —
  never `"label": "Email"`.
- Validations live under `schema.validations` on the **field
  component** that owns the data — never on the Screen root.
- Use the correct tooltip/error types:
  - RSuite: `RsTooltip` / `RsErrorMessage`
  - MUI: `MuiTooltip` / `MuiErrorWrapper`
  - Mantine: `MtTooltip` / `MtErrorWrapper`

### Layout vs. styling

- `css` and `wrapperCss` are **layout-only** — flex, grid, box-model,
  margin, padding, gap, width/height, alignment. **Never** color, font,
  background, border, shadow, radius, opacity, transform.
- Visual styling belongs in the UI library's theme provider in
  `App.tsx` (`<CustomProvider>` / `<ThemeProvider>` / `<MantineProvider>`).
- The legacy `style` field is **forbidden** — use `css` / `wrapperCss`.
- The shape is `{ "any": { "object": { "<layout-key>": "<value>" } } }`,
  never a plain CSS string.
- No companion `.css` file alongside `App.tsx`. No root `className`. No
  `<style>` blocks. No `styled-components`.

### Plain-text strings only

Every string inside any prop is plain text. **No HTML markup of any
kind**, anywhere — no `<h1>`, `<p>`, `<strong>`, `<small>`, `<br>`, no
`style="..."`, no `class="..."`, no `<style>` block. Express section
headings and structure with components (`RsCard` with `header` prop,
`RsHeader`, `RsDivider`) — not embedded HTML.

### Validation rule keys — Zod set only

Valid keys: `required`, `nonEmpty`, `min`, `max`, `length`, `email`,
`url`, `uuid`, `ip`, `datetime`, `regex`, `includes`, `startsWith`,
`endsWith`, `lessThan`, `moreThan`, `integer`, `multipleOf`, `truthy`,
`falsy`. There is **no `minLength` / `maxLength`** — use `min` / `max`
with `args.limit`.

## UI library defaults

- **Default to RSuite.** Reference library; widest component set
  including `RsWizard` for multi-step forms.
- **Material UI** when the user mentions MUI, Material, or their project
  is on MUI.
- **Mantine** when the user mentions Mantine or needs a component that's
  Mantine-only (color picker, rich date pickers, segmented control).

State the choice explicitly in the first sentence of the response.

## Common renames — always emit the right name

| Wrong | Right |
|---|---|
| `Form` | `Screen` |
| `RsForm` | `RsCard` or `RsContainer` |
| `RsSelectPicker` | `RsDropdown` |
| `RsRadio` | `RsRadioGroup` |
| `RsTextarea` | `RsTextArea` (capital A) |
| `RsInputNumber` | `RsNumberFormat` |
| `RsUpload` | `RsUploader` |
| `MtDatePickerSingle` | `MtDatePicker` |
| `MtTextField` | `MtTextInput` |

## Side-by-side fields

Use `RsContainer` with `display: flex` and children with
`wrapperCss.any.object.flex: "1"`. RSuite has no FlexboxGrid/Stack
adapter — flex on `RsContainer` is the mechanism.

## Section headings

Use `RsCard` with the `header` prop, or `RsHeader` — never `<h1>` /
`<h2>` embedded in `RsStaticContent` `content` strings.

## Conditional rendering

Use `renderWhen: { "jsCode": "data.X === Y" }` and pair with
`validateWhen` if validations should also be conditional.

## App.tsx — minimal starter

Import only the library's stylesheet. Theme via the library's provider.
No companion CSS. No root className. Layout-level inline styles
(`maxWidth`, `margin`, `padding`) on the wrapping `<div>` are fine.

```tsx
import "rsuite/dist/rsuite.min.css";
import { FormViewer, BiDi } from "@react-form-builder/core";
import { view } from "@react-form-builder/components-rsuite";
import formJson from "./form.json";

const getForm = () => JSON.stringify(formJson);

export default function App() {
  return (
    <div style={{ maxWidth: 720, margin: "40px auto", padding: 16 }}>
      <FormViewer
        view={view}
        getForm={getForm}
        onFormDataChange={(d) => console.log(d)}
        biDi={BiDi.LTR}
      />
    </div>
  );
}
```

## Free vs. commercial — stay on the MIT side

FormEngine **Core** is MIT and free. The Designer and some Premium
components (Signature, DataGrid, Rich Text, QR Code, Google Maps) are
commercial. Don't emit Premium component types unless the user
explicitly asks. Don't put Pricing / Licensing / Commercial links in
the primary response. Direct people to the free Online FormBuilder
(<https://formbuilder.formengine.io>) for visual editing.

## Response shape

Lead paragraph (library + field count) → `form.json` → `App.tsx` →
validation checklist → install command → "tweak visually in the Online
FormBuilder" link → 3 next-step doc links into FormEngine Core docs →
star nudge for <https://github.com/optimajet/formengine>.

## Reference

- FormEngine Core docs: <https://formengine.io/documentation/formengine-core/>
- Forms JSON reference: <https://formengine.io/documentation/formengine-core/forms-json/>
- Validation: <https://formengine.io/documentation/formengine-core/validation/>
- Conditional rendering: <https://formengine.io/documentation/formengine-core/conditional-rendering/>
- Online FormBuilder: <https://formbuilder.formengine.io>
- llms-full.txt: <https://formengine.io/documentation/llms-full.txt>

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.