Generate React components that stay fast and accessible: typed props, memoization only where it pays (or React Compiler), naming conventions, error boundaries and real behaviour tests.
.devin/rules/windsurf-react-component-optimization.md. Downloaded files need to be placed in that repository path.--- trigger: glob globs: "**/*" --- When generating React components: 1. Write function components with hooks. 2. Type props with a TypeScript interface or type; extend native element props for wrappers (`ComponentProps<'button'>`) so ARIA and event props pass through. 3. Memoize deliberately: - If the project uses React Compiler, do not add `useMemo`, `useCallback` or `React.memo` by default; the compiler memoizes automatically. - Otherwise add them only for a measured slow render, an expensive calculation, or a value passed to a memoized child or hook dependency list. Explain the reason in a short comment. - First try cheaper fixes: move state down to the component that uses it, pass children as props, and avoid creating new objects in props of memoized children. 4. Naming: PascalCase components in matching file names, `useX` hooks, `onX` callback props, `handleX` handlers. 5. Props: required props for data the component cannot work without, optional props with defaults, union types for variants instead of several Booleans. 6. Accessibility: semantic elements first (`button`, `nav`, `label`), accessible names for icon-only controls, keyboard support for custom widgets, `useId` for id relationships. 7. Error boundaries: wrap independent widgets or route segments with an error boundary (`react-error-boundary` or the framework's error file) that renders a fallback with a retry. 8. Tests: generate real tests, not empty stubs. Cover rendering with required props, the main interaction and an edge case, using React Testing Library queries by role or label.
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.
Windsurf
frontend
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Windsurf keeps wrapping every handler in useCallback and every component in React.memo in a project that already enables React Compiler, and generates empty test files.
Generate a ProductCard component (title, price, onAddToCart, optional badge) following the component optimization rule. React Compiler is enabled.
A typed ProductCard without manual memoization (compiler enabled), semantic markup with an accessible add-to-cart button, a badge variant union, and a test file that renders the card, clicks the button by role and asserts onAddToCart was called with the product id.
Windsurf's rules documentation (docs.windsurf.com/windsurf/cascade/memories) now redirects to Devin documentation, which describes rules for the Devin Local agent in Devin Desktop. Current rules live in .devin/rules/*.md with a trigger setting, and the legacy Windsurf files (.windsurf/rules/*.md, .windsurf/global_rules.md and .windsurfrules) are still imported by default. AGENTS.md files are read as always-on rules.
.devin/rules/windsurf-react-component-optimization.mdStarting point, not a tested configuration for your repository. Applied when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
--- trigger: glob globs: "**/*" --- When generating React components: 1. Write function components with hooks. 2. Type props with a TypeScript interface or type; extend native element props for wrappers (`ComponentProps<'button'>`) so ARIA and event props pass through. 3. Memoize deliberately: - If the project uses React Compiler, do not add `useMemo`, `useCallback` or `React.memo` by default; the compiler memoizes automatically. - Otherwise add them only for a measured slow render, an expensive calculation, or a value passed to a memoized child or hook dependency list. Explain the reason in a short comment. - First try cheaper fixes: move state down to the component that uses it, pass children as props, and avoid creating new objects in props of memoized children. 4. Naming: PascalCase components in matching file names, `useX` hooks, `onX` callback props, `handleX` handlers. 5. Props: required props for data the component cannot work without, optional props with defaults, union types for variants instead of several Booleans. 6. Accessibility: semantic elements first (`button`, `nav`, `label`), accessible names for icon-only controls, keyboard support for custom widgets, `useId` for id relationships. 7. Error boundaries: wrap independent widgets or route segments with an error boundary (`react-error-boundary` or the framework's error file) that renders a fallback with a retry. 8. Tests: generate real tests, not empty stubs. Cover rendering with required props, the main interaction and an edge case, using React Testing Library queries by role or label.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The docs recommend keeping rules short and specific. The current docs say AGENTS.md, AGENTS.local.md and AGENT.md are read as always-on rules, including files in subdirectories. Use .devin/rules/ when you need glob, model-decision or manual triggers.
Documentation checked 2026-11-05: Devin docs: Local customizations (redirect target of Windsurf memories docs)Windsurf docs: Cascade memories (redirects)
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.