React + ViteRule
by DUOMReport
Rules for React single-page apps built with Vite: components, state, effects, and accessibility.
Developer toolsLicense: CC0-1.0Updated yesterdayrule/react
Install
Run in your project folder (DuoM CLI: risk check, then write; undo with npx duom@1 undo)
npx duom@1 add rule/react --client claude-code
Writes to CLAUDE.md in your project (where Claude Code reads it). If the project has an AGENTS.md but no CLAUDE.md, DuoM creates CLAUDE.md starting with @AGENTS.md so Claude Code keeps reading it. Only the marked block is added; the rest of the file is left alone, and remove takes out only that block.
Manual: paste into CLAUDE.md
CLAUDE.md
<!-- duom:rule/react --> ## React + Vite - Function components and hooks only. One component per file once it is reused or passes ~150 lines. - Derive values during render instead of copying props into state. Reach for useEffect only to sync with something outside React. - Keep state as close as possible to where it is used; lift it only when two siblings need it. - Lists need stable keys from the data, never the array index when items can move. - Use semantic HTML (button, label, nav) and keep everything usable by keyboard. - Env vars exposed to the app must start with VITE_ and are public. Keep secrets on a server. - Run the type check and the tests before calling a change done. <!-- /duom:rule/react -->
The rule
React + Vite
- Function components and hooks only. One component per file once it is reused or passes ~150 lines.
- Derive values during render instead of copying props into state. Reach for useEffect only to sync with something outside React.
- Keep state as close as possible to where it is used; lift it only when two siblings need it.
- Lists need stable keys from the data, never the array index when items can move.
- Use semantic HTML (button, label, nav) and keep everything usable by keyboard.
- Env vars exposed to the app must start with VITE_ and are public. Keep secrets on a server.
- Run the type check and the tests before calling a change done.