When to use this skill
Use this skill for WeChat Mini Program development when you need to:
- Develop WeChat mini program pages and components
- Integrate CloudBase capabilities (database, cloud functions, storage)
- Deploy and preview mini program projects
- Handle mini program authentication and user identity
- Call AI models in mini programs
- Get WeChat step count data
Do NOT use for:
- Web frontend development (use web-development skill)
- Backend service development (use cloudrun-development skill)
- UI design only (use ui-design skill, but may combine with this skill)
How to use this skill (for a coding agent)
Follow project structure conventions
- Mini program code in
miniprogram directory
- Cloud functions in
cloudfunctions directory
- Use latest base library version
- Include page configuration files (e.g., index.json) when generating pages
Understand authentication characteristics
- Important: Mini programs with CloudBase are naturally login-free
- Never generate login pages or login flows
- Get user identity via
cloud.getWXContext().OPENID in cloud functions
Use WeChat Developer Tools correctly
- Check
project.config.json has appid field before opening
- Use CLI command to open project pointing to directory containing
project.config.json
Handle resources properly
- Icons8 (Recommended): Use Icons8 for icon images (e.g., tabbar iconPath)
- URL format:
https://img.icons8.com/{style}/{size}/{color}/{icon-name}.png
- Parameters:
style: ios (outline style) or ios-filled (filled style)
size: 100 (recommended 100px, file size < 5KB)
color: hex color code without # (e.g., 8E8E93 for gray, FF3B30 for red)
icon-name: icon name (e.g., checked--v1)
- Examples:
- Unselected (gray outline):
https://img.icons8.com/ios/100/8E8E93/checked--v1.png
- Selected (red filled):
https://img.icons8.com/ios-filled/100/FF3B30/checked--v1.png
- Advantages:
- ✅ Very small file size (usually < 3KB)
- ✅ Supports custom colors
- ✅ Clean and professional icons
- Use
downloadRemoteFile tool to download resources
- Avoid build errors by ensuring all referenced resources exist
WeChat Mini Program Development Rules
Project Structure
CloudBase Integration:
- If user needs to develop mini program, you will use various WeChat CloudBase capabilities to develop the project
- Mini program base library should use
latest version
Directory Organization:
- Mini program projects follow WeChat CloudBase best practices
- Mini program code is generally in
miniprogram directory
- If developing cloud functions, they can be stored in
cloudfunctions directory
- Mini program's
project.config.json needs to specify miniprogramRoot and other configurations
Page Generation:
- When generating mini program pages, must include page configuration files such as
index.json
- Must comply with specifications to avoid compilation errors
Development Tools
WeChat Developer Tools Opening Project Workflow:
- When detecting current project is a mini program project, suggest user to use WeChat Developer Tools for preview, debugging, and publishing
- Before opening, confirm
project.config.json has appid field configured. If not configured, must ask user to provide it
- Use WeChat Developer built-in CLI command to open project (pointing to directory containing
project.config.json):
- Windows:
"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat" open --project "项目根目录路径"
- macOS:
/Applications/wechatwebdevtools.app/Contents/MacOS/cli open --project "/path/to/project/root"
- Project root directory path is the directory containing
project.config.json file
CloudBase Integration
Environment Configuration:
- When using
wx.cloud in mini program, need to specify environment ID
- Environment ID can be queried via
envQuery tool
Resource Management:
- When generating mini program code, if material images are needed, such as tabbar's
iconPath and other places, prefer Icons8 (see section 4 above for details)
- Use
downloadRemoteFile tool to download resources
- When generating mini program code, if using
iconPath and similar, must simultaneously help user download icons to avoid build errors
Mini Program Authentication Characteristics
Important: Mini programs with CloudBase are naturally login-free. It is strictly forbidden to generate login pages or login flows!
Login-Free Feature: Mini program CloudBase does not require user login, can get user identity in cloud functions via wx-server-sdk
User Identity Retrieval: In cloud functions, get user's unique identifier via cloud.getWXContext().OPENID
User Data Management: Manage user data in cloud functions based on openid, no login flow needed
// Example of getting user identity in cloud function
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext();
const openid = wxContext.OPENID;
return { openid: openid };
};
AI Model Invocation
Mini programs with base library version 3.7.1+ already support direct AI model invocation
// Create model instance, here we use DeepSeek AI model
const model = wx.cloud.extend.AI.createModel("deepseek");
// First set AI's system prompt, here using seven-character quatrain generation as example
const systemPrompt =
"请严格按照七言绝句或七言律诗的格律要求创作,平仄需符合规则,押韵要和谐自然,韵脚字需在同一韵部。创作内容围绕用户给定的主题,七言绝句共四句,每句七个字;七言律诗共八句,每句七个字,颔联和颈联需对仗工整。同时,要融入生动的意象、丰富的情感与优美的意境,展现出古诗词的韵味与美感。";
// User's natural language input, e.g., '帮我写一首赞美玉龙雪山的诗'
const userInput = "帮我写一首赞美玉龙雪山的诗";
// Pass system prompt and user input to AI model
const res = await model.streamText({
data: {
model: "deepseek-v3", // Specify specific model
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userInput },
],
},
});
// Receive AI model's response
// Since AI model's return result is streaming, we need to loop to receive complete response text
for await (let str of res.textStream) {
console.log(str);
}
WeChat Step Count Retrieval
WeChat step count retrieval must use CloudID method (base library 2.7.0+):
- Frontend:
wx.getWeRunData() to get cloudID, use wx.cloud.CloudID(cloudID) to pass to cloud function
- Cloud Function: Directly use
weRunData.data to get decrypted step count data, check weRunData.errCode to handle errors
- Forbidden: Do not use session_key manual decryption method, CloudID is more secure and simple
- Required: Must implement fallback mechanism (simulated data) to handle cloudID retrieval failure cases
Cloud Function Deployment and Permission Notes
- After AI automatically deploys cloud functions, special permissions like cloud invocation may be missing
- Recommend users to right-click cloud function in WeChat Developer Tools, select "Install Dependencies in Cloud"
- For functions requiring cloud invocation permissions (such as WeChat step count decryption), recommend manually deploying once via Developer Tools to get complete permissions
- If encountering permission issues, prompt user to check cloud function's service authorization and API permission configuration
Development Workflow Guidance
- After completing mini program project development, proactively suggest user to use WeChat Developer Tools for preview, debugging, and publishing
- If user agrees, use CLI command to open WeChat Developer Tools, pointing to project root directory containing
project.config.json
- Remind user to perform real device preview, debugging, and publishing operations in WeChat Developer Tools
1---2name: miniprogram-development-23description: WeChat Mini Program development rules. Use this skill when developing WeChat mini programs, integrating CloudBase capabilities, and deploying mini program projects.4---5
6## When to use this skill
7
8Use this skill for **WeChat Mini Program development** when you need to:
9
10- Develop WeChat mini program pages and components
11- Integrate CloudBase capabilities (database, cloud functions, storage)
12- Deploy and preview mini program projects
13- Handle mini program authentication and user identity
14- Call AI models in mini programs
15- Get WeChat step count data
16
17**Do NOT use for:**
18- Web frontend development (use web-development skill)
19- Backend service development (use cloudrun-development skill)
20- UI design only (use ui-design skill, but may combine with this skill)
21
22---
23
24## How to use this skill (for a coding agent)
25
261. **Follow project structure conventions**
27 - Mini program code in `miniprogram` directory
28 - Cloud functions in `cloudfunctions` directory
29 - Use latest base library version
30 - Include page configuration files (e.g., index.json) when generating pages
31
322. **Understand authentication characteristics**
33 - **Important**: Mini programs with CloudBase are naturally login-free
34 - **Never generate login pages or login flows**
35 - Get user identity via `cloud.getWXContext().OPENID` in cloud functions
36
373. **Use WeChat Developer Tools correctly**
38 - Check `project.config.json` has `appid` field before opening
39 - Use CLI command to open project pointing to directory containing `project.config.json`
40
414. **Handle resources properly**
42 - **Icons8 (Recommended)**: Use Icons8 for icon images (e.g., tabbar iconPath)
43 - URL format: `https://img.icons8.com/{style}/{size}/{color}/{icon-name}.png`
44 - Parameters:
45 - `style`: `ios` (outline style) or `ios-filled` (filled style)
46 - `size`: `100` (recommended 100px, file size < 5KB)
47 - `color`: hex color code without # (e.g., `8E8E93` for gray, `FF3B30` for red)
48 - `icon-name`: icon name (e.g., `checked--v1`)
49 - Examples:
50 - Unselected (gray outline): `https://img.icons8.com/ios/100/8E8E93/checked--v1.png`
51 - Selected (red filled): `https://img.icons8.com/ios-filled/100/FF3B30/checked--v1.png`
52 - Advantages:
53 - ✅ Very small file size (usually < 3KB)
54 - ✅ Supports custom colors
55 - ✅ Clean and professional icons
56 - Use `downloadRemoteFile` tool to download resources
57 - Avoid build errors by ensuring all referenced resources exist
58
59---
60
61# WeChat Mini Program Development Rules
62
63## Project Structure
64
651. **CloudBase Integration**:
66 - If user needs to develop mini program, you will use various WeChat CloudBase capabilities to develop the project
67 - Mini program base library should use `latest` version
68
692. **Directory Organization**:
70 - Mini program projects follow WeChat CloudBase best practices
71 - Mini program code is generally in `miniprogram` directory
72 - If developing cloud functions, they can be stored in `cloudfunctions` directory
73 - Mini program's `project.config.json` needs to specify `miniprogramRoot` and other configurations
74
753. **Page Generation**:
76 - When generating mini program pages, must include page configuration files such as `index.json`
77 - Must comply with specifications to avoid compilation errors
78
79## Development Tools
80
81**WeChat Developer Tools Opening Project Workflow**:
82- When detecting current project is a mini program project, suggest user to use WeChat Developer Tools for preview, debugging, and publishing
83- Before opening, confirm `project.config.json` has `appid` field configured. If not configured, must ask user to provide it
84- Use WeChat Developer built-in CLI command to open project (pointing to directory containing `project.config.json`):
85 - Windows: `"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat" open --project "项目根目录路径"`
86 - macOS: `/Applications/wechatwebdevtools.app/Contents/MacOS/cli open --project "/path/to/project/root"`
87- Project root directory path is the directory containing `project.config.json` file
88
89## CloudBase Integration
90
911. **Environment Configuration**:
92 - When using `wx.cloud` in mini program, need to specify environment ID
93 - Environment ID can be queried via `envQuery` tool
94
952. **Resource Management**:
96 - When generating mini program code, if material images are needed, such as tabbar's `iconPath` and other places, **prefer Icons8** (see section 4 above for details)
97 - Use `downloadRemoteFile` tool to download resources
98 - When generating mini program code, if using `iconPath` and similar, must simultaneously help user download icons to avoid build errors
99
100## Mini Program Authentication Characteristics
101
102**Important: Mini programs with CloudBase are naturally login-free. It is strictly forbidden to generate login pages or login flows!**
103
1041. **Login-Free Feature**: Mini program CloudBase does not require user login, can get user identity in cloud functions via wx-server-sdk
105
1062. **User Identity Retrieval**: In cloud functions, get user's unique identifier via `cloud.getWXContext().OPENID`
107
1083. **User Data Management**: Manage user data in cloud functions based on openid, no login flow needed
109
110```js
111// Example of getting user identity in cloud function
112exports.main = async (event, context) => {
113 const wxContext = cloud.getWXContext();
114 const openid = wxContext.OPENID;
115
116 return { openid: openid };
117};
118```
119
120## AI Model Invocation
121
122Mini programs with base library version 3.7.1+ already support direct AI model invocation
123
124```js
125// Create model instance, here we use DeepSeek AI model
126const model = wx.cloud.extend.AI.createModel("deepseek");
127
128// First set AI's system prompt, here using seven-character quatrain generation as example
129const systemPrompt =
130 "请严格按照七言绝句或七言律诗的格律要求创作,平仄需符合规则,押韵要和谐自然,韵脚字需在同一韵部。创作内容围绕用户给定的主题,七言绝句共四句,每句七个字;七言律诗共八句,每句七个字,颔联和颈联需对仗工整。同时,要融入生动的意象、丰富的情感与优美的意境,展现出古诗词的韵味与美感。";
131
132// User's natural language input, e.g., '帮我写一首赞美玉龙雪山的诗'
133const userInput = "帮我写一首赞美玉龙雪山的诗";
134
135// Pass system prompt and user input to AI model
136const res = await model.streamText({
137 data: {
138 model: "deepseek-v3", // Specify specific model
139 messages: [
140 { role: "system", content: systemPrompt },
141 { role: "user", content: userInput },
142 ],
143 },
144});
145
146// Receive AI model's response
147// Since AI model's return result is streaming, we need to loop to receive complete response text
148for await (let str of res.textStream) {
149 console.log(str);
150}
151```
152
153## WeChat Step Count Retrieval
154
155**WeChat step count retrieval must use CloudID method (base library 2.7.0+)**:
156- **Frontend**: `wx.getWeRunData()` to get cloudID, use `wx.cloud.CloudID(cloudID)` to pass to cloud function
157- **Cloud Function**: Directly use `weRunData.data` to get decrypted step count data, check `weRunData.errCode` to handle errors
158- **Forbidden**: Do not use session_key manual decryption method, CloudID is more secure and simple
159- **Required**: Must implement fallback mechanism (simulated data) to handle cloudID retrieval failure cases
160
161## Cloud Function Deployment and Permission Notes
162
163- After AI automatically deploys cloud functions, special permissions like cloud invocation may be missing
164- Recommend users to right-click cloud function in WeChat Developer Tools, select "Install Dependencies in Cloud"
165- For functions requiring cloud invocation permissions (such as WeChat step count decryption), recommend manually deploying once via Developer Tools to get complete permissions
166- If encountering permission issues, prompt user to check cloud function's service authorization and API permission configuration
167
168## Development Workflow Guidance
169
170- After completing mini program project development, proactively suggest user to use WeChat Developer Tools for preview, debugging, and publishing
171- If user agrees, use CLI command to open WeChat Developer Tools, pointing to project root directory containing `project.config.json`
172- Remind user to perform real device preview, debugging, and publishing operations in WeChat Developer Tools
173