cloudbase-document-database-in-wechat-miniprogram — скилл
Скилл ведёт агента по работе с документной базой CloudBase из мини-программы WeChat: запросы, пагинация, агрегации, геолокация.
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a claude-codeЧто делает cloudbase-document-database-in-wechat-miniprogram
Скилл включается, когда код мини-программы обращается к базе через wx.cloud.database(). Агент получает правила инициализации, разбор владения документами и маршрутизацию по операциям: CRUD, сложные запросы, пагинация, агрегации, геолокация, правила безопасности — под каждую тему отдельный файл-справочник рядом со SKILL.md.
Внутри есть контракт активации: когда применять, что прочитать до написания кода, а для чего скилл не годится. Прямо сказано, что браузерный @cloudbase/js-sdk, серверный доступ и облачные функции — не его территория, как и MySQL. Отдельный список типовых ошибок: копирование Web SDK в страницы мини-программы, ручная запись _openid при создании и обновлении.
Важная деталь: _openid управляется системой при записи через SDK, и подставлять его вручную в .add(), .set() или .update() не нужно. Если правило коллекции требует условий владения, форма запроса должна совпадать с этой моделью — ошибки доступа чаще означают несоответствие правила и запроса, а не разлогиненного пользователя. Привилегированные операции скилл советует уводить в бэкенд, а не открывать в клиенте мини-программы.
Какие задачи решает
- сделать CRUD коллекции из страницы мини-программы
- собрать запрос с условиями и постраничной выдачей
- посчитать агрегацию по документам
- найти записи рядом с точкой на карте
- разобраться, почему правило коллекции отклоняет запрос
Примеры запросов агенту
- покажи, как через wx.cloud.database() получить незавершённые задачи с пагинацией
- нужен агрегатный запрос по коллекции orders в мини-программе
- почему запрос падает с ошибкой доступа, если правило коллекции проверяет _openid
Как установить cloudbase-document-database-in-wechat-miniprogram
1Через Skills CLI (Vercel)
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a claude-code2Вручную: положить файлы
~/.claude/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/cloudbase-document-database-in-wechat-miniprogram/
1Через Skills CLI (Vercel)
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a codex2Вручную: положить файлы
.agents/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a cursor2Вручную: положить файлы
.cursor/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install TencentCloudBase/skills cloudbase-document-database-in-wechat-miniprogram2Вручную: положить файлы
.github/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md1Через Skills CLI (Vercel)
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a gemini-cli2Командой платформы
gemini skills install https://github.com/TencentCloudBase/skills --path skills/cloudbase-document-database-in-wechat-miniprogramВручную: положить файлы
.devin/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора16
Похожие
Рядом в теме «Данные и базы»
Все скиллы по теме «Данные и базы» →Вопросы о cloudbase-document-database-in-wechat-miniprogram
Как установить cloudbase-document-database-in-wechat-miniprogram в Claude?
Выполните npx skills add TencentCloudBase/skills --skill cloudbase-document-database-in-wechat-miniprogram -a claude-code. После этого файл скилла лежит по пути ~/.claude/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md.
Что делает этот скилл?
Он даёт агенту правила работы с документной базой CloudBase из мини-программы WeChat: инициализация wx.cloud.database(), CRUD, сложные запросы, пагинация, агрегации и геолокация, плюс отдельный разбор правил безопасности.
Подойдёт ли он для браузерного кода или облачных функций?
Нет. Для браузера с @cloudbase/js-sdk и для серверного доступа есть соседние скиллы CloudBase, а этот рассчитан на код мини-программы.
Исходный текст
SKILL.md · MIT
---
name: cloudbase-document-database-in-wechat-miniprogram
description: Use CloudBase document database WeChat MiniProgram SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.
version: 2.36.1
license: MIT
alwaysApply: false
---
## Sibling skills (local only)
Sibling CloudBase skills ship beside this skill. Use local relative paths such as `../auth-tool-cloudbase/SKILL.md`.
If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do **not** HTTP-fetch remote skill or protocol markdown into the agent context.
# CloudBase Document Database WeChat Mini Program SDK
## Activation Contract
### Use this first when
- A WeChat Mini Program must access CloudBase document database through `wx.cloud.database()`.
- The request mentions Mini Program collection CRUD, pagination, aggregation, or geolocation queries.
### Read before writing code if
- The task is Mini Program database work but you still need to separate it from Web SDK, cloud functions, or SQL tasks.
- The request depends on built-in user identity, `_openid`, or Mini Program-side permissions.
### Then also read
- Mini Program project rules and CloudBase integration -> `../miniprogram-development/SKILL.md`
- Mini Program auth and identity flow -> `../auth-wechat-miniprogram/SKILL.md`
- Browser-side document database code -> `../cloudbase-document-database-web-sdk/SKILL.md`
### Do NOT use for
- Browser/Web code using `@cloudbase/js-sdk`.
- Server-side or cloud-function database access.
- MySQL / relational database work.
### Common mistakes / gotchas
- Copying Web SDK code into Mini Program pages.
- Manually writing `_openid` during create or update operations.
- Assuming built-in Mini Program identity means security rules can be ignored.
- Mixing collection CRUD and backend-wide admin workflows in the same client path.
### Minimal checklist
- Confirm the caller is a Mini Program page/component or Mini Program-side logic.
- Initialize `wx.cloud` correctly before database calls.
- Verify whether the collection rules rely on `auth.openid` / `_openid`.
- Read the specific companion reference file for the operation you need.
## Overview
This skill covers **Mini Program-side document database access** through `wx.cloud.database()`.
Use it for:
- collection CRUD in Mini Program pages
- query composition and pagination
- aggregation
- geolocation queries
Mini Program CloudBase access comes with built-in identity, but database operations are still constrained by collection permissions and security rules.
## Canonical initialization
```javascript
const db = wx.cloud.database();
const _ = db.command;
```
To target a specific environment:
```javascript
const db = wx.cloud.database({
env: "test"
});
```
Important notes:
- Users are authenticated through the Mini Program CloudBase context.
- In cloud functions, caller identity is available through `wxContext.OPENID`.
- In client-side collection rules, ownership checks usually use `auth.openid` / `doc._openid`.
## Quick routing
- CRUD -> `./crud-operations.md`
- Complex queries -> `./complex-queries.md`
- Pagination -> `./pagination.md`
- Aggregation -> `./aggregation.md`
- Geolocation -> `./geolocation.md`
- Security rules -> `./security-rules.md`
## Working rules for a coding agent
1. **Keep Mini Program code Mini Program-native**
- Use `wx.cloud.database()`.
- Do not substitute browser SDK initialization patterns.
2. **Respect ownership fields**
- `_openid` is system-managed for SDK writes.
- Never set or override `_openid` manually in `.add()`, `.set()`, or `.update()` payloads.
3. **Remember that security rules validate requests**
- If a rule requires ownership conditions, the query shape must match that rule model.
- Permission errors usually mean the rule/query relationship is wrong, not only that the user is logged out.
4. **Route admin-style operations to backend flows**
- If the task needs privileged global access, use backend tools or functions instead of exposing that path directly in Mini Program client code.
## Quick examples
### Basic collection access
```javascript
const todos = db.collection("todos");
const result = await todos.where({ completed: false }).get();
```
### Document reference
```javascript
const todo = db.collection("todos").doc("todo-id");
const result = await todo.get();
```
## Best practices
1. Create clear collection naming conventions.
2. Use typed wrappers or model helpers in app code where possible.
3. Design rules around real ownership and sharing patterns.
4. Use pagination instead of large unbounded reads.
5. Keep admin/operations logic in backend code, not Mini Program direct access.
© TencentCloudBase · MIT · TencentCloudBase/skills