wizard-workbench / rules
Cursor rule5 starsChanged 6 months agoMITView on GitHub
When writing React code, use this guide for React best practices and guidance
We split this jsx-and-tsx.mdc into the rules it gives an agent
10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Use ShadCN/ui for components.
- Very specific: line 31
Use clear, descriptive, consistent naming.
- Distinctive: line 37
Use proper React TypeScript types: MouseEventHandler<HTMLButtonElement>, ChangeEventHandler<HTMLInputElement>, ReactNode, React.Ref<T>, …
- Distinctive: line 38
When extending HTML elements or existing components, use ComponentProps to inherit their props: ComponentProps<'input'>, …
- Distinctive: line 44
When using server/database return types: Awaited<ReturnType<typeof serverFunction>>, wrap with NonNullable<> if guaranteed to exist.
- Distinctive: line 54
Use consistent naming: isSubmitting = false, isLoading{Action} = false, is{Action}ing{Entity} = false
- Distinctive: line 55
Always provide default values in function signature
- Distinctive: line 60
Use FormProvider for parent, useFormContext for nested components
- Distinctive: line 72
Use useTranslation with namespace and keyPrefix: const { t } = useTranslation('namespace', { keyPrefix: 'section' }).
- Distinctive: line 73
Use Trans component for interpolation with links/components.
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 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.
Files
---
description: When writing React code, use this guide for React best practices and guidance
globs: **/*.js,**/*.jsx,**/*.tsx
alwaysApply: false
---
# React guide
Act as a top-tier software engineer with extensive React ecosystem knowledge to build high-quality fullstack web applications.
## Before Writing Code
- Observe the project's relevant existing code.
- Conform to existing code style, patterns, and conventions unless directed otherwise. Note: these instructions count as "directed otherwise" unless the user explicitly overrides them.
## Principles
- Display/container component pattern
- Split your component into display components, which are pure functions that map props to JSX, and container components, which are (optional) stateful components that wrap one display component.
- Then compose them together in the parent or page/route component.
Constraints {
Be concise.
You're using React Router V7 (the successor to Remix).
Use ShadCN/ui for components. If a component is missing, install it.
Modularize by feature; one concern per file or component; prefer named exports.
This project uses TailwindCSS V4, so you can use things like container queries and child selectors.
}
NamingConstraints {
Use clear, descriptive, consistent naming.
Components should be postfixed with `Component`.
Props should be the component's name, postifxed with `ComponentProps`.
}
TypeConstraints {
Use proper React TypeScript types: MouseEventHandler<HTMLButtonElement>, ChangeEventHandler<HTMLInputElement>, ReactNode, React.Ref<T>, ComponentProps<'element'>, etc. Never use generic () => void or (event: any) => void.
When extending HTML elements or existing components, use ComponentProps to inherit their props: ComponentProps<'input'>, ComponentProps<'button'>, ComponentProps<typeof ExistingComponent>.
This project uses Prisma. If a prop comes from a database entity, use the entities type for it, e.g.:
- type UserMenuProps = Pick<UserAccount, 'id' | 'name' | 'email'> & {
onLogout: MouseEventHandler<HTMLInputElement>;
organizationName: Organization['name'];
}
When using server/database return types: Awaited<ReturnType<typeof serverFunction>>, wrap with NonNullable<> if guaranteed to exist.
}
FormConstraints {
For react-hook-form + Zod forms:
- Export schema types: export type Schema = z.infer<typeof schema>
- Export error types: export type SchemaErrors = FieldErrors<Schema>
- Optionally include intent field: intent: z.literal('actionName')
- Pass translation keys (not translated strings) in validation error messages
For loading/submission states:
- Use consistent naming: isSubmitting = false, isLoading{Action} = false, is{Action}ing{Entity} = false
- Always provide default values in function signature
- Disable forms with fieldset disabled={isSubmitting || isLoading} instead of individual disabled props
For form components:
- Accept errors?: SchemaErrors (always optional)
- Accept children?: ReactNode for composition
- Use FormProvider for parent, useFormContext for nested components
- Provide complete defaultValues object to useForm with all fields initialized
}
AccessibilityConstraints {
For interactive components, provide aria props with defaults:
- *AriaLabel props for screen readers (e.g., countryAriaLabel = 'Select country')
- *Placeholder props for empty states
- FormControl handles aria-describedby and aria-invalid automatically
}
InternationalizationConstraints {
Use useTranslation with namespace and keyPrefix: const { t } = useTranslation('namespace', { keyPrefix: 'section' });
Use Trans component for interpolation with links/components.
FormMessage components handle translation of error keys automatically.
}
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 3,978 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 repository5 other files it gives its agents.
- apps/basic-integration/rails/fizzy/AGENTS.mdAGENTS.md
- apps/basic-integration/swift/hackers-ios/AGENTS.mdAGENTS.md
- apps/basic-integration/rails/fizzy/.claude/CLAUDE.mdCLAUDE.md
- apps/basic-integration/react-router/saas-template/.cursor/rules/facades.mdcCursor rule
- apps/basic-integration/react-router/saas-template/.cursor/rules/js-and-ts.mdcCursor rule
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

