Skip to content

Commit 1dd3da4

Browse files
chore: sync allinone skill from CloudBase-AI-ToolKit
1 parent 27c67bd commit 1dd3da4

26 files changed

Lines changed: 466 additions & 52 deletions

File tree

skills/cloudbase/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Follow relative `references/...` paths from the current skill. If MCP is unavail
7171

7272
- After 2–3 failed attempts on the same path, stop and reroute (platform skill, runtime, auth domain, permission model, SDK boundary).
7373
- Always specify `EnvId` explicitly; do not rely on CLI-selected or implicit env state.
74-
- When the environment identifier is an alias, nickname, or other short form, **do not pass it directly** to `auth.set_env`, SDK init, console URLs, or generated config. First resolve it to the canonical full `EnvId` with `envQuery(action=list, alias=..., aliasExact=true)`. If multiple environments match or no exact alias exists, stop and clarify with the user.
74+
- When the environment identifier is an alias, nickname, or other short form, **do not pass it directly** to `auth.set_env`, SDK init, console URLs, or generated config. First resolve it to the canonical full `EnvId` with `queryEnv(action=list, alias=..., aliasExact=true)`. If multiple environments match or no exact alias exists, stop and clarify with the user.
7575
- When writing MCP/tool results to a file, pass serialized text (`JSON.stringify(result, null, 2)`), not raw objects. If a write tool says `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text, and make sure the retried call actually passes the serialized string rather than the original object.
7676
- Keep scenario-specific pitfalls in child skills — do not expand this entry file.
7777
- **First frontend deploy must use `manageApps(action="createApp", ...)`.** `manageHosting` is only for incremental updates of projects originally deployed via hosting.
@@ -97,6 +97,7 @@ These rules override convenience. Full rationale lives in `web-development`.
9797
| WeChat mini program + CloudBase | `miniprogram-development` | `auth-wechat-miniprogram`, `cloudbase-document-database-in-wechat-miniprogram` | `auth-web-cloudbase`, `web-development` | Whether the project really uses CloudBase / `wx.cloud` |
9898
| Native App / Flutter / React Native | `http-api-cloudbase` | `auth-tool-cloudbase`, `relational-database-mcp-cloudbase` | `auth-web-cloudbase`, `cloudbase-document-database-web-sdk`, `web-development` | SDK boundary, OpenAPI, auth method |
9999
| Web projects + NoSQL Database | `web-development` | `cloudbase-document-database-web-sdk`, `auth-web-cloudbase` | `relational-database-mcp-cloudbase`, `http-api-cloudbase` | Login state and database access permission model |
100+
| CloudBase PostgreSQL Best Practices | `postgresql-best-practices-cloudbase` | `postgresql-development-cloudbase` | `cloudbase-document-database-web-sdk` | Access paths, index decisions, row authorization, and launch capacity |
100101
| CloudBase PostgreSQL / PG | `postgresql-development-cloudbase` | `auth-tool-cloudbase`, `auth-web-cloudbase`, `web-development`, `miniprogram-development`, `cloud-storage-web`, `http-api-cloudbase` | `relational-database-mcp-cloudbase`, `cloudbase-document-database-web-sdk` | PG schema, usernamePassword login, backend/RLS permission model |
101102
| MySQL Database (relational) | `relational-database-mcp-cloudbase` | `relational-database-web-cloudbase`, `http-api-cloudbase` | `cloudbase-document-database-web-sdk`, `web-development` | Distinguish MCP management vs app code access |
102103
| Cloud Functions | `cloud-functions` | `auth-tool-cloudbase`, `ai-model-nodejs` | `cloudrun-development`, `auth-web-cloudbase` | Event vs HTTP function, runtime, `scf_bootstrap` |
@@ -115,6 +116,7 @@ These rules override convenience. Full rationale lives in `web-development`.
115116
- **WeChat mini program + CloudBase** — 小程序 云开发, wx.cloud, mini program cloudbase, OPENID, 小程序数据库
116117
- **Native App / Flutter / React Native** — Android CloudBase, iOS CloudBase, Flutter CloudBase, React Native CloudBase, 原生 App 接入
117118
- **Web projects + NoSQL Database** — Web 文档数据库, CloudBase collection, 前端查库, NoSQL Web SDK
119+
- **CloudBase PostgreSQL Best Practices** — PG access pattern, 数据库访问路径, N+1 查询, 批量查询, 慢查询, EXPLAIN ANALYZE, 缺索引, 活动数据库容量
118120
- **CloudBase PostgreSQL / PG** — CloudBase PG, PostgreSQL, Postgres, PG 模式, JS SDK v3 PostgreSQL, app.rdb(), queryPgDatabase, managePgDatabase, mysqldb OpenAPI, PostgREST, RLS, service_role, auth schema, storage schema, pgvector
119121
- **MySQL Database (relational)** — MySQL 建表, executeWriteSQL, security rule, CloudBase 关系型数据库管理
120122
- **Cloud Functions** — 创建云函数, HTTP 云函数, getFunctionLogs, scf_bootstrap, runtime

skills/cloudbase/references/activation-map.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ scenarios:
9696
label: Web projects + NoSQL Database
9797
mustCheckBeforeAction:
9898
- Login state and database access permission model
99+
- id: postgresql-best-practices-cloudbase
100+
priority: 97
101+
signals:
102+
- PG access pattern
103+
- 数据库访问路径
104+
- N+1 查询
105+
- 批量查询
106+
- 慢查询
107+
- EXPLAIN ANALYZE
108+
- 缺索引
109+
- 活动数据库容量
110+
firstRead: postgresql-best-practices-cloudbase
111+
thenRead:
112+
- postgresql-development-cloudbase
113+
beforeAction:
114+
- 先列出接口、任务或 RPC 的读写路径、谓词、排序、基数和频率。
115+
- 查询实现完成前确认数据库往返次数有界,并为每个高频谓词作出索引决策。
116+
doNotUse:
117+
- cloudbase-document-database-web-sdk
118+
commonMistakes:
119+
- 在循环中逐行查询数据库。
120+
- 只增加数据库规格而不减少查询往返或检查执行计划。
121+
label: CloudBase PostgreSQL Best Practices
122+
mustCheckBeforeAction:
123+
- Access paths, index decisions, row authorization, and launch capacity
99124
- id: postgresql-development-cloudbase
100125
priority: 96
101126
signals:
@@ -262,7 +287,7 @@ scenarios:
262287
beforeAction:
263288
- 按 BaaS-first 排序:Web SDK CRUD > MCP schema > 模板预热 > 云函数(默认 0)。
264289
- 连接器尽量预启用;凭据/Trust 等待窗口并行 downloadTemplate + 安装依赖。
265-
- 能力嗅探顺序:connector ready → envQuery → 锁定一种 DB(NoSQL 或 PG 或 MySQL)→ MCP schema → @cloudbase/js-sdk CRUD → 本地预览;禁止中途横跳。
290+
- 能力嗅探顺序:connector ready → queryEnv → 锁定一种 DB(NoSQL 或 PG 或 MySQL)→ MCP schema → @cloudbase/js-sdk CRUD → 本地预览;禁止中途横跳。
266291
- 先本地预览再部署;自定义域名 / DNS / 回滚非默认范围。
267292
doNotUse:
268293
- cloud-functions
@@ -344,7 +369,7 @@ scenarios:
344369
- ai-model-nodejs
345370
- ai-model-wechat
346371
beforeAction:
347-
- 先跑「调用前必须的资格检查」:用 `envQuery` 拿到 `EnvId`,再按端别优先级查资格。
372+
- 先跑「调用前必须的资格检查」:用 `queryEnv` 拿到 `EnvId`,再按端别优先级查资格。
348373
- Web / Node.js 端优先 `callCloudApi(tcb, DescribeEnvPostpayPackage)` 确认 Token Credits 资源包开通;未命中返回 `https://buy.cloud.tencent.com/lowcode?buyType=resPack&envId={envId}&resourceType=token` 引导购买。
349374
- 小程序端优先调用 `callCloudApi` 的 `DescribeActivityInfo`(参数 activityNames 为 ai_miniprogram_inspire_plan)判断成长计划是否报名;命中用 `hunyuan-exp` / `hunyuan-2.0-instruct-20251111`;未命中引导 `https://docs.cloudbase.net/ai/ai-inspire-plan` 或退回资源包 + 非 hunyuan 模型。
350375
- 指定的模型不在托管列表时走自定义接入(CloudBase 控制台 `#/ai` 或 `callCloudApi(tcb, CreateAIModel)`),不要点名任何第三方品牌。

skills/cloudbase/references/ai-model-nodejs/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Before calling any AI API on the server, **run the two-step preflight**: ① eli
7575

7676
### Step 0: obtain the environment ID
7777

78-
Call the MCP tool `envQuery` with `action=info` and read `EnvId` from the response.
78+
Call the MCP tool `queryEnv` with `action=info` and read `EnvId` from the response.
7979

8080
---
8181

@@ -254,7 +254,7 @@ For full `generateText` / `streamText` / `generateImage` code examples, the erro
254254

255255
## Best Practices
256256

257-
1. **Run the two-step preflight before writing business code** — ① eligibility: `envQuery``callCloudApi(tcb, DescribeEnvPostpayPackage)` to confirm the Token Credits resource pack (text + image share the same pack); ② group readiness: `DescribeAIModels` for the `cloudbase` group and its `Models[]`, `DescribeManagedAIModelList` for the authoritative supported-model catalog, `UpdateAIModel` with a full-replacement `Models[]` + `Status: 1` when the target model is missing. If the pack is missing, return the purchase link `https://buy.cloud.tencent.com/lowcode?buyType=resPack&envId={envId}&resourceType=token` instead of emitting SDK code and letting the user debug runtime errors.
257+
1. **Run the two-step preflight before writing business code** — ① eligibility: `queryEnv``callCloudApi(tcb, DescribeEnvPostpayPackage)` to confirm the Token Credits resource pack (text + image share the same pack); ② group readiness: `DescribeAIModels` for the `cloudbase` group and its `Models[]`, `DescribeManagedAIModelList` for the authoritative supported-model catalog, `UpdateAIModel` with a full-replacement `Models[]` + `Status: 1` when the target model is missing. If the pack is missing, return the purchase link `https://buy.cloud.tencent.com/lowcode?buyType=resPack&envId={envId}&resourceType=token` instead of emitting SDK code and letting the user debug runtime errors.
258258
2. **Never assume any model is already enabled** — not `deepseek-v4-flash`, not `hunyuan-image`, not anything. Always verify with `DescribeAIModels` first; if the target is missing, look up the exact `Model` string in `DescribeManagedAIModelList` (do **not** guess the spelling) and then `UpdateAIModel` to enable it.
259259
3. **`createModel` accepts exactly three kinds of values**`"cloudbase"` (the main managed group), `"hunyuan-exp"` (legacy builtin), or a user-defined GroupName registered via `CreateAIModel` (**MUST start with `custom-`**, e.g. `custom-kimi`, `custom-openai-compat`). **Never** guess with `createModel("deepseek")` / `createModel("kimi")` / `createModel("custom")` — the first two are vendor/model names, the last is a placeholder. `createImageModel("hunyuan-image")` is a separate image API — keep it as-is.
260260
4. **Do not invent SDK method names or parameters.** This skill (SKILL.md + `references/api-reference.md`) is the authoritative reference for `@cloudbase/node-sdk`'s AI surface — look up the method signature there before writing code. If a method or field is not documented there, stop and ask, or check the live contract via the MCP tools. No guessing.

skills/cloudbase/references/ai-model-web/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Before generating any AI-related SDK code, **run the two-step preflight**: ① e
8282

8383
### Step 0: obtain the environment ID
8484

85-
Call the MCP tool `envQuery` with `action=info` and read `EnvId` from the response. Every subsequent check and purchase link uses this `EnvId`.
85+
Call the MCP tool `queryEnv` with `action=info` and read `EnvId` from the response. Every subsequent check and purchase link uses this `EnvId`.
8686

8787
---
8888

skills/cloudbase/references/ai-model-wechat/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ You MUST NOT jump straight into `wx.cloud.extend.AI.createModel(...)`. Before wr
8787

8888
The Mini Program side has two billing paths: **小程序成长计划** (checked first; if enrolled, use `hunyuan-exp`) and **Token Credits 资源包** (generic fallback; if available, use the `cloudbase` main managed group).
8989

90-
1. Fetch `envId` via the MCP tool `envQuery action=info`.
90+
1. Fetch `envId` via the MCP tool `queryEnv action=info`.
9191

9292
2. Pick the branch by user intent:
9393

skills/cloudbase/references/auth-web-cloudbase/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Use npm installation for modern Web projects. In React, Vue, Vite, and other bun
8787
### Parameter map
8888

8989
- For username-style identifiers, the required precondition is `loginMethods.usernamePassword === true` from `queryAppAuth(action="getLoginConfig")`. If it is false, enable it with `manageAppAuth(action="patchLoginStrategy", patch={ usernamePassword: true })` before wiring frontend auth code.
90-
- If the conversation only provides an environment alias, nickname, or other shorthand, resolve it with `envQuery(action="list", alias=..., aliasExact=true)` first and use the returned canonical full `EnvId` for SDK init, console links, and generated config. Do not pass alias-like short forms directly into `cloudbase.init({ env })`.
90+
- If the conversation only provides an environment alias, nickname, or other shorthand, resolve it with `queryEnv(action="list", alias=..., aliasExact=true)` first and use the returned canonical full `EnvId` for SDK init, console links, and generated config. Do not pass alias-like short forms directly into `cloudbase.init({ env })`.
9191
- Treat CloudBase Web Auth as **Supabase-like**, not “every `supabase-js` auth example is valid unchanged”
9292
- When `queryAppAuth` / `manageAppAuth` returns `sdkStyle: "supabase-like"` and `sdkHints`, follow those method and parameter hints first
9393
- `auth.signInWithOtp({ phone })` and `auth.signUp({ phone })` use the phone number in a `phone` field, not `phone_number`
@@ -110,7 +110,7 @@ SDK init reference: [docs.cloudbase.net/api-reference/webv3/initialization.md](h
110110
import cloudbase from '@cloudbase/js-sdk'
111111

112112
const app = cloudbase.init({
113-
env: 'your-full-env-id', // Canonical full CloudBase environment ID resolved from envQuery or the console, not an alias or shorthand
113+
env: 'your-full-env-id', // Canonical full CloudBase environment ID resolved from queryEnv or the console, not an alias or shorthand
114114
region: 'ap-shanghai', // CloudBase environment Region, default 'ap-shanghai'
115115
accessKey: 'publishable key', // required, get from auth-tool-cloudbase
116116
// ⚠️ accessKey alone ≠ a login session. NoSQL CRUD needs a session —

skills/cloudbase/references/cloud-storage-web/SKILL.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If a referenced sibling skill file is missing from this environment, ask the use
6060

6161
When the app runs on a local browser origin and must upload files from the frontend:
6262

63-
1. Use `envQuery` with `action="domains"` to inspect the current security-domain whitelist.
63+
1. Use `queryEnv` with `action="domains"` to inspect the current security-domain whitelist.
6464
2. Convert the browser origin into the CloudBase whitelist entry format:
6565
- Browser origin `http://127.0.0.1:4173` -> whitelist entry `127.0.0.1:4173`
6666
- Browser origin `http://localhost:5173` -> whitelist entry `localhost:5173`
@@ -142,12 +142,12 @@ ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;
142142
-- Allow authenticated users to upload files
143143
CREATE POLICY "authenticated_upload" ON storage.objects
144144
FOR INSERT TO authenticated
145-
WITH CHECK (auth.role() = 'authenticated');
145+
WITH CHECK (true);
146146

147147
-- Allow authenticated users to read/download files
148148
CREATE POLICY "authenticated_read" ON storage.objects
149149
FOR SELECT TO authenticated
150-
USING (auth.role() = 'authenticated');
150+
USING (true);
151151

152152
-- Optional: allow users to update/delete their own files
153153
CREATE POLICY "users_manage_own" ON storage.objects
@@ -216,7 +216,7 @@ const result = await app.uploadFile({
216216
- Validate file type and size before upload.
217217
- Show upload progress for larger files when UX matters.
218218
- On local dev origins, confirm the exact frontend origin already exists in environment security domains before assuming the upload path is usable.
219-
- Match against the whitelist entry format returned by `envQuery(action="domains")`, which is typically `host:port` instead of a full `http://...` URL.
219+
- Match against the whitelist entry format returned by `queryEnv(action="domains")`, which is typically `host:port` instead of a full `http://...` URL.
220220
- If the environment has no storage bucket or the SDK returns `STORAGE_NOT_EXIST` / `STORAGE_BUCKET_NOT_FOUND`, use CloudBase management/MCP storage tools to create or choose a bucket before retrying. Do not treat this as a successful optional upload.
221221
- After `app.uploadFile()` succeeds, do **not** fabricate a public-looking URL by concatenating `envId`, bucket domain, or `cloudPath`. Use the returned `fileID` with `app.getTempFileURL()` and store or display the SDK-resolved URL instead.
222222

@@ -291,7 +291,7 @@ Use this for browser-initiated downloads. For programmatic rendering or preview,
291291
To avoid CORS problems, add your frontend domain in CloudBase security domains. In MCP-enabled workflows, prefer checking and updating this through tools before coding browser uploads.
292292
293293
```json
294-
{ "tool": "envQuery", "action": "domains" }
294+
{ "tool": "queryEnv", "action": "domains" }
295295
```
296296
297297
Use the actual browser origin when deciding what to add. If the page is running on a custom domain or a local dev port, add that exact `host:port` value instead of guessing from a hard-coded list.
@@ -304,7 +304,7 @@ Use the actual browser origin when deciding what to add. If the page is running
304304
}
305305
```
306306
307-
Match the real browser origin to the whitelist entry format returned by `envQuery(action="domains")`. For local Vite and preview servers, the port can vary between runs, so avoid assuming any fixed default port is sufficient.
307+
Match the real browser origin to the whitelist entry format returned by `queryEnv(action="domains")`. For local Vite and preview servers, the port can vary between runs, so avoid assuming any fixed default port is sufficient.
308308
309309
Typical examples:
310310

skills/cloudbase/references/cloudbase-code-review/references/RULES_INDEX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Only add rules that are backed by stable SDK/API documentation, repeated evaluat
6969
| AUTH-TOOL-009 | error | lint | Web, MP, Node, CR | 禁止使用 lowcode/DescribeLoginStrategy/ModifyLoginStrategy |
7070
| AUTH-TOOL-010 | error | lint | Web | 用户名禁止路由到 email-only 辅助函数 |
7171
| AUTH-TOOL-011 | error | LLM | Web, MP, Node, CR | EnvId 是环境 ID,不是 publishable key |
72-
| AUTH-TOOL-012 | error | LLM | Web, MP, Node, CR | 环境别名必须通过 envQuery 解析为规范 EnvId |
72+
| AUTH-TOOL-012 | error | LLM | Web, MP, Node, CR | 环境别名必须通过 queryEnv 解析为规范 EnvId |
7373
| AUTH-TOOL-013 | warning | LLM | Web, MP, Node, CR | 匿名登录默认禁用 |
7474
| AUTH-TOOL-014 | warning | LLM | Web, MP, Node, CR | 匿名用户调用 AI 模型需显式授权 |
7575

skills/cloudbase/references/cloudbase-code-review/references/rules/postgresql/PG-CR005.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
1. 项目是否运行在 CloudBase PG / pgstore 环境?
2323
2. 如果是,存储桶创建后是否配置了 `storage.objects` 表的 RLS 策略?
24-
3. 存储 RLS 策略是否至少允许认证用户上传(`FOR INSERT TO authenticated WITH CHECK (auth.role() = 'authenticated')`)和读取(`FOR SELECT TO authenticated USING (auth.role() = 'authenticated')`)?
24+
3. 存储 RLS 策略是否至少允许认证用户上传(`FOR INSERT TO authenticated WITH CHECK (true)`)和读取(`FOR SELECT TO authenticated USING (true)`)?`TO authenticated` 已经是角色门,不需要重复调用 `auth.role()`
2525
4. 配置方式是否正确使用了 `managePgDatabase(action="execute", confirm=true)` 执行 SQL?不要使用 CloudBase 传统安全规则 API(`managePermissions` / `ModifyStorageSafeRule`),那是 NoSQL 环境用的。
2626
5. 如果上传失败(`STORAGE_PERMISSION_DENIED`),是否检查了 storage RLS 配置?
2727

@@ -34,11 +34,11 @@ ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;
3434

3535
CREATE POLICY "authenticated_upload" ON storage.objects
3636
FOR INSERT TO authenticated
37-
WITH CHECK (auth.role() = 'authenticated');
37+
WITH CHECK (true);
3838

3939
CREATE POLICY "authenticated_read" ON storage.objects
4040
FOR SELECT TO authenticated
41-
USING (auth.role() = 'authenticated');
41+
USING (true);
4242
```
4343

4444
详细指引见 `cloud-storage-web/SKILL.md` "Post-bucket: storage RLS" 章节。

0 commit comments

Comments
 (0)