demo

A set of instructions for creating focused demos for Alibaba Hooks. Each demo pairs a Markdown explanation with TypeScript code, includes Chinese and English sections, and is organized under the relevant hook in the source directory.

In plain words
What is it for?
Use it when adding or revising a hook example. It guides file names, bilingual explanations, single-feature demos, interaction notes, comments, variable names, and basic runtime quality checks.
Why use it?
It helps keep examples short, understandable, copyable, and less dependent on unrelated code. It also sets checks for readable code, common browser sizes, current APIs, and no console errors.

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/alibaba/hooks/demo
Clone the repo
git clone --depth 1 https://github.com/alibaba/hooks

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 355 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin unknown 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.00355
Opus 5 $0.00000 $0.00178
Sonnet 5 $0.00000 $0.00071
Haiku 4.5 $0.00000 $0.00036

Measured today against content hash 4bb80113a9ae, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

demo 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 today.

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/demo.mdc · 44 lines

What it actually says

Demo 规范

  • demo 代码尽可能简洁
  • 避免冗余代码,方便用户复制到项目直接使用
  • 每个 demo 聚焦展示一个功能点
  • 提供中英文两个版本的说明
  • demo 文件命名:
    • 英文 demo: index.en-US.md
    • 中文 demo: index.zh-CN.md
  • 确保 demo 在各种尺寸下都能正常展示
  • 对于复杂交互提供必要的操作说明

文件组织

  • 每个组件演示包含 .md(说明文档)和 .ts(实际代码)两部分
  • 位置:hooks 目录下的 src 子目录,如 packages/hooks/src/useHover
  • 文件名应简洁地描述示例内容

MD 文档规范

  • 必须包含 ## zh-CN## en-US 两种语言说明
  • 内容简洁明了,突出组件特性和用法
  • 避免冗长段落,必要时使用列表或粗体
  • 标注注意事项和实验性功能

代码质量

  • 实用且专注于单一功能
  • 关键处添加简洁注释
  • 使用有意义的数据和变量
  • 优先使用 ahooks 内置 hook 或者公共方法,减少外部依赖

质量要求

  • 确保代码运行正常,无控制台错误
  • 适配常见浏览器
  • 避免过时 API,及时更新到新推荐用法
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. today First seen · 44 lines · 0 tokens per session scan A 4bb80113a9ae

Subscribe to this mod's changes

demo is a cursor rule published in the GitHub repository alibaba/hooks (14,977 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 355 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-01.