react-rules

react-rules is a cursor rule for Cursor from openstory-so/openstory. It costs 989 tokens per session, scanned A, original, MIT.

A collection of React coding conventions for building user interfaces, including guidance on component size, state, effects, props, and shared data.

In plain words
What is it for?
It helps structure React components, decide when to use useEffect or useState, move logic into plain TypeScript functions, define props, and manage state with reducers or context.
Why use it?
It aims to reduce complex components, unnecessary state, hard-to-test logic, and unpredictable behavior caused by shared global data.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It helps structure React components, decide when to use useEffect or useState, move logic into plain TypeScript functions, define props, and manage state with reducers or context.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/openstory-so/openstory/react-rules
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.

Clone the repo
git clone --depth 1 https://github.com/openstory-so/openstory

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for react-rules

README.md
[![agentmods](https://agentmods.dev/badge/rules/openstory-so/openstory/react-rules/github.svg)](https://agentmods.dev/rules/openstory-so/openstory/react-rules)
Your own site
<a href="https://agentmods.dev/rules/openstory-so/openstory/react-rules"><img src="https://agentmods.dev/badge/rules/openstory-so/openstory/react-rules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for react-rules

Your own site · 80×15
<a href="https://agentmods.dev/rules/openstory-so/openstory/react-rules"><img src="https://agentmods.dev/badge/rules/openstory-so/openstory/react-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 989 This file is loaded in full into every session.
When invoked 989 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00989 $0.00989
Opus 5.5 $0.00396 $0.00396
Sonnet 5.5 $0.00198 $0.00198
Haiku 4.5 $0.00099 $0.00099

Measured 1mo ago against content hash 41e965deebf3, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

react-rules 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 1mo 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.

.cursor/rules/react-rules.mdc · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

1. Use as little React as possible

  • Keep components small - less than 100 lines
  • Views reference components
  • Remove as much logic as possible from components and views
  • Externalize functions rather and keep external functions vanilla typescript
  • Vanilla typescript is easier to test, and package for other uses

2. Avoid using useEffect

  • Avoid using useEffect to fetch data or initialise state
  • Use hooks, tanstack query, or the new use feature in react 19
  • use useEffect to update state when something else changes

3. Use useState sparingly

  • Using a local variable is often more optimal - even if something has to be calculated
  • useState uses reducers under the hood
  • If you have more than 3 useStates you might as well use reducers

4. Use React.FC and expand props

  • Expand props so that each parameter is named
  • It's easier to know which props are not used

5. Avoid globals and global state

  • Globals including auth globals, often lead to race conditions
  • Global state is only useful in rare cases. SPAs with signifant complexity
  • Start with reducers which are passed through props
  • If that's too complicated, use React context
  • As a last resort for very complicated SPAs - use zustand

6. Use reducers

  • Reducers are great - read up on them and understand them
  • They keep all state update logic in one place
  • They are vanilla typescript - keep them that way
  • Use them to update state based on other state.
  • Note that updating any part of the state returned from a reducer will cause a re-render if the whole state is a parameter - you can pass just parts of it

7. Avoid passing style to components

  • Avoid passing styles to components, or styling your components in views
  • Create components that are pre-styled
  • Create variants - e.g. small, medium, large - rather than size={18}
  • Avoid using styles in views as much as possible

8. Use the theme

  • Create constants for your theme or use a consistent structure
  • Use the theme fonts and colors
  • Avoid naming fonts and inluding color values directly in views and components

Read the full file on GitHub · 110 lines

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. 1mo ago First seen · 110 lines · 989 tokens per session scan A 41e965deebf3

Subscribe to this mod's changes

react-rules is a cursor rule published in the GitHub repository openstory-so/openstory (676 stars, last pushed yesterday), licensed MIT. It adds 989 tokens to every session, about $0.0040 per session on Opus 5.5. 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-30.