---
description: CloudBase AI Development Rules Guide - Provides scenario-based best practices to ensure development quality
globs: *
alwaysApply: true
inclusion: always
---
- Environment Check: Call
envQuerytool first (applies to all interactions) ⚠️ Template Download (MANDATORY for New Projects): MUST calldownloadTemplatetool FIRST when starting a new project - Do NOT create files manually. UsedownloadTemplatewithtemplate="react"ortemplate="vue"to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.⚠️ UI Design (CRITICAL): MUST readrules/ui-design/rule.mdFIRST before generating any page, interface, component, or style - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.- Core Capabilities: Read Core Capabilities section below (especially UI Design and Database + Authentication for Web)
- Platform Rules: Read
rules/web-development/rule.mdfor platform-specific rules (SDK integration, static hosting, build configuration) - Authentication: Read
rules/auth-web/rule.md- MUST use Web SDK built-in authentication - Database:
- NoSQL:
rules/no-sql-web-sdk/rule.md - MySQL:
rules/relational-database-web/rule.md+rules/relational-database-tool/rule.md
- NoSQL:
- Environment Check: Call
envQuerytool first (applies to all interactions) ⚠️ Template Download (MANDATORY for New Projects): MUST calldownloadTemplatetool FIRST when starting a new project - Do NOT create files manually. UsedownloadTemplatewithtemplate="miniprogram"to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.⚠️ UI Design (CRITICAL): MUST readrules/ui-design/rule.mdFIRST before generating any page, interface, component, or style - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.- Core Capabilities: Read Core Capabilities section below (especially UI Design and Database + Authentication for Mini Program)
- Platform Rules: Read
rules/miniprogram-development/rule.mdfor platform-specific rules (project structure, WeChat Developer Tools, wx.cloud usage) - Authentication: Read
rules/auth-wechat/rule.md- Naturally login-free, get OPENID in cloud functions - Database:
- NoSQL:
rules/no-sql-wx-mp-sdk/rule.md - MySQL:
rules/relational-database-tool/rule.md(via tools)
- NoSQL:
- Environment Check: Call
envQuerytool first (applies to all interactions) ⚠️ Platform Limitation: Native apps (iOS, Android, Flutter, React Native, and other native mobile frameworks) do NOT support CloudBase SDK - Must use HTTP API to call CloudBase capabilities⚠️ UI Design (CRITICAL): MUST readrules/ui-design/rule.mdFIRST before generating any page, interface, component, or style - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.- Required Rules:
- MUST read
rules/http-api/rule.md- HTTP API usage for all CloudBase operations - MUST read
rules/relational-database-tool/rule.md- MySQL database operations (via tools)
- MUST read
- Optional Rules:
rules/cloudbase-platform/rule.md- Universal CloudBase platform knowledgerules/ui-design/rule.md- UI design guidelines (if UI is involved)
⚠️ Database Limitation: Only MySQL database is supported for native apps. If users need to use MySQL database, MUST prompt them to enable it in the console first:- Enable MySQL database at: CloudBase Console - MySQL Database
- Replace
${envId}with the actual environment ID
As the most important part of application development, the following four core capabilities must be done well, without needing to read different rules for different platforms:
rules/ui-design/rule.md rules for ALL design work
🚨 CRITICAL ENFORCEMENT: You MUST explicitly read the file rules/ui-design/rule.md before generating ANY UI code. This is NOT a suggestion - it is a MANDATORY requirement.
Before generating ANY page, interface, component, or style:
- MUST FIRST explicitly read
rules/ui-design/rule.mdfile - Use file reading tools to read this file, do NOT skip this step - MUST complete design specification output before writing any code:
- Purpose Statement
- Aesthetic Direction (choose from specific options, NOT generic terms)
- Color Palette (with hex codes, avoid forbidden colors)
- Typography (specific font names, avoid forbidden fonts)
- Layout Strategy (asymmetric/creative approach, avoid centered templates)
- MUST ensure generated interfaces have distinctive aesthetic styles and high-quality visual design
- MUST avoid generic AI aesthetics (common fonts, clichéd color schemes, templated designs)
This applies to ALL tasks involving:
- Page generation
- Interface creation
- Component design
- Style/visual effects
- Any frontend visual elements
rules/ui-design/rule.md, STOP immediately and read the file first.
Strengthen database and authentication capabilities
Authentication:
- Web Projects:
- Must use CloudBase Web SDK built-in authentication, refer to
rules/auth-web/rule.md - Platform development rules: Refer to
rules/web-development/rule.mdfor Web SDK integration, static hosting deployment, and build configuration
- Must use CloudBase Web SDK built-in authentication, refer to
- Mini Program Projects:
- Naturally login-free, get
wxContext.OPENIDin cloud functions, refer torules/auth-wechat/rule.md - Platform development rules: Refer to
rules/miniprogram-development/rule.mdfor mini program project structure, WeChat Developer Tools integration, and CloudBase capabilities
- Naturally login-free, get
- Node.js Backend: Refer to
rules/auth-nodejs/rule.md
Database Operations:
- Web Projects:
- NoSQL Database: Refer to
rules/no-sql-web-sdk/rule.md - MySQL Relational Database: Refer to
rules/relational-database-web/rule.md(Web application development) andrules/relational-database-tool/rule.md(Management via tools) - Platform development rules: Refer to
rules/web-development/rule.mdfor Web SDK database integration patterns
- NoSQL Database: Refer to
- Mini Program Projects:
- NoSQL Database: Refer to
rules/no-sql-wx-mp-sdk/rule.md - MySQL Relational Database: Refer to
rules/relational-database-tool/rule.md(via tools) - Platform development rules: Refer to
rules/miniprogram-development/rule.mdfor mini program database integration and wx.cloud usage
- NoSQL Database: Refer to
Refer to deployment process in rules/web-development/rule.md
- Use CloudBase static hosting after build completion
- Deploy using
uploadFilestool - Remind users that CDN has a few minutes of cache after deployment
- Generate markdown format access links with random queryString
Refer to rules/cloudrun-development/rule.md
- Cloud Function Deployment: Use
getFunctionListto query, then callcreateFunctionorupdateFunctionCodeto deploy - CloudRun Deployment: Use
manageCloudRuntool for containerized deployment - Ensure backend code supports CORS, prepare Dockerfile (for container type)
Important: To ensure development quality, AI must complete the following steps before starting work:
After user inputs any content, first check CloudBase environment status:
- Ensure current CloudBase environment ID is known
- If not present in conversation history, must call
envQuerytool with parameteraction=infoto query current environment information and environment ID - Important: When environment ID configuration is involved in code later, automatically use the queried environment ID, no need for manual user input
Identify current development scenario type, mainly for understanding project type, but core capabilities apply to all projects:
- Web Projects: React/Vue/native JS frontend projects
- WeChat Mini Programs: Mini program CloudBase projects
- Native Apps: Native mobile applications (iOS, Android, Flutter, React Native, etc.) that use HTTP API (no SDK support)
- CloudRun Projects: CloudBase Run backend service projects (supports any language: Java/Go/Python/Node.js/PHP/.NET, etc.)
- Database Related: Projects involving data operations
- UI Design/Interface Generation: Projects requiring interface design, page generation, prototype creation, component design, etc.
Web Projects - Required Rule Files:
rules/web-development/rule.md- Platform development rules (SDK integration, static hosting, build configuration)rules/auth-web/rule.md- Authentication (MUST use Web SDK built-in authentication)rules/no-sql-web-sdk/rule.md- NoSQL database operationsrules/relational-database-web/rule.md- MySQL database operations (Web)rules/relational-database-tool/rule.md- MySQL database management (tools)rules/cloudbase-platform/rule.md- Universal CloudBase platform knowledge
Mini Program Projects - Required Rule Files:
rules/miniprogram-development/rule.md- Platform development rules (project structure, WeChat Developer Tools, wx.cloud)rules/auth-wechat/rule.md- Authentication (naturally login-free, get OPENID in cloud functions)rules/no-sql-wx-mp-sdk/rule.md- NoSQL database operationsrules/relational-database-tool/rule.md- MySQL database operations (via tools)rules/cloudbase-platform/rule.md- Universal CloudBase platform knowledge
Native App Projects (iOS/Android/Flutter/React Native/etc.) - Required Rule Files:
⚠️ rules/http-api/rule.md- MANDATORY - HTTP API usage for all CloudBase operations (SDK not supported)⚠️ rules/relational-database-tool/rule.md- MANDATORY - MySQL database operations (via tools)⚠️ Database Limitation: Only MySQL database is supported. If users need MySQL, MUST prompt them to enable it in console: Enable MySQL Database
Native App Projects (iOS/Android/Flutter/React Native/etc.) - Optional Rule Files:
rules/cloudbase-platform/rule.md- Universal CloudBase platform knowledgerules/ui-design/rule.md- UI design guidelines (if UI is involved)
Universal Rule Files (All Projects):
⚠️ rules/ui-design/rule.md- MANDATORY - HIGHEST PRIORITY - Must read FIRST before any UI/page/component/style generationrules/spec-workflow/rule.md- Standard software engineering process (if needed)
Before starting work, suggest confirming with user:
- "I identify this as a [scenario type] project"
- "I will strictly follow core capability requirements and refer to relevant rule files"
- "Please confirm if my understanding is correct"
- Tool Priority: For Tencent CloudBase operations, must prioritize using CloudBase tools
⚠️ Template Download (MANDATORY): When starting a new project or when user requests to develop an application, MUST FIRST calldownloadTemplatetool - Do NOT manually create project files. UsedownloadTemplatewith appropriate template type (react,vue,miniprogram,uniapp). Only create files manually if template download fails or user explicitly requests manual creation. This ensures proper project structure, configuration files, and best practices.- Project Understanding: First read current project's README.md, follow project instructions for development
- Directory Standards: Before outputting project code in current directory, first check current directory files
- Development Order: When developing, prioritize frontend first, then backend, ensuring frontend interface and interaction logic are completed first, then implement backend business logic
⚠️ UI Design Rules Mandatory Application: When tasks involve generating pages, interfaces, components, styles, or any frontend visual elements, MUST FIRST explicitly read the filerules/ui-design/rule.mdusing file reading tools, then strictly follow the rule file, ensuring generated interfaces have distinctive aesthetic styles and high-quality visual design, avoiding generic AI aesthetics. You MUST output the design specification before writing any UI code.- Backend Development Priority Strategy: When developing backend, prioritize using SDK to directly call CloudBase database, rather than through cloud functions, unless specifically needed (such as complex business logic, server-side computation, calling third-party APIs, etc.)
- Deployment Order: When there are backend dependencies, prioritize deploying backend before previewing frontend
- Interactive Confirmation: Use interactiveDialog to clarify when requirements are unclear, must confirm before executing high-risk operations
- Real-time Communication: Use CloudBase real-time database watch capability
⚠️ Authentication Rules: When users develop projects, if user login authentication is needed, must use built-in authentication functions, must strictly distinguish authentication methods by platform
- Web Projects: MUST use CloudBase Web SDK built-in authentication (e.g.,
auth.toDefaultLoginPage()), refer torules/auth-web/rule.md - Mini Program Projects: Naturally login-free, get
wxContext.OPENIDin cloud functions, refer torules/auth-wechat/rule.md - Native Apps (iOS/Android): MUST use HTTP API for authentication, refer to
rules/http-api/rule.mdand Authentication API swagger
⚠️ Native App Development Rules: When developing native mobile applications (iOS, Android, Flutter, React Native, and other native mobile frameworks):
- SDK Not Supported: CloudBase SDK is NOT available for native apps, MUST use HTTP API
- Database Limitation: Only MySQL database is supported via HTTP API
- MySQL Database Setup: If users need MySQL database, MUST prompt them to enable it in console first at: CloudBase Console - MySQL Database (replace
${envId}with actual environment ID) - Required Rules: MUST read
rules/http-api/rule.mdandrules/relational-database-tool/rule.md
-
⚠️ Download CloudBase Templates (MANDATORY for New Projects):- MUST call
downloadTemplatetool FIRST when starting a new project - Do NOT manually create project files - For Web projects: Use
downloadTemplatewithtemplate="react"ortemplate="vue" - For Mini Program projects: Use
downloadTemplatewithtemplate="miniprogram" - For UniApp projects: Use
downloadTemplatewithtemplate="uniapp" - Only proceed with manual file creation if template download fails or user explicitly requests manual creation
- If unable to download to current directory, can use scripts to copy, note that hidden files also need to be copied
- MUST call
-
⚠️ UI Design Document Reading (MANDATORY):- Before generating ANY page, interface, component, or style, MUST FIRST explicitly read the file
rules/ui-design/rule.mdusing file reading tools - MUST output the design specification (Purpose Statement, Aesthetic Direction, Color Palette, Typography, Layout Strategy) before writing any UI code
- This is NOT optional - you MUST read the file and follow the design thinking framework and frontend aesthetics guidelines
- Avoid generating generic AI aesthetic style interfaces
- Before generating ANY page, interface, component, or style, MUST FIRST explicitly read the file
-
Mini Program TabBar Material Download - Download Remote Material Links: Mini program Tabbar and other material images must use png format, must use downloadRemoteFile tool to download files locally. Can select from Unsplash, wikimedia (generally choose 500 size), Pexels, Apple official UI and other resources
If remote links are needed in the application, can continue to call uploadFile to upload and obtain temporary access links and cloud storage cloudId
-
Query Professional Knowledge from Knowledge Base: If uncertain about any CloudBase knowledge, can use searchKnowledgeBase tool to intelligently search CloudBase knowledge base (supports CloudBase and cloud functions, mini program frontend knowledge, etc.), quickly obtain professional documents and answers through vector search
-
WeChat Developer Tools Open 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"
- Windows:
- Project root directory path is the directory containing project.config.json file
-
Cloud Function Deployment Process: Can use getFunctionList tool to query if there are cloud functions, then directly call createFunction or updateFunctionCode to update cloud function code. Only need to point functionRootPath to parent directory of cloud function directory (e.g., absolute path of cloudfunctions directory). No need for code compression and other operations. The above tools will automatically read files from cloud function subdirectories with same name under parent directory and automatically deploy
-
CloudRun Deployment Process: For non-cloud function backend services (Java, Go, PHP, Python, Node.js, etc.), use manageCloudRun tool for deployment. Ensure backend code supports CORS, prepare Dockerfile, then call manageCloudRun for containerized deployment. For details, refer to
rules/cloudrun-development/rule.md -
Static Hosting Deployment Process: Deploy using uploadFiles tool. After deployment, remind users that CDN has a few minutes of cache. Can generate markdown format access links with random queryString. For details, refer to
rules/web-development/rule.md
- You will generate a README.md file after generating the project, containing basic project information, such as project name, project description. Most importantly, clearly explain the project architecture and involved CloudBase resources, so maintainers can refer to it for modification and maintenance
- After deployment, if it's a web project, can write the official deployment access address in the documentation
- To help others who don't use AI understand what resources are available, can generate a cloudbaserc.json file after generation
When calling tool services, you need to fully understand the data types of all interfaces to be called, as well as return value types. If you're not sure which interface to call, first check the documentation and tool descriptions, then determine which interface and parameters to call based on the documentation and tool descriptions. Do not have incorrect method parameters or parameter type errors.
For example, many interfaces require a confirm parameter, which is a boolean type. If you don't provide this parameter, or provide incorrect data type, the interface will return an error.
- When generating project configuration files (such as
cloudbaserc.json,project.config.json, etc.), automatically use the environment ID queried byenvQuery - In code examples involving environment ID, automatically fill in current environment ID, no need for manual user replacement
- In deployment and preview related operations, prioritize using already queried environment information
Note: For detailed information, refer to the specific skill files. This section provides quick reference only.
- Web:
rules/web-development/rule.md- SDK integration, static hosting, build configuration - Mini Program:
rules/miniprogram-development/rule.md- Project structure, WeChat Developer Tools, wx.cloud - CloudRun:
rules/cloudrun-development/rule.md- Backend deployment (functions/containers) - Platform (Universal):
rules/cloudbase-platform/rule.md- Environment, authentication, services
- Web:
rules/auth-web/rule.md- MUST use Web SDK built-in authentication - Mini Program:
rules/auth-wechat/rule.md- Naturally login-free, get OPENID in cloud functions - Node.js:
rules/auth-nodejs/rule.md - HTTP API:
rules/auth-http-api/rule.md
- NoSQL (Web):
rules/no-sql-web-sdk/rule.md - NoSQL (Mini Program):
rules/no-sql-wx-mp-sdk/rule.md - MySQL (Web):
rules/relational-database-web/rule.md - MySQL (Tool):
rules/relational-database-tool/rule.md
rules/ui-design/rule.md- MANDATORY - HIGHEST PRIORITY- MUST read FIRST before generating ANY interface/page/component/style
- Design thinking framework, complete design process, frontend aesthetics guidelines
- NO EXCEPTIONS: All UI work requires reading this file first
- Spec Workflow:
rules/spec-workflow/rule.md- Standard software engineering process (requirements, design, tasks)
To ensure development quality, recommend completing the following checks before starting tasks:
- [ ] Environment Check: Call
envQuerytool to check CloudBase environment status (applies to all interactions) - [ ] Template Download Check (MANDATORY for New Projects): If starting a new project, have you called
downloadTemplatetool FIRST? Do NOT manually create project files - use templates. - [ ] Scenario Identification: Clearly identify what type of project this is (Web/Mini Program/Database/UI)
- [ ] Core Capability Confirmation: Confirm all four core capabilities have been considered
- UI Design: Have you explicitly read the file
rules/ui-design/rule.mdusing file reading tools? - Database + Authentication: Have you referred to corresponding authentication and database skills?
- Static Hosting Deployment: Have you understood the deployment process?
- Backend Deployment: Have you understood cloud function or CloudRun deployment process?
- UI Design: Have you explicitly read the file
- [ ] UI Design Rules Check (MANDATORY): If task involves generating pages, interfaces, components, or styles:
- Have you explicitly read the file
rules/ui-design/rule.mdusing file reading tools? (Required: YES) - Have you output the design specification before writing code? (Required: YES)
- Have you understood and will follow the design thinking framework? (Required: YES)
- Have you explicitly read the file
- [ ] User Confirmation: Confirm with user whether scenario identification and core capability understanding are correct
- [ ] Rule Execution: Strictly follow core capability requirements and relevant rule files for development
- ❌ DO NOT manually create project files - Always use
downloadTemplatetool first for new projects - ❌ DO NOT skip reading UI design document - Must explicitly read
rules/ui-design/rule.mdfile before generating any UI code - Avoid skipping core capabilities and starting development directly
- Avoid mixing APIs and authentication methods from different platforms
- Avoid ignoring UI design rules: All tasks involving interfaces, pages, components, styles must explicitly read and strictly follow
rules/ui-design/rule.md - Avoid ignoring database and authentication standards: Must use correct authentication methods and database operation methods
- Important technical solutions should be confirmed with users
If development is found to not comply with standards, can:
- Point out specific issues
- Require re-execution of rule check process
- Clearly specify rule files that need to be followed