When to use this skill
Use this skill for CloudBase platform knowledge when you need to:
- Understand CloudBase storage and hosting concepts
- Configure authentication for different platforms (Web vs Mini Program)
- Deploy and manage cloud functions
- Understand database permissions and access control
- Work with data models (MySQL and NoSQL)
- Access CloudBase console management pages
This skill provides foundational knowledge that applies to all CloudBase projects, regardless of whether they are Web, Mini Program, or backend services.
How to use this skill (for a coding agent)
Understand platform differences
- Web and Mini Program have completely different authentication approaches
- Must strictly distinguish between platforms
- Never mix authentication methods across platforms
Follow best practices
- Use SDK built-in authentication features (Web)
- Understand natural login-free feature (Mini Program)
- Configure appropriate database permissions
- Use cloud functions for cross-collection operations
Use correct SDKs and APIs
- Different platforms require different SDKs for data models
- MySQL data models must use models SDK, not collection API
- Use
envQuery tool to get environment ID
CloudBase Platform Knowledge
Storage and Hosting
Static Hosting vs Cloud Storage:
- CloudBase static hosting and cloud storage are two different buckets
- Generally, publicly accessible files can be stored in static hosting, which provides a public web address
- Static hosting supports custom domain configuration (requires console operation)
- Cloud storage is suitable for files with privacy requirements, can get temporary access addresses via temporary file URLs
Static Hosting Domain:
- CloudBase static hosting domain can be obtained via
getWebsiteConfig tool
- Combine with static hosting file paths to construct final access addresses
- Important: If access address is a directory, it must end with
/
Environment and Authentication
- SDK Initialization:
- CloudBase SDK initialization requires environment ID
- Can query environment ID via
envQuery tool
- Then proceed with login, for example using anonymous login
Authentication Best Practices
Important: Authentication methods for different platforms are completely different, must strictly distinguish!
Web Authentication
- Must use SDK built-in authentication: CloudBase Web SDK provides complete authentication features
- Recommended method:
auth.toDefaultLoginPage() redirect to default login page
- Forbidden behavior: Do not use cloud functions to implement login authentication logic
- User management: After login, get user information via
auth.getCurrentUser()
Mini Program Authentication
- Login-free feature: Mini program CloudBase is naturally login-free, no login flow needed
- User identifier: In cloud functions, get
wxContext.OPENID via wx-server-sdk
- User management: Manage user data in cloud functions based on openid
- Forbidden behavior: Do not generate login pages or login flow code
Cloud Functions
- Node.js Cloud Functions:
- Node.js cloud functions need to include
package.json, declaring required dependencies
- Can use
createFunction to create functions
- Use
updateFunctionCode to deploy cloud functions
- Prioritize cloud dependency installation, do not upload node_modules
functionRootPath refers to the parent directory of function directories, e.g., cloudfunctions directory
Database Permissions
Permission Model:
- CloudBase database access has permissions
- Default basic permissions include:
- Only creator can write, everyone can read
- Only creator can read/write
- Only admin can write, everyone can read
- Only admin can read/write
- If directly requesting database from web or mini program side, need to configure appropriate database permissions
- In cloud functions, there is no permission control by default
Cross-Collection Operations:
- If user has no special requirements, operations involving cross-database collections must be implemented via cloud functions
Cloud Function Optimization:
- If involving cloud functions, while ensuring security, can minimize the number of cloud functions as much as possible
- For example: implement one cloud function for client-side requests, implement one cloud function for data initialization
Data Models
Get Data Model Operation Object:
- Mini Program: Need
@cloudbase/wx-cloud-client-sdk, initialize const client = initHTTPOverCallFunction(wx.cloud), use client.models
- Cloud Function: Need
@cloudbase/node-sdk@3.10+, initialize const app = cloudbase.init({env}), use app.models
- Web: Need
@cloudbase/js-sdk, initialize const app = cloudbase.init({env}), after login use app.models
Data Model Query:
- Can call MCP
manageDataModel tool to:
- Query model list
- Get model detailed information (including Schema fields)
- Get specific models SDK usage documentation
MySQL Data Model Invocation Rules:
- MySQL data models cannot use collection method invocation, must use data model SDK
- Wrong:
db.collection('model_name').get()
- Correct:
app.models.model_name.list({ filter: { where: {} } })
- Use
manageDataModel tool's docs method to get specific SDK usage
Console Management
After creating/deploying resources, provide corresponding console management page links:
Static Hosting: https://console.cloud.tencent.com/tcb/hosting
Cloud Function: https://tcb.cloud.tencent.com/dev?envId=${envId}#/scf/detail?id=${functionName}&NameSpace=${envId}
Database Collection: https://tcb.cloud.tencent.com/dev?envId=${envId}#/db/doc/collection/${collectionName}
Data Model: https://tcb.cloud.tencent.com/dev?envId=${envId}#/db/doc/model/${modelName}
Usage: After creating corresponding resources, replace variables with actual values, provide to user for management operations.
1---2name: cloudbase-platform-23description: CloudBase platform knowledge and best practices. Use this skill for general CloudBase platform understanding, including storage, hosting, authentication, cloud functions, database permissions, and data models.4---5
6## When to use this skill
7
8Use this skill for **CloudBase platform knowledge** when you need to:
9
10- Understand CloudBase storage and hosting concepts
11- Configure authentication for different platforms (Web vs Mini Program)
12- Deploy and manage cloud functions
13- Understand database permissions and access control
14- Work with data models (MySQL and NoSQL)
15- Access CloudBase console management pages
16
17**This skill provides foundational knowledge** that applies to all CloudBase projects, regardless of whether they are Web, Mini Program, or backend services.
18
19---
20
21## How to use this skill (for a coding agent)
22
231. **Understand platform differences**
24 - Web and Mini Program have completely different authentication approaches
25 - Must strictly distinguish between platforms
26 - Never mix authentication methods across platforms
27
282. **Follow best practices**
29 - Use SDK built-in authentication features (Web)
30 - Understand natural login-free feature (Mini Program)
31 - Configure appropriate database permissions
32 - Use cloud functions for cross-collection operations
33
343. **Use correct SDKs and APIs**
35 - Different platforms require different SDKs for data models
36 - MySQL data models must use models SDK, not collection API
37 - Use `envQuery` tool to get environment ID
38
39---
40
41# CloudBase Platform Knowledge
42
43## Storage and Hosting
44
451. **Static Hosting vs Cloud Storage**:
46 - CloudBase static hosting and cloud storage are two different buckets
47 - Generally, publicly accessible files can be stored in static hosting, which provides a public web address
48 - Static hosting supports custom domain configuration (requires console operation)
49 - Cloud storage is suitable for files with privacy requirements, can get temporary access addresses via temporary file URLs
50
512. **Static Hosting Domain**:
52 - CloudBase static hosting domain can be obtained via `getWebsiteConfig` tool
53 - Combine with static hosting file paths to construct final access addresses
54 - **Important**: If access address is a directory, it must end with `/`
55
56## Environment and Authentication
57
581. **SDK Initialization**:
59 - CloudBase SDK initialization requires environment ID
60 - Can query environment ID via `envQuery` tool
61 - Then proceed with login, for example using anonymous login
62
63## Authentication Best Practices
64
65**Important: Authentication methods for different platforms are completely different, must strictly distinguish!**
66
67### Web Authentication
68- **Must use SDK built-in authentication**: CloudBase Web SDK provides complete authentication features
69- **Recommended method**: `auth.toDefaultLoginPage()` redirect to default login page
70- **Forbidden behavior**: Do not use cloud functions to implement login authentication logic
71- **User management**: After login, get user information via `auth.getCurrentUser()`
72
73### Mini Program Authentication
74- **Login-free feature**: Mini program CloudBase is naturally login-free, no login flow needed
75- **User identifier**: In cloud functions, get `wxContext.OPENID` via wx-server-sdk
76- **User management**: Manage user data in cloud functions based on openid
77- **Forbidden behavior**: Do not generate login pages or login flow code
78
79## Cloud Functions
80
811. **Node.js Cloud Functions**:
82 - Node.js cloud functions need to include `package.json`, declaring required dependencies
83 - Can use `createFunction` to create functions
84 - Use `updateFunctionCode` to deploy cloud functions
85 - Prioritize cloud dependency installation, do not upload node_modules
86 - `functionRootPath` refers to the parent directory of function directories, e.g., `cloudfunctions` directory
87
88## Database Permissions
89
901. **Permission Model**:
91 - CloudBase database access has permissions
92 - Default basic permissions include:
93 - Only creator can write, everyone can read
94 - Only creator can read/write
95 - Only admin can write, everyone can read
96 - Only admin can read/write
97 - If directly requesting database from web or mini program side, need to configure appropriate database permissions
98 - In cloud functions, there is no permission control by default
99
1002. **Cross-Collection Operations**:
101 - If user has no special requirements, operations involving cross-database collections must be implemented via cloud functions
102
1033. **Cloud Function Optimization**:
104 - If involving cloud functions, while ensuring security, can minimize the number of cloud functions as much as possible
105 - For example: implement one cloud function for client-side requests, implement one cloud function for data initialization
106
107## Data Models
108
1091. **Get Data Model Operation Object**:
110 - **Mini Program**: Need `@cloudbase/wx-cloud-client-sdk`, initialize `const client = initHTTPOverCallFunction(wx.cloud)`, use `client.models`
111 - **Cloud Function**: Need `@cloudbase/node-sdk@3.10+`, initialize `const app = cloudbase.init({env})`, use `app.models`
112 - **Web**: Need `@cloudbase/js-sdk`, initialize `const app = cloudbase.init({env})`, after login use `app.models`
113
1142. **Data Model Query**:
115 - Can call MCP `manageDataModel` tool to:
116 - Query model list
117 - Get model detailed information (including Schema fields)
118 - Get specific models SDK usage documentation
119
1203. **MySQL Data Model Invocation Rules**:
121 - MySQL data models cannot use collection method invocation, must use data model SDK
122 - **Wrong**: `db.collection('model_name').get()`
123 - **Correct**: `app.models.model_name.list({ filter: { where: {} } })`
124 - Use `manageDataModel` tool's `docs` method to get specific SDK usage
125
126## Console Management
127
128After creating/deploying resources, provide corresponding console management page links:
129
1301. **Static Hosting**: https://console.cloud.tencent.com/tcb/hosting
131
1322. **Cloud Function**: https://tcb.cloud.tencent.com/dev?envId=${envId}#/scf/detail?id=${functionName}&NameSpace=${envId}
133
1343. **Database Collection**: https://tcb.cloud.tencent.com/dev?envId=${envId}#/db/doc/collection/${collectionName}
135
1364. **Data Model**: https://tcb.cloud.tencent.com/dev?envId=${envId}#/db/doc/model/${modelName}
137
138**Usage**: After creating corresponding resources, replace variables with actual values, provide to user for management operations.
139