react-general-preferences

react-general-preferences is a cursor rule for Cursor from holtwood/awesome-cursorrules-zh. It costs 0 tokens per session (531 once invoked), scanned A, original, MIT.

A set of React preferences that favors function components with Hooks, which let functions use state and other React features.

In plain words
What is it for?
Use it when creating React components, managing state and side effects, or reusing logic through custom Hooks.
Why use it?
It reduces class-component boilerplate and makes reusable component logic easier to organize and test.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { useStore } from '../stores';.

Good fit Use it when creating React components, managing state and side effects, or reusing logic through custom Hooks.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zh
agentmods
npx agentmods add rules/holtwood/awesome-cursorrules-zh/react-general-preferences

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-general-preferences

README.md
[![agentmods](https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/react-general-preferences/github.svg)](https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/react-general-preferences)
Your own site
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/react-general-preferences"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/react-general-preferences/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-general-preferences

Your own site · 80×15
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/react-general-preferences"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/react-general-preferences.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 531 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.00531
Opus 5 $0.00000 $0.00266
Sonnet 5 $0.00000 $0.00106
Haiku 4.5 $0.00000 $0.00053

Measured 6d ago against content hash 8220033accdf, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

react-general-preferences 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 6d 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.

docs/rules/frontend/react/mobx/react-general-preferences.mdc · 44 lines

What it actually says

  • 优先使用带有 Hooks 的函数式组件
    • 现代化开发
      • 函数式组件结合 Hooks 是 React 官方推荐的现代开发范式。它使得组件逻辑更清晰、可复用性更高,并且避免了类组件中 this 的复杂性。
    • 代码简洁性
      • Hooks 允许你在函数式组件中直接使用状态(useState)、生命周期(useEffect)和其他 React 特性,从而减少了样板代码,使组件更简洁。
      • 示例:
        import React, { useState, useEffect } from 'react';
        import { observer } from 'mobx-react-lite';
        import { useStore } from '../stores';
        
        const Counter = observer(() => {
          const [count, setCount] = useState(0);
          const { appStore } = useStore();
        
          useEffect(() => {
            console.log('Component mounted or updated');
            return () => console.log('Component unmounted');
          }, []);
        
          return (
            <div>
              <p>Count: {count}</p>
              <button onClick={() => setCount(count + 1)}>Increment</button>
              <p>App Status: {appStore.status}</p>
            </div>
          );
        });
        
        export default Counter;
        
    • 逻辑复用
      • 自定义 Hooks 使得逻辑复用变得非常简单和直观,你可以将状态逻辑和副作用封装成可独立测试和复用的单元。
    • 性能优化
      • 结合 React.memouseCallbackuseMemo 等 Hooks,可以对函数式组件进行更细粒度的性能优化,避免不必要的重新渲染。
    • 与 MobX 兼容性
      • mobx-react-lite 库专门为函数式组件和 Hooks 优化,提供了 observer HOC 和 useObserver Hook,使得 MobX 状态管理在函数式组件中表现出色。
    • 社区支持
      • 随着 Hooks 的普及,越来越多的库和工具都优先支持函数式组件和 Hooks,这使得开发生态更加丰富和活跃。
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. 6d ago First seen · 44 lines · 0 tokens per session scan A 8220033accdf

Subscribe to this mod's changes

react-general-preferences is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (233 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 531 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-09-03.