Windsurf rules for React with TypeScript: typed function components, correct form submission handling, state ownership by kind, and measured memoization.
.devin/rules/react-with-windsurf-ai.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
Apply these rules to React components.
## Component guidelines
- Use function components with hooks and TypeScript props.
- Split a component when it has more than one responsibility or when logic is reused; move reusable stateful logic into custom hooks.
## Code style
```tsx
import { useState, type FormEvent } from 'react';
interface NameFormProps {
title: string;
onSubmit: (data: { name: string }) => void;
}
export function NameForm({ title, onSubmit }: NameFormProps) {
const [name, setName] = useState('');
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
onSubmit({ name: name.trim() });
}
return (
<form onSubmit={handleSubmit}>
<h2>{title}</h2>
<label>
Name
<input value={name} onChange={(e) => setName(e.target.value)} required />
</label>
<button type="submit">Save</button>
</form>
);
}
```
- Type callback props with the data they receive (`{ name: string }`), not with an unrelated DOM type such as `FormData`.
- Call `event.preventDefault()` in submit handlers that handle the data in JavaScript; otherwise the browser reloads the page.
- Plain function declarations are fine for components; `React.FC` is optional.
## State management
- `useState` for local component state; `useReducer` for related values updated through named actions.
- Server state (fetched data) through a data library such as TanStack Query or the framework's loaders.
- Global client state (Zustand or context) only when many distant components share it.
## Performance
- Measure with React DevTools Profiler before optimizing.
- Use `useMemo`/`useCallback`/`React.memo` when profiling shows a cost or a memoized child needs stable props; if React Compiler is enabled, rely on it instead.
- Virtualize long lists and lazy-load heavy components.
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 .
A Windsurf-generated form component passes { value } to a prop typed (data: FormData) => void and the page reloads on submit.
Fix src/components/NameForm.tsx following the React rule and keep the parent API simple.
A component whose onSubmit prop is typed with the submitted data shape, a submit handler that calls preventDefault, a labelled input and submit button, no unnecessary useCallback, and the parent updated to the new prop type.
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/react-with-windsurf-ai.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: "**/*"
---
Apply these rules to React components.
## Component guidelines
- Use function components with hooks and TypeScript props.
- Split a component when it has more than one responsibility or when logic is reused; move reusable stateful logic into custom hooks.
## Code style
```tsx
import { useState, type FormEvent } from 'react';
interface NameFormProps {
title: string;
onSubmit: (data: { name: string }) => void;
}
export function NameForm({ title, onSubmit }: NameFormProps) {
const [name, setName] = useState('');
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
onSubmit({ name: name.trim() });
}
return (
<form onSubmit={handleSubmit}>
<h2>{title}</h2>
<label>
Name
<input value={name} onChange={(e) => setName(e.target.value)} required />
</label>
<button type="submit">Save</button>
</form>
);
}
```
- Type callback props with the data they receive (`{ name: string }`), not with an unrelated DOM type such as `FormData`.
- Call `event.preventDefault()` in submit handlers that handle the data in JavaScript; otherwise the browser reloads the page.
- Plain function declarations are fine for components; `React.FC` is optional.
## State management
- `useState` for local component state; `useReducer` for related values updated through named actions.
- Server state (fetched data) through a data library such as TanStack Query or the framework's loaders.
- Global client state (Zustand or context) only when many distant components share it.
## Performance
- Measure with React DevTools Profiler before optimizing.
- Use `useMemo`/`useCallback`/`React.memo` when profiling shows a cost or a memoized child needs stable props; if React Compiler is enabled, rely on it instead.
- Virtualize long lists and lazy-load heavy components.
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.