react

Coding rules for React components, which are user-interface building blocks used in React and similar frameworks. They set limits on component structure, hooks, state management, and data fetching.

In plain words
What is it for?
Use them when editing React components, choosing how to manage state or fetch data, and deciding whether a hook or new component is justified.
Why use it?
They help keep a small UI change focused and consistent with the existing code instead of introducing unnecessary components, libraries, or state patterns.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/inboxpraveen/minimize-cursor-cost/react
Clone the repo
git clone --depth 1 https://github.com/inboxpraveen/Minimize-Cursor-Cost

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 471 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00471
Opus 5 $0.00000 $0.00235
Sonnet 5 $0.00000 $0.00094
Haiku 4.5 $0.00000 $0.00047

Measured 2d ago against content hash 0136e14ba54c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

react scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

lean-cursor/.cursor/rules/react.mdc · 50 lines

What it actually says

React Rules

Output Format

  • Single component change → show only the changed JSX section + affected hooks.
  • Use // ... rest of component to skip unchanged JSX.
  • Don't reprint the import block unless adding new imports.

Components

  • Don't extract a new component unless asked or unless the same JSX repeats 3+ times.
  • Don't switch a function component to a class component (or vice versa).
  • Don't rename props, state variables, or event handlers.

Hooks

  • Don't add useMemo / useCallback unless the task is performance.
  • Don't introduce useReducer if useState is already in use.
  • Don't add useEffect to "be safe" — only when a side-effect is required.
  • Don't change the dependency array of an existing useEffect unless the bug is in there.

State

  • Match existing state library: Redux / Zustand / Jotai / Context. Never introduce a second.
  • Don't lift state without asking.
  • Don't add a new context provider unless the data is genuinely tree-wide.

Data Fetching

  • Match existing pattern: fetch / axios / TanStack Query / SWR / RTK Query.
  • Don't introduce a query library if the codebase uses raw fetch.
  • Don't add loading/error states beyond what siblings have.

Styling

  • Match existing system: CSS Modules / Tailwind / styled-components / Emotion / vanilla CSS.
  • Don't switch styling systems within a file.
  • Don't add className props for styles that don't exist yet.

Forms

  • Match existing form library: React Hook Form / Formik / native. Don't switch.
  • Don't add validation libraries (zod, yup) if the project doesn't use one.

Never

  • Don't add key props on non-list elements.
  • Don't add React.memo speculatively.
  • Don't add forwardRef unless a parent actually passes a ref.
  • Don't add inline onClick={() => handler(arg)} if there's an existing pattern using useCallback.
  • Don't add new ESLint disable comments — fix the underlying issue.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 50 lines · 0 tokens per session scan A 0136e14ba54c

Subscribe to this mod's changes

react is a cursor rule published in the GitHub repository inboxpraveen/Minimize-Cursor-Cost (7 stars, last pushed 17d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 471 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.