mobx-best-practices

mobx-best-practices is a cursor rule for Cursor from holtwood/awesome-cursorrules-zh. It costs 0 tokens per session (453 once invoked), scanned A, original, MIT.

Guidance for managing shared application state with MobX, a library that updates React interfaces when data changes. It covers observable state, derived values, controlled updates, side effects, dependency injection, and tests.

In plain words
What is it for?
Use it when designing MobX stores, defining computed values and actions, connecting stores to React, handling reactions to state changes, or testing state logic.
Why use it?
It helps prevent unpredictable updates, infinite render loops, and unnecessary component refreshes. It also keeps state changes and side effects easier to inspect and test.

Cursor rule for Cursor

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

Good fit Use it when designing MobX stores, defining computed values and actions, connecting stores to React, handling reactions to state changes, or testing state logic.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/holtwood/awesome-cursorrules-zh/mobx-best-practices
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/holtwood/awesome-cursorrules-zh

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 mobx-best-practices

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

Your own site · 80×15
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/mobx-best-practices"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/mobx-best-practices.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 453 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.00453
Opus 5 $0.00000 $0.00227
Sonnet 5 $0.00000 $0.00091
Haiku 4.5 $0.00000 $0.00045

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

Security

Grade A, and why

mobx-best-practices 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/mobx-best-practices.mdc · 16 lines

What it actually says

  • 遵循 MobX 可扩展状态管理的最佳实践
    • 明确可观察状态:使用 @observablemakeObservable 明确定义哪些属性是可观察的,避免不必要的响应。
    • 使用计算值(@computed:对于从可观察状态派生出的值,使用 @computed。它们只在依赖项改变时重新计算,提高性能。
    • 使用动作(@action)修改状态:所有状态修改都应通过 @action 标记的函数进行,这有助于调试和确保状态更新的原子性。
    • 避免在渲染中修改状态:不要在 React 组件的 render 方法或函数组件的顶层直接修改 MobX 状态,这可能导致无限循环或不可预测的行为。
    • 细粒度可观察性:尽量使可观察状态的粒度更细,例如,将一个大对象分解为多个小对象,这样只有当特定部分改变时才会触发更新。
    • 使用 reactionautorun 进行副作用处理:对于需要响应状态变化并执行副作用(如日志记录、网络请求)的场景,使用 reactionautorun,而不是在组件中直接处理。
    • 依赖注入:使用 React Context 或其他依赖注入模式来提供 MobX store,避免 prop drilling。
    • 严格模式(useStrict:在开发模式下启用严格模式,强制所有状态修改都通过 action 进行,有助于早期发现问题。
    • 测试:为 MobX store 编写单元测试,确保状态逻辑的正确性。
    • 避免过度使用 MobX:对于简单的组件内部状态,可以考虑使用 React 的 useStateuseReducer,而不是总是引入 MobX。
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 · 16 lines · 0 tokens per session scan A 25142536b50d

Subscribe to this mod's changes

mobx-best-practices 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 453 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.