Install
$ agentstack add skill-tencentcloudbase-cloudbase-skills-cloud-functions ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ● Network access Used
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Standalone Install Note
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
- CloudBase main entry:
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md - Current skill raw source:
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloud-functions/SKILL.md
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.
Cross-cutting protocols (required for public exposure and code changes):
- 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 - Deployment Gate:
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-platform/references/protocols/deployment-gate.md
Cloud Functions Development
Activation Contract
Use this first when
- The task is to create, update, deploy, inspect, or debug a CloudBase Event Function or HTTP Function that serves application runtime logic.
- The request mentions function runtime, function logs,
scf_bootstrap, function triggers, or function gateway exposure.
Read before writing code if
- You still need to decide between Event Function and HTTP Function.
- The task mentions
manageFunctions,queryFunctions,manageGateway, or legacy function-tool names. - The task might require
callCloudApias a fallback for logs or gateway setup.
Then also read
- Detailed reference routing ->
./references.md - 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) - 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) - 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) - 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) - 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)
Do NOT use for
- CloudRun container services.
- Web authentication UI implementation.
- Database-schema design or general data-model work.
- CloudBase official platform API clients or raw HTTP integrations that only consume platform endpoints.
- Creating Integration Center instances through guessed APIs. For WeChat Pay or Official Account generated functions, use
cloudbase-wechat-integrationfor the business contract and this skill only for function operations. - 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/updateonly for confirmed NoSQL collections, andapp.rdb().from(...)for CloudBase PG tables. Functions add deployment complexity, CORS configuration, and HTTP gateway binding that the SDK eliminates entirely.
Common mistakes / gotchas
- Picking the wrong function type and trying to compensate later.
- Confusing official CloudBase API client work with building your own HTTP function.
- Mixing Event Function code shape (
exports.main(event, context)) with HTTP Function code shape (req/reson port9000). - 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.
- Assuming
db.collection("name").add(...)will create a missing document-database collection automatically. Collection creation is a separate management step. - Forgetting that runtime cannot be changed after creation.
- Using cloud functions as the first answer for Web login.
- Forgetting that HTTP Functions must ship
scf_bootstrap, listen on port9000, and include dependencies. - Forgetting to configure function security rules after creating an HTTP Function. Default rules reject anonymous callers with
EXCEED_AUTHORITY. Note: anonymous login is disabled by default for new environments — if the function needs public access without authentication, configure the security rule to allow all callers rather than relying on anonymous login. - Mismatching the
scf_bootstrapNode.js binary path with the function runtime (e.g. using/var/lang/node18/bin/nodebut settingruntime: "Nodejs16.13"). - For Custom Image HTTP Functions: forgetting that TCR, the CloudApp build, and SCF must be in the same region; using
:latestinstead of a unique tag; or confusing the request-driven port-9000image model with a long-lived CloudRun container that listens on the injectedPORT. - Assuming MCP covers the whole image pipeline.
manageFunctionscovers SCF image deploy (Stage B) viaruntime: "CustomImage"+imageConfig, but the CloudApp custom build → TCR push (Stage A) is a raw Tencent Cloud API path — confirm action names and parameters from official docs before anycallCloudApifallback. - Making code or configuration changes without first following the Change Safety Protocol (
cloudbase-platform/references/protocols/change-safety-protocol.md). - Exposing functions publicly or deploying without first completing the checks in
cloudbase-platform/references/protocols/deployment-gate.md.
Minimal checklist
- Read [Cloud Functions Execution Checklist](checklist.md) before deployment or runtime changes.
- Decide whether the task is Event Function, HTTP Function, or actually CloudRun.
- Pick the detailed reference file in [references.md](references.md) before writing implementation code.
Overview
Use this skill when developing, deploying, and operating CloudBase cloud functions. CloudBase has two different programming models:
- Event Functions: serverless handlers driven by SDK calls, timers, and other events.
- HTTP Functions: standard web services for HTTP endpoints, SSE, or WebSocket workloads. By default they run on a managed runtime (
scf_bootstrap+ zip); when they need custom system libraries or an arbitrary runtime they can instead run from a container image (Runtime: CustomImage, deployed from TCR — see./references/http-functions-custom-image.md).
Writing mode at a glance
- If the request is for SDK calls, timers, or event-driven workflows, write an Event Function with
exports.main = async (event, context) => {}. - If the request is for REST APIs, browser-facing endpoints, SSE, or WebSocket, write an HTTP Function with
req/reson port9000. - For Node.js HTTP Functions, default to the native
httpmodule unless the user explicitly asks for Express, Koa, NestJS, or another framework. - If the HTTP Function needs custom system libraries or an arbitrary runtime but should still be SCF request-driven and scale to zero, deploy it as a Custom Image HTTP Function (
Runtime: CustomImage) from a TCR image. The container still listens on the fixed port9000. See./references/http-functions-custom-image.md. This is distinct from a CloudRun container, which listens on the injectedPORTand runs long-lived. - If the user mentions HTTP access for an existing Event Function, keep the Event Function code shape and add gateway access separately.
HTTP Function authoring contract
Use these rules whenever you are writing the function code itself:
- Do not write an HTTP Function as
exports.main(event, context). That is the Event Function contract. - Treat the function as a standard web server process that must listen on port
9000. - With Node.js, prefer
http.createServer((req, res) => { ... })by default so the runtime contract stays explicit. - With the Node.js native
httpmodule, do not assume Express-style helpers exist.req.body,req.query, andreq.paramsare not provided for you. - For Node.js HTTP Functions, choose one module system up front and keep it consistent. Default to CommonJS for simple functions (
require(...), no"type": "module"inpackage.json) unless you explicitly want ES Modules. - If you do choose ES Modules (
"type": "module"+import ...), do not mix in CommonJS-only globals or APIs such asrequire(...),module.exports, or bare__dirname. In ESM, derive file paths fromimport.meta.urlwithfileURLToPath(...)only when needed. - With the native
httpmodule, parsereq.urlyourself withnew URL(...), collect the request body from the stream, and only then callJSON.parse. Empty bodies should be handled explicitly instead of assuming JSON is always present. - Return responses explicitly with
res.writeHead(...)andres.end(...), includingContent-Typesuch asapplication/json; charset=utf-8for JSON APIs. - Handle CORS headers. Browsers block cross-origin requests without proper CORS headers. Default to allowing all origins for simple APIs:
- Respond to
OPTIONSpreflight with200and CORS headers - Include
Access-Control-Allow-Origin: *(or specific origin) on all responses - Include
Access-Control-Allow-Methods: GET, POST, OPTIONSas needed - Include
Access-Control-Allow-Headers: Content-Typefor JSON requests - Keep routing and method handling explicit. Unknown paths should return
404, and known paths with unsupported methods should normally return405. - Keep gateway setup and security-rule changes separate from the runtime code. They affect access, not the HTTP Function programming model.
- Do not add HTTP access service configuration when the task is only to create an HTTP Function itself. Gateway paths or custom domains are separate access-layer work; public invocation requirements should be handled through the function security rule workflow (note: anonymous login is disabled by default).
Quick decision table
| Question | Choose | | --- | --- | | Triggered by SDK calls or timers? | Event Function | | Needs browser-facing HTTP endpoint? | HTTP Function | | Needs SSE or WebSocket service? | HTTP Function | | Needs custom system libraries / arbitrary runtime, but still SCF request-driven + scale-to-zero? | HTTP Function with Runtime: CustomImage (deploy from a TCR image) | | Needs long-lived container runtime or custom system environment? | CloudRun | | Only needs HTTP access for an existing Event Function? | Event Function + gateway access |
How to use this skill (for a coding agent)
- Choose the correct runtime model first
- Event Function ->
exports.main(event, context) - HTTP Function -> web server on port
9000 - If the requirement is really a container service, reroute to CloudRun early
- Use the converged MCP entrances
- Reads ->
queryFunctions,queryGateway - Writes ->
manageFunctions,manageGateway - Translate legacy names before acting rather than copying them literally
- Write code and deploy, do not stop at local files
- Use
manageFunctions(action="createFunction")for creation - Use
manageFunctions(action="updateFunctionCode")for code updates - Use
manageFunctions(action="updateFunctionConfig")for config updates (timeout, memorySize, envVariables) - For a Custom Image HTTP Function, call
manageFunctions(action="createFunction")withfunc.runtime="CustomImage"andimageConfig(imageUriwith tag;registryIdfor enterprise TCR); iterate later withmanageFunctions(action="updateFunctionCode")+imageConfig. NofunctionRootPathis needed because the code lives in the image. See./references/http-functions-custom-image.md. - Keep
functionRootPathas the directory that directly contains function folders (e.g.,cloudfunctions/orfunctions/), NOT the project root and NOT the function subdirectory itself - Prefer MCP tools over CLI — when MCP tools are available, use
manageFunctionsandqueryFunctionsinstead of CLI commands - Do NOT assume CLI is available from task wording alone — if the available capabilities only include MCP tools, use MCP tools exclusively
- For batch updates (multiple functions), call
manageFunctions(action="updateFunctionConfig")individually for each function — MCP does not have a--allbatch parameter like CLI
- Prefer doc-first fallbacks
- If a task falls back to
callCloudApi, first check the official docs or knowledge-base entry for that action - Confirm the exact action name and parameter contract before calling it
- Do not guess raw cloud API payloads from memory
- Read the right detailed reference
- Event Function details ->
./references/event-functions.md - HTTP Function details ->
./references/http-functions.md - HTTP Function from a container image (
Runtime: CustomImage, TCR image pipeline) ->./references/http-functions-custom-image.md - Logs, gateway, env vars, and legacy mappings ->
./references/operations-and-config.md
Database write reminder
- If a function will write to CloudBase document database, create the target collection first through console or management tooling.
db.collection("feedback").add(...)only inserts into an existing collection; it does not auto-createfeedbackwhen absent.- If the product requirement says "create when missing", implement that as an explicit collection-management step before the first write instead of assuming the runtime write call will provision it.
Function types comparison
| Feature | Event Function | HTTP Function | | --- | --- | --- | | Primary trigger | SDK call, timer, event | HTTP request | | Entry shape | exports.main(event, context) | web server with req / res | | Port | No port | Must listen on 9000 | | scf_bootstrap | Not required | Required | | Dependencies | Auto-installed from package.json | Must be packaged with function code | | Best for | serverless handlers, scheduled jobs | APIs, SSE, WebSocket, browser-facing services |
Minimal code skeletons
Event Function hello world
cloudfunctions/hello-event/index.js
exports.main = async (event, context) => {
return {
ok: true,
message: "hello from event function",
event,
};
};
cloudfunctions/hello-event/package.json
{
"name": "hello-event",
"version": "1.0.0"
}
HTTP Function hello world
cloudfunctions/hello-http/index.js
const http = require("http");
const { URL } = require("url");
// CORS headers — default to * for simple cross-origin APIs
const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
};
function sendJson(res, statusCode, data) {
res.writeHead(statusCode, {
"Content-Type": "application/json; charset=utf-8",
...CORS_HEADERS,
});
res.end(JSON.stringify(data));
}
function sendOptions(res) {
res.writeHead(204, CORS_HEADERS);
res.end();
}
function readJsonBody(req) {
return new Promise((resolve, reject) => {
let raw = "";
req.on("data", (chunk) =>
…
## Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- **Author:** [TencentCloudBase](https://github.com/TencentCloudBase)
- **Source:** [TencentCloudBase/cloudbase-skills](https://github.com/TencentCloudBase/cloudbase-skills)
- **License:** MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.