moon-web-pages-conventions

moon-web-pages-conventions is a cursor rule for Cursor from aide-family/moon-web. It costs 0 tokens per session (1,278 once invoked), scanned A, original, MIT.

A set of coding rules for React and TypeScript web pages using Ant Design version 6, a library of ready-made interface components.

In plain words
What is it for?
It guides the implementation of page components, API requests, loading states, internationalization, tables, pagination, dialogs, and related UI code.
Why use it?
It gives developers consistent patterns for data loading, error handling, translated interface text, tables, dialogs, and other page behavior.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It guides the implementation of page components, API requests, loading states, internationalization, tables, pagination, dialogs, and related UI code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/aide-family/moon-web/moon-web-pages-conventions
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/aide-family/moon-web

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 moon-web-pages-conventions

README.md
[![agentmods](https://agentmods.dev/badge/rules/aide-family/moon-web/moon-web-pages-conventions/github.svg)](https://agentmods.dev/rules/aide-family/moon-web/moon-web-pages-conventions)
Your own site
<a href="https://agentmods.dev/rules/aide-family/moon-web/moon-web-pages-conventions"><img src="https://agentmods.dev/badge/rules/aide-family/moon-web/moon-web-pages-conventions/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 moon-web-pages-conventions

Your own site · 80×15
<a href="https://agentmods.dev/rules/aide-family/moon-web/moon-web-pages-conventions"><img src="https://agentmods.dev/badge/rules/aide-family/moon-web/moon-web-pages-conventions.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 1,278 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.01278
Opus 5 $0.00000 $0.00639
Sonnet 5 $0.00000 $0.00256
Haiku 4.5 $0.00000 $0.00128

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

Security

Grade A, and why

moon-web-pages-conventions 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 10d 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/moon-web-pages-conventions.mdc · 94 lines

How it starts

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

React + TS + Ant Design v6 页面规范

1) 组件与数据流

  • 页面组件使用函数式组件 + hooks;避免把副作用写在 render 中。
  • 派生状态优先用 useMemo(例如过滤/排序后数据、列定义),避免每次 render 都重建大对象。
  • 事件处理函数优先用 useCallback,并保证依赖项正确且完整。
  • 页面业务请求只调用 src/api/** 的封装;禁止在页面内直接使用底层 http

2) 数据获取与副作用(必做)

  • 进行异步请求时,必须处理 loading(至少是页面级 loading 或局部 actionLoading)。
  • 需要在卸载后避免 setState:使用 mountedRef/取消逻辑(与当前项目一致的写法优先)。
  • try/catch/finally 必须闭环:成功给用户反馈,失败记录并给出降级 UI(例如空表/空状态)。
  • 不要在异常里吞掉错误;至少 console.error(或项目约定的 logger)。

示例(结构要求,非强制实现):

setLoading(true)
try {
  const res = await apiCall()
  setData(res.items ?? [])
} catch (e) {
  console.error('xxx失败', e)
  setData([])
} finally {
  setLoading(false)
}

3) i18n(必做)

  • 所有 UI 文案必须走 i18n:使用 const { t } = useLocale() + t('xxx')
  • message/Modal/Table/placeholder/Tooltip/Button 的文本都必须来自 t(...)
  • 规则:页面里不允许出现业务文案的硬编码(表格列名、弹窗标题、按钮文本、空状态文案等)。

4) Ant Design v6 用法(必做)

Table

  • Table 必须设置 rowKey,且 rowKey 应为业务稳定字段(如 uid)。
  • 分页/滚动使用受控 props:pagination.current/pageSize/totalonChange 联动。
  • 列渲染函数使用类型约束(ColumnsType<T>),渲染内避免出现未处理的 undefined(使用 emptyPlaceholder 或兜底 '-')。

Modal

  • 使用 open(v6)而非 visible
  • onCancel 必须回收/重置本地 state(关闭弹窗时把 record 清空、把输入值清空)。
  • footer
    • 详情弹窗优先 footer={null} 并只读展示
    • 有确认逻辑的弹窗使用 onOk + confirmLoading

Form

  • 表单使用 Form.useForm() 管理实例,校验通过用 form.validateFields()
  • 处理 validateFields 的异常:仅当是 errorFields(校验失败)时直接 return;其它异常要记录并提示。

Dropdown

  • Dropdown 使用 menu={{ items: ... }}(v6),并避免在 render 中创建会变化但不必要的 handler(可在上层 memo/回调中稳定)。
  • 删除/危险操作前使用 MENU_DIVIDER@/utils/menu)与常规菜单项分隔。

代码格式

  • 使用项目根目录 prettier.config.js(单引号、无分号、trailingComma: all 等);提交前执行 pnpm format 或依赖编辑器保存时格式化。
  • ESLint 与 Prettier 分工:样式由 Prettier 处理,逻辑由 ESLint;勿在 ESLint 中重复配置与 Prettier 冲突的规则。

5) 编辑器悬停文档(JSDoc)

  • TypeScript / Cursor 悬停提示只识别 /** JSDoc */,普通 // 行注释不会出现在悬停里。
  • 需要悬停展示说明的函数、变量、接口字段、类型,请写在紧邻声明上方的 JSDoc 中。
  • 第三方库(如 antd)的类型说明来自 node_modules 中的 .d.ts,需保证工作区使用项目内 TypeScript(见 .vscode/settings.jsontypescript.tsdk)。

Read the full file on GitHub · 94 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. 10d ago First seen · 94 lines · 0 tokens per session scan A 578a527450db

Subscribe to this mod's changes

moon-web-pages-conventions is a cursor rule published in the GitHub repository aide-family/moon-web (12 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,278 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-30.