$npx -y skills add TencentCloudBase/cloudbase-skills --skill cloud-functionsCloudBase function runtime guide for building, deploying, and debugging your own Event Functions or HTTP Functions. This skill should be used when users need application runtime code on CloudBase, not when they are merely calling CloudBase official platform APIs.
| 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/cloud-functions/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 | **Cross-cutting protocols** (required for public exposure and code changes): |
| 11 | - Change Safety Protocol: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-platform/references/protocols/change-safety-protocol.md` |
| 12 | - Deployment Gate: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-platform/references/protocols/deployment-gate.md` |
| 13 | |
| 14 | # Cloud Functions Development |
| 15 | |
| 16 | ## Activation Contract |
| 17 | |
| 18 | ### Use this first when |
| 19 | |
| 20 | - The task is to create, update, deploy, inspect, or debug a CloudBase Event Function or HTTP Function that serves application runtime logic. |
| 21 | - The request mentions function runtime, function logs, `scf_bootstrap`, function triggers, or function gateway exposure. |
| 22 | |
| 23 | ### Read before writing code if |
| 24 | |
| 25 | - You still need to decide between Event Function and HTTP Function. |
| 26 | - The task mentions `manageFunctions`, `queryFunctions`, `manageGateway`, or legacy function-tool names. |
| 27 | - The task might require `callCloudApi` as a fallback for logs or gateway setup. |
| 28 | |
| 29 | ### Then also read |
| 30 | |
| 31 | - Detailed reference routing -> `./references.md` |
| 32 | - Auth setup or provider-related backend work -> `../auth-tool/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-tool/SKILL.md`) |
| 33 | - CloudBase Integration Center generated WeChat Pay or Official Account functions -> `../cloudbase-wechat-integration/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-wechat-integration/SKILL.md`; official docs: `https://docs.cloudbase.net/integration/introduce/index.md`) |
| 34 | - AI in functions -> `../ai-model-nodejs/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/ai-model-nodejs/SKILL.md`) |
| 35 | - Long-lived container services or Agent runtimes -> `../cloudrun-development/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudrun-development/SKILL.md`) |
| 36 | - Calling CloudBase official platform APIs from a client or script -> `../http-api/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/http-api/SKILL.md`) |
| 37 | |
| 38 | ### Do NOT use for |
| 39 | |
| 40 | - CloudRun container services. |
| 41 | - Web authentication UI implementation. |
| 42 | - Database-schema design or general data-model work. |
| 43 | - CloudBase official platform API clients or raw HTTP integrations that only consume platform endpoints. |
| 44 | - Creating Integration Center instances through guessed APIs. For WeChat Pay or Official Account generated functions, use `cloudbase-wechat-integration` for the business contract and this skill only for function operations. |
| 45 | - **Tasks that the CloudBase JS SDK can handle directly** — simple data reads/writes, leaderboards, file uploads, real-time queries. Reach for the matching SDK surface before writing a function: `db.collection(...).get/add/update` only for confirmed NoSQL collections, and `app.rdb().from(...)` for CloudBase PG tables. Functions add deployment complexity, CORS configuration, and HTTP gateway binding that the SDK eliminates entirely. |
| 46 | |
| 47 | ### Common mistakes / gotchas |
| 48 | |
| 49 | - Picking the wrong function type and trying to compensate later. |
| 50 | - Confusing official CloudBase API client work with building your own HTTP function. |
| 51 | - Mixing Event Function code shape (`exports.main(event, context)`) with HTTP Function code shape (`req` / `res` on port `9000`). |
| 52 | - Treating HTTP Access as the implementation model for HTTP Functions. HTTP Access is a gateway configuration for Event Functions, not the HTTP Function runtime model. |
| 53 | - Assuming `db.collection("name").add(...)` will create a missing document-database collection automatically. Collection creation |