// CloudBase 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.
| name | cloudrun-development |
| description | CloudBase 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. |
| alwaysApply | false |
Use this skill for CloudBase Run backend service development when you need:
callContainer internal direct connectionDo NOT use for:
Choose the right mode
Follow mandatory requirements
PORT environment variable (real port in container)Mem = 2 × CPU (e.g., 0.25 vCPU → 0.5 GB)Use tools correctly
queryCloudRun (list, detail, templates)manageCloudRun (init, download, run, deploy, delete, createAgent)targetPathforce: true for delete operationsFollow the workflow
A concise guide for AI assistants and engineering collaboration, providing "when to use, how to use" rules and tool workflows.
callContainer internal direct connection| Dimension | Function Mode | Container Mode |
|---|---|---|
| Language/Framework | Node.js (via @cloudbase/functions-framework) | Any language/runtime (Java/Go/PHP/.NET/Python/Node.js, etc.) |
| Runtime | Function framework loads functions (Runtime) | Docker image starts process |
| Port | Fixed 3000 | Application listens on PORT (injected by platform during deployment) |
| Dockerfile | Not required | Required (and must pass local build) |
| Local Running | Supported (built-in tools) | Not supported (recommend using Docker for debugging) |
| Typical Scenarios | WebSocket/SSE/streaming responses, forms/files, low latency, multiple functions per instance, shared memory | Arbitrary system dependencies/languages, migrating existing containerized applications |
PORT environment variable (real port in container)Mem = 2 × CPU (e.g., 0.25 vCPU → 0.5 GB)queryCloudRun):
list: What services do I have? Can filter by name/typedetail: Current configuration, version, access address of a servicetemplates: Ready-to-use starter templatesmanageCloudRun):
init: Create local project (optional template)download: Pull existing service code to localrun: Run locally (Function mode only, supports normal function and Agent mode)deploy: Deploy local code to CloudRundelete: Delete service (requires explicit confirmation)createAgent: Create AI agent (based on Function mode CloudRun)targetPath: Local directory (must be absolute path)serverConfig: Deployment parameters (CPU/Mem/instance count/access type/environment variables, etc.)runOptions: Local running port and temporary environment variables (Function mode), supports runMode: 'normal' | 'agent'agentConfig: Agent configuration (agentName, botTag, description, template)force: true, otherwise it won't executeChoose mode
Initialize local project
init (both Function mode and Container mode can start from templates)FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node","server.js"]
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt --no-cache-dir
COPY . .
ENV PORT=3000
EXPOSE 3000
CMD ["python","app.py"]
Local running (Function mode only)
npm run dev/start or entry file via runConfigure access
OpenAccessTypes (WEB/VPC/PRIVATE) as needed; configure security domain and authentication for Web scenariosDeploy
deployVerify
detail to confirm access address and configuration meet expectations{ "name": "queryCloudRun", "arguments": { "action": "templates" } }
{ "name": "queryCloudRun", "arguments": { "action": "detail", "detailServerName": "my-svc" } }
{ "name": "manageCloudRun", "arguments": { "action": "init", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc", "template": "helloworld" } }
{ "name": "manageCloudRun", "arguments": { "action": "download", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc" } }
{ "name": "manageCloudRun", "arguments": { "action": "run", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc", "runOptions": { "port": 3000 } } }
{ "name": "manageCloudRun", "arguments": { "action": "deploy", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc", "serverConfig": { "OpenAccessTypes": ["WEB"], "Cpu": 0.5, "Mem": 1, "MinNum": 0, "MaxNum": 5 } } }
{ "name": "manageCloudRun", "arguments": { "action": "createAgent", "serverName": "my-agent", "targetPath": "/abs/ws/agents", "agentConfig": { "agentName": "MyAgent", "botTag": "demo", "description": "My agent", "template": "blank" } } }
{ "name": "manageCloudRun", "arguments": { "action": "run", "serverName": "my-agent", "targetPath": "/abs/ws/agents/my-agent", "runOptions": { "port": 3000, "runMode": "agent" } } }
callContainer, reduce public network exposurequeryCloudRun.detail to verify configuration and accessibility before and after deployment@cloudbase/aiagent-framework, supports SSE streaming responses, BotId format is ibot-{name}-{tag}package.json dev/start or entry index.js|app.js|server.js@cloudbase/aiagent-framework dependency, BotId format, SSE response format@cloudbase/functions-framework) + function code, making container service development as simple as writing cloud functions@cloudbase/aiagent-framework, supports SSE streaming responses and personalized AI applicationsmanageCloudRun → run); deploy using manageCloudRun → deploy; query using queryCloudRuncurl -L "https://<your-service-domain>"
// app.js (ensure wx.cloud.init() is called)
const res = await wx.cloud.callContainer({
config: { env: "<envId>" },
path: "/",
method: "GET",
header: { "X-WX-SERVICE": "<serviceName>" }
});
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({ env: "<envId>" });
await app.auth().toDefaultLoginPage({});
const res = await app.callContainer({
name: "<serviceName>", method: "POST", path: "/api",
header: { "Content-Type": "application/json" },
data: { key: "value" }
});
// Web JS SDK initialization MUST be synchronous:
// - Always use top-level import cloudbase from "@cloudbase/js-sdk";
// - Do NOT use dynamic imports like import("@cloudbase/js-sdk") or async wrappers such as initCloudBase() with internal initPromise
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({});
const res = await app.callContainer({
name: "<serviceName>", method: "GET", path: "/health",
timeout: 5000
});