5 react rules available
Five Claude rules match react; the React expert and Next.js expert rules are substantive, and the performance, mobile (React Native) and architecture rules are short. The file below is scoped to component files so Claude Code applies it only while it is editing UI code.
Claude Code loads persistent project instructions from CLAUDE.md files and from Markdown rules in .claude/rules/. Rules can be scoped to file paths with a paths frontmatter field, and CLAUDE.md can import other files with @path syntax. The rules in this directory are written as plain instruction prompts: in Claude Code, save them as CLAUDE.md or .claude/rules/ content; in Claude.ai or the Claude API, use the same text as project instructions or a system prompt instead.
.claude/rules/react.mdStarting point, not a tested configuration for your repository. Loaded when Claude Code works with files matching paths. Review the instructions, adapt the file paths and run your project's existing checks.
--- paths: - "**/*.tsx" - "**/*.jsx" --- # React instructions for Claude Code ## Focus for this project - Before adding memo, useMemo or useCallback, identify the re-render cause and state it. - Prefer moving state down or splitting components over memoization. - If the project uses React Native, do not use DOM elements or web-only APIs. ## React conventions - Write function components and custom hooks; call hooks only at the top level of components or other hooks. - Derive values during render instead of copying props into state, and do not use an effect only to transform data for rendering. - Check the react version in package.json: on React 19, function components receive ref as a regular prop and forwardRef is not needed for new components; on React 18 keep forwardRef. - In tests, query by role and accessible name with Testing Library rather than by class names or test IDs. ## Before you finish - Run the type checker (npx tsc --noEmit for TypeScript projects), the lint script and the component tests and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - You have shell access: run the checks yourself instead of asking the user to, unless a command needs credentials or would deploy.
Create your own Claude rules for React and share with the community.
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.
Imports with @path can nest up to four hops deep, according to the docs. Claude Code can read AGENTS.md as project instructions without extra configuration, but by default only when there is no CLAUDE.md in the working directory or above it. The docs list this behavior for version 2.1.277 and later and describe a setting (claude-md-and-agents-md) that loads both files. If you maintain AGENTS.md for other tools, you can also import it from CLAUDE.md with @AGENTS.md.
Documentation checked 2026-11-05: Claude Code docs: Manage Claude's memory
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Claude Code to fix a slow list and want it to measure before memoizing anything.
The OrderTable re-renders on every keystroke in an unrelated search box. Fix it.
An explanation of why OrderTable re-renders, a change that moves search state closer to the input or splits the component, memoization only where justified, and type-check/test output.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.