wechat-mini-program

A set of development rules for WeChat Mini Programs, which are small apps that run inside WeChat. It covers TypeScript, styling, page structure, reusable components, shared state, and network requests.

In plain words
What is it for?
Use it when building or maintaining a WeChat Mini Program with TypeScript, Less or Sass, Vant Weapp, and Vue-inspired reusable logic.
Why use it?
It gives the project a consistent structure and coding approach, reducing confusion as pages and features grow. It also specifies how to handle requests, errors, retries, and shared data.

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/mywand/cusrsor-do-it/wechat-mini-program
Clone the repo
git clone --depth 1 https://github.com/mywand/cusrsor-do-it

Made for: Cursor.

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

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

Security

Grade A, and why

wechat-mini-program 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 yesterday.

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/frameworks/wechat-mini-program.mdc · 979 lines

How it starts

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

最近更新: 2025-09-18

微信小程序开发规范

1. 技术栈与项目基础

  • 平台:微信小程序(基础库 2.32.0+)
  • 语言:TypeScript 严格模式(strict: truenoImplicitAny: true
  • 样式:Less/Sass + 设计系统 Token
  • 状态管理:轻量 store + 组合式逻辑(借鉴 Vue Composition API 思想)
  • UI库:Vant Weapp + 自定义原子组件
  • 构建:微信开发者工具 + 自定义构建脚本
  • 数据请求:统一封装 + 错误处理 + 重试机制(参考 TanStack Query 模式)

2. 目录结构(优化版)

miniprogram/
├── app.json                    # 小程序全局配置
├── app.less                    # 全局样式 + Token 导入
├── app.ts                      # 小程序入口 + 全局状态初始化
├── sitemap.json                # 搜索索引配置
├── pages/                      # 页面目录(路由页面)
│   ├── home/                   # 首页
│   └── profile/                # 个人中心
├── components/                 # 可复用基础组件(无业务逻辑)
│   ├── base/                   # 原子组件(Button/Input/Card)
│   └── business/               # 业务组件(UserCard/OrderItem)
├── features/                   # 业务特性模块(聚合页面/组件/逻辑)
│   ├── auth/                   # 认证模块
│   ├── order/                  # 订单模块
│   └── user/                   # 用户模块
├── composables/                # 复用逻辑(类似 Vue useXXX)
│   ├── useRequest.ts           # 请求封装
│   ├── useAuth.ts              # 认证逻辑
│   └── useStorage.ts           # 存储管理
├── stores/                     # 状态管理模块
│   ├── auth.ts                 # 认证状态
│   ├── user.ts                 # 用户状态
│   └── index.ts                # 状态汇总
├── api/                        # API 接口封装
│   ├── types.ts                # API 类型定义
│   ├── client.ts               # 统一请求客户端
│   ├── auth.ts                 # 认证相关接口
│   └── user.ts                 # 用户相关接口
├── utils/                      # 纯函数工具(无框架耦合)
│   ├── format.ts               # 格式化工具
│   ├── validate.ts             # 校验工具
│   └── constants.ts            # 常量定义
├── tokens/                     # 设计系统 Token
│   ├── colors.ts               # 颜色定义
│   ├── spacing.ts              # 间距定义
│   ├── typography.ts           # 字体定义
│   └── index.ts                # Token 汇总
├── styles/                     # 全局样式
│   ├── variables.less          # Less 变量
│   ├── mixins.less             # 样式混入
│   └── reset.less              # 样式重置
├── assets/                     # 静态资源
│   ├── images/                 # 图片资源
│   └── icons/                  # 图标资源
├── types/                      # 全局类型定义
│   ├── global.d.ts             # 全局类型扩展
│   └── api.d.ts                # API 响应类型
└── custom-tab-bar/             # 自定义 TabBar

Read the full file on GitHub · 979 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. yesterday First seen · 979 lines · 0 tokens per session scan A 23253b382fff

Subscribe to this mod's changes

wechat-mini-program is a cursor rule published in the GitHub repository mywand/cusrsor-do-it (2 stars, last pushed 7mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 6,985 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-31.