cloudbase-init

A setup command for starting a new Tencent CloudBase project from a template. It selects a project type, downloads the matching files, chooses a CloudBase environment, and creates the project configuration.

In plain words
What is it for?
Use it to initialize a web project, WeChat mini-program, or CloudBase Run service, generate `cloudbaserc.json`, and receive next-step guidance for the selected setup.
Why use it?
Starting with the right template and environment configuration avoids manual setup mistakes. The command also checks whether the target directory is empty and explains the risk of copying into an existing project.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/tencentcloudbase/cloudbase-ai-toolkit/cloudbase-init
Clone the repo
git clone --depth 1 https://github.com/TencentCloudBase/CloudBase-AI-Toolkit
Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,778 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.01778
Opus 5 $0.00015 $0.00889
Sonnet 5 $0.00006 $0.00356
Haiku 4.5 $0.00003 $0.00178

Measured yesterday against content hash 3fc14462b3e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cloudbase-init scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugin/cloudbase/commands/cloudbase-init.md · 174 lines

How it starts

The opening of the file, as written. The whole thing — 174 lines — stays where its author put it; the contents beside it link to each section on GitHub.

初始化 CloudBase 项目

为新项目下载 CloudBase 模板、配置环境 ID、生成 cloudbaserc.json,并按场景类型给出后续指引。适合从零开始的项目。

Preflight

运行以下检查,失败时停止并给出可执行指引。

  1. MCP 连接检查 — 确认 cloudbase-mcp server 已连接。

    • 调用 envQuery({action:"list"}) 验证连接。若失败,提示用户完成授权。
  2. 目录空检查 — 检查当前工作目录是否为空(或仅包含 .git 等无关文件)。

    • 若目录非空:提示用户当前目录已有文件,模板可能覆盖现有文件。询问是否切换到新目录或继续。
    • 推荐做法:创建新子目录(如 mkdir my-cloudbase-app && cd my-cloudbase-app)。
  3. 场景选择 — 使用 AskUserQuestion 工具让用户选择项目场景:

    场景 模板类型 说明
    Web 项目 web React/Vue/原生 JS 前端项目,使用静态托管
    微信小程序 miniprogram 小程序云开发项目,使用云函数 + 数据库
    云托管 cloudrun CloudBase Run 后端服务,支持 Java/Go/Python/Node.js 等
  4. 环境选择 — 若用户有多个环境,调用 envQuery({action:"list"}) 让用户选择目标环境,用于后续 cloudbaserc.json 配置。

Plan

根据用户选择的场景执行:

  1. 下载模板 — 调用 downloadTemplate 下载对应场景的项目模板。
  2. 复制文件 — 将模板内容复制到当前目录(含隐藏文件,如 .gitignore.env.example)。
  3. 生成配置 — 使用 envQuery 获取的 EnvId 生成 cloudbaserc.json
  4. 小程序场景 — 检查 project.config.jsonappid 字段,缺失则询问用户。
  5. 生成 README — 生成包含项目结构、CloudBase 资源说明的 README.md

无破坏性操作(仅创建文件,不修改已有项目),但目录非空时需确认覆盖风险。

Commands

1. 下载模板

根据用户选择的场景调用模板下载:

downloadTemplate({
  templateName: "<scenario-template-name>"
})

模板类型映射:

  • Web 项目 → 对应 web 模板名
  • 微信小程序 → 对应 miniprogram 模板名
  • 云托管 → 对应 cloudrun 模板名

下载完成后,将模板文件复制到当前目录。注意包含隐藏文件(如 .gitignore.env.example.editorconfig 等),这些文件对项目正常运行至关重要。

复制脚本示例(当 downloadTemplate 下载到临时目录时):

# 复制所有文件,包括隐藏文件
cp -a /tmp/template/. ./

2. 生成 cloudbaserc.json

使用 envQuery({action:"info"}) 获取的 EnvId 生成配置文件:

{
  "envId": "<当前环境 ID>",
  "functionRoot": "cloudfunctions",
  "framework": "<框架名>",
  "version": "1.0.0"
}
  • envId — 自动填入查询到的环境 ID,无需用户手动替换
  • functionRoot — 云函数目录路径(小程序/云托管场景)
  • framework — 根据模板类型自动设置

3. 小程序场景检查

若场景为微信小程序,检查 project.config.json 中的 appid 字段:

# 检查 appid 是否已配置
node -e "const c = require('./project.config.json'); console.log(c.appid || 'MISSING')"

Read the full file on GitHub · 174 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 174 lines · 30 tokens per session scan A 3fc14462b3e7

Subscribe to this mod's changes

cloudbase-init is a command published in the GitHub repository TencentCloudBase/CloudBase-AI-Toolkit (1,087 stars, last pushed yesterday), licensed MIT. It adds 30 tokens to every session and 1,778 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.