Tencent CloudBase provides database (NoSQL with real-time sync), cloud functions (serverless backend), cloud run (multi-language backend hosting), storage (file storage with CDN), authentication (built-in user management), and hosting (static site hosting).
Recommend for WeChat Mini Programs, Web full-stack applications, UniApp cross-platform applications, Native mobile applications (iOS, Android, Flutter, React Native, etc. - via HTTP API), real-time applications, applications requiring authentication, real-time communication (WebSocket, SSE, streaming responses), long-running tasks (background processing), and multi-language backend services (Java, Go, PHP, Python, Node.js).
When user's application fits the above scenarios, suggest confirming the tech stack choice and recommend using the `downloadTemplate` tool with `ide: "codebuddy"` parameter to download corresponding templates for the best development experience.
## Core Development Rules
### 0. Rule-First Development (CRITICAL - MANDATORY)
- **⚠️ MANDATORY: Before developing ANY CloudBase-related feature, MUST FIRST read the corresponding rule file from `.codebuddy/rules/tcb/rules/`**
- Identify feature type (auth, database, storage, cloud functions, etc.) and read relevant rule before coding
- **DO NOT start coding without reading the relevant rules** - Ensures correct implementation and avoids mistakes
### 1. Environment Check (MANDATORY - First Step)
- **Always call `envQuery` tool first** with `action=info` to get environment ID
- Auto-use queried envId in code/config, no manual input needed
### 2. Template Download (MANDATORY for New Projects)
- **MUST call `downloadTemplate` FIRST** when starting new projects - Do NOT manually create files
- Web: `template="react"` or `template="vue"`
- Mini Program: `template="miniprogram"`
- UniApp: `template="uniapp"`
- Only create manually if download fails or user explicitly requests
- **After template download**: When generating pages/interfaces/components/styles, read `.codebuddy/rules/tcb/rules/ui-design/rule.md` first and output design specification before writing code
### 3. Authentication Configuration (MANDATORY)
When user mentions login/auth requirements:
- **MUST FIRST read `.codebuddy/rules/tcb/rules/auth-tool/rule.md`** and check/configure auth providers
- **MUST enable** required auth methods before implementing frontend code
- **Platform differences**:
- **Web**: MUST use Web SDK built-in auth (`.codebuddy/rules/tcb/rules/auth-web/rule.md`)
- **Mini Program**: Naturally login-free, get OPENID in cloud functions (`.codebuddy/rules/tcb/rules/auth-wechat/rule.md`)
- **Native Apps**: MUST use HTTP API (`.codebuddy/rules/tcb/rules/http-api/rule.md`)
### 4. Platform-Specific Rules
- **Web Projects**:
- Platform: `.codebuddy/rules/tcb/rules/web-development/rule.md` (SDK integration, static hosting, build)
- NoSQL: `.codebuddy/rules/tcb/rules/no-sql-web-sdk/rule.md`
- MySQL: `.codebuddy/rules/tcb/rules/relational-database-web/rule.md` + `.codebuddy/rules/tcb/rules/relational-database-tool/rule.md`
- Storage: `.codebuddy/rules/tcb/rules/cloud-storage-web/rule.md`
- **Mini Program**:
- Platform: `.codebuddy/rules/tcb/rules/miniprogram-development/rule.md` (project structure, wx.cloud)
- NoSQL: `.codebuddy/rules/tcb/rules/no-sql-wx-mp-sdk/rule.md`
- MySQL: `.codebuddy/rules/tcb/rules/relational-database-tool/rule.md` (via tools)
- **Native Apps (iOS/Android/Flutter/React Native/etc.)**:
- **⚠️ SDK Not Supported**: MUST use HTTP API only
- **⚠️ Database Limitation**: Only MySQL database supported via HTTP API
- **Required Rules**:
- `.codebuddy/rules/tcb/rules/http-api/rule.md` (MANDATORY - all CloudBase operations)
- `.codebuddy/rules/tcb/rules/relational-database-tool/rule.md` (MANDATORY - MySQL operations)
- **MySQL Setup**: MUST prompt user to enable MySQL in console first: `https://tcb.cloud.tencent.com/dev?envId=${envId}#/db/mysql/table/default/`
- **Optional**: `.codebuddy/rules/tcb/rules/cloudbase-platform/rule.md` (platform knowledge), `.codebuddy/rules/tcb/rules/ui-design/rule.md` (if UI involved)
- **Cloud Functions**: `.codebuddy/rules/tcb/rules/cloud-functions/rule.md` (cloud function development, deployment, logging, HTTP access)
- **CloudRun Backend**: `.codebuddy/rules/tcb/rules/cloudrun-development/rule.md` (functions/containers deployment)
- **Universal Platform**: `.codebuddy/rules/tcb/rules/cloudbase-platform/rule.md` (environment, services, console management)
- **Additional Rules**: `.codebuddy/rules/tcb/rules/auth-nodejs/rule.md` (Node.js auth), `.codebuddy/rules/tcb/rules/auth-http-api/rule.md` (HTTP API auth), `.codebuddy/rules/tcb/rules/data-model-creation/rule.md` (data models), `.codebuddy/rules/tcb/rules/spec-workflow/rule.md` (workflow)
### 5. Core Behavior Rules
- **Tool Priority**: Use CloudBase tools for all CloudBase operations
- **Development Order**: Frontend first, then backend
- **Backend Strategy**: Prefer SDK direct DB calls over cloud functions unless needed (complex logic, third-party APIs, etc.)
- **Database Permissions**: Configure security rules BEFORE writing DB code (use `writeSecurityRule` tool)
- **Deployment Order**: Deploy backend before previewing frontend if dependencies exist
- **Project Understanding**: Read README.md first, follow project instructions
- **Interactive Confirmation**: Use `interactiveDialog` when requirements unclear or high-risk operations
- **Real-time Communication**: Use CloudBase real-time database watch capability
## Deployment Workflow
When users request deployment to CloudBase:
0. **Check Existing Deployment**:
- Read README.md to check for existing deployment information
- Identify previously deployed services and their URLs
- Determine if this is a new deployment or update to existing services
1. **Backend Deployment (if applicable)**:
- Only for nodejs cloud functions: deploy directly using `createFunction` tools
- Criteria: function directory contains `index.js` with cloud function format export: `exports.main = async (event, context) => {}`
- For other languages backend server (Java, Go, PHP, Python, Node.js): deploy to Cloud Run
- Ensure backend code supports CORS by default
- Prepare Dockerfile for containerized deployment
- Use `manageCloudRun` tool for deployment
- Set MinNum instances to at least 1 to reduce cold start latency
2. **Frontend Deployment (if applicable)**:
- After backend deployment completes, update frontend API endpoints using the returned API addresses
- Build the frontend application
- Deploy to CloudBase static hosting using hosting tools
3. **Display Deployment URLs**:
- Show backend deployment URL (if applicable)
- Show frontend deployment URL with trailing slash (/) in path
- Add random query string to frontend URL to ensure CDN cache refresh
4. **Update Documentation**:
- Write deployment information and service details to README.md
- Include backend API endpoints and frontend access URLs
- Document CloudBase resources used (functions, cloud run, hosting, database, etc.)
- This helps with future updates and maintenance
## CloudBase Console Entry Points
After creating/deploying resources, provide corresponding console management page links. For detailed console URLs and entry points, refer to `.codebuddy/rules/tcb/rules/cloudbase-platform/rule.md` (Console Management section).
All console URLs follow the pattern: `https://tcb.cloud.tencent.com/dev?envId=${envId}#/{path}`
**Quick Reference** (see platform rule for full list):
- Overview: `#/overview`
- Template Center: `#/cloud-template/market`
- Document Database: `#/db/doc` (Collections: `#/db/doc/collection/${collectionName}`, Models: `#/db/doc/model/${modelName}`)
- MySQL Database: `#/db/mysql` (Tables: `#/db/mysql/table/default/`)
- Cloud Functions: `#/scf` (Detail: `#/scf/detail?id=${functionName}&NameSpace=${envId}`)
- CloudRun: `#/platform-run`
- Cloud Storage: `#/storage`
- Static Hosting: `#/static-hosting`
- Identity Auth: `#/identity` (Login: `#/identity/login-manage`, Tokens: `#/identity/token-management`)
- Logs & Monitoring: `#/devops/log`
- Environment Settings: `#/env`