$npx -y skills add TencentCloudBase/cloudbase-skills --skill cloudrun-developmentCloudBase Run backend development rules (Function mode/Container mode). Use this skill when deploying backend services that require long connections, multi-language support, custom environments, or AI agent development.
| 1 | ## Standalone Install Note |
| 2 | |
| 3 | If this environment only installed the current skill, start from the CloudBase main entry and use the published `cloudbase/references/...` paths for sibling skills. |
| 4 | |
| 5 | - CloudBase main entry: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md` |
| 6 | - Current skill raw source: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudrun-development/SKILL.md` |
| 7 | |
| 8 | Keep local `references/...` paths for files that ship with the current skill directory. When this file points to a sibling skill such as `auth-tool` or `web-development`, use the standalone fallback URL shown next to that reference. |
| 9 | |
| 10 | # CloudBase Run Development |
| 11 | |
| 12 | ## Activation Contract |
| 13 | |
| 14 | ### Use this first when |
| 15 | |
| 16 | - The task is to initialize, run, deploy, inspect, or debug a CloudBase Run service. |
| 17 | - The request needs a long-lived HTTP service, SSE, WebSocket, custom system dependencies, or container-style deployment. |
| 18 | - The task is to create or run an Agent service on CloudBase Run. |
| 19 | |
| 20 | ### Read before writing code if |
| 21 | |
| 22 | - You still need to choose between Function mode and Container mode. |
| 23 | - The prompt mentions `queryCloudRun`, `manageCloudRun`, Dockerfile, service domains, or public/private access. |
| 24 | |
| 25 | ### Then also read |
| 26 | |
| 27 | - Cloud functions instead of CloudRun -> `../cloud-functions/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloud-functions/SKILL.md`) |
| 28 | - Agent SDK and AG-UI specifics -> `../cloudbase-agent/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-agent/SKILL.md`) |
| 29 | - Web authentication for browser callers -> `../auth-web/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web/SKILL.md`) |
| 30 | |
| 31 | ### Do NOT use for |
| 32 | |
| 33 | - Simple Event Function or HTTP Function workflows that fit the function model better. |
| 34 | - Frontend-only projects with no backend service. |
| 35 | - Database-schema design tasks. |
| 36 | |
| 37 | ### Common mistakes / gotchas |
| 38 | |
| 39 | - Choosing CloudRun when the request only needs a normal cloud function. |
| 40 | - Forgetting to listen on the platform-provided `PORT`. |
| 41 | - Treating CloudRun as stateful app hosting and storing important state on local disk. |
| 42 | - Assuming local run is available for Container mode. |
| 43 | - Opening public access by default when the scenario only needs private or mini-program internal access. |
| 44 | |
| 45 | ### Minimal checklist |
| 46 | |
| 47 | - Choose Function mode or Container mode explicitly. |
| 48 | - Confirm whether the service should be public, VPC-only, or mini-program internal. |
| 49 | - Keep the service stateless and externalize durable data. |
| 50 | - Use absolute paths for every local project path. |
| 51 | |
| 52 | ## Overview |
| 53 | |
| 54 | Use CloudBase Run when the task needs a deployed backend service rather than a short-lived serverless function. |
| 55 | |
| 56 | ### When CloudRun is a better fit |
| 57 | |
| 58 | - Long connections: WebSocket, SSE, server push |
| 59 | - Long-running request handling or persistent service processes |
| 60 | - Custom runtime environments or system libraries |
| 61 | - Arbitrary languages or frameworks |
| 62 | - Stable external service endpoints with elastic scaling |
| 63 | - AI Agent deployment on Function mode CloudRun |
| 64 | |
| 65 | ## Mode selection |
| 66 | |
| 67 | | Dimension | Function mode | Container mode | |
| 68 | | --- | --- | --- | |
| 69 | | Best for | Fast start, Node.js service patterns, built-in framework, Agent flows | Existing containers, arbitrary runtimes, custom system dependencies | |
| 70 | | Port model | Framework-managed local mode, deployed service still follows platform rules | App must listen on injected `PORT` | |
| 71 | | Dockerfile | Not required | Required | |
| 72 | | Local run through tools | Supported | Not supported | |
| 73 | | Typical use | Streaming APIs, low-latency backend, Agent service | Custom language stack, migrated container app | |
| 74 | |
| 75 | ## How to use this skill (for a coding agent) |
| 76 | |
| 77 | 1. **Choose mode first** |
| 78 | - Function mode -> quickest path for HTTP/SSE/WebSocket or Agent scenarios |
| 79 | - Container mode -> use when Docker/custom runtime is a real requirement |
| 80 | |
| 81 | 2. **Follow mandatory runtime rules** |
| 82 | - Listen on `PORT` |
| 83 | - Keep the service stateless |
| 84 | - Put durable data in DB/storage/cache |
| 85 | - Keep dependencies and image size small |
| 86 | - Respect resource ratio guidance: `Mem = 2 × CPU` |
| 87 | |
| 88 | 3. **Use the correct tools** |
| 89 | - Read operations -> `queryCloudRun` |
| 90 | - Write operations -> `manageCloudRun` |
| 91 | - Delete requires explicit confirmation and `force: true` |
| 92 | - Always use absolute `targetPath` |
| 93 | |
| 94 | 4. **Follow the deployment sequence** |
| 95 | - Initialize or download code |
| 96 | - For Container mode, verify Dockerfile |
| 97 | - Local run when available |
| 98 | - Confi |