cloudbase-document-database-in-wechat-miniprogram skill
✓ VerifiedPerform CRUD operations, complex queries, pagination, aggregation, and geolocation queries within WeChat Mini Programs using the wx.cloud.database SDK.
- GitHub stars
- 1,164
- Files
- 8
- Last commit
- Nov 11, 2026
- License
- MIT
- Allowed tools
- —
What does the cloudbase-document-database-in-wechat-miniprogram skill do?
cloudbase-document-database-in-wechat-miniprogram is an agent skill. Perform CRUD operations, complex queries, pagination, aggregation, and geolocation queries within WeChat Mini Programs using the wx.cloud.database SDK.
Summary generated from the skill's SKILL.md.
About the cloudbase-document-database-in-wechat-miniprogram skill
Managing data within WeChat Mini Programs is the primary function of this skill. It allows developers to perform document database operations directly through the wx.cloud.database() SDK. An agent should load this tool when a task involves Mini Program collection CRUD, pagination, aggregation, or geolocation queries. It produces client-side code specifically designed for the Mini Program environment, ensuring that database calls are compatible with the native framework.
This skill is distinct because it focuses exclusively on the Mini Program-side SDK rather than the Web SDK or server-side cloud functions. It handles built-in user identity through the CloudBase context and respects system-managed fields like _openid. Developers must use this when working within Mini Program pages or components to ensure that security rules and ownership checks function correctly. It is not intended for MySQL, relational database work, or browser-based @cloudbase/js-sdk implementations.
What an agent can do with it
- 1Perform collection CRUD operationsWrite code to create, read, update, or delete documents within a WeChat Mini Program collection.
- 2Implement data paginationDevelop logic to retrieve database results in smaller, manageable chunks using pagination.
- 3Execute complex geolocation queriesCreate queries that filter or retrieve data based on geographic location data.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the cloudbase-document-database-in-wechat-miniprogram skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the cloudbase-document-database-in-wechat-miniprogram skill in Claude Code
~/.claude/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram ~/.claude/skills/cloudbase-document-database-in-wechat-miniprogramInstall the cloudbase-document-database-in-wechat-miniprogram skill in Claude Code (project)
.claude/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram .claude/skills/cloudbase-document-database-in-wechat-miniprogramInstall the cloudbase-document-database-in-wechat-miniprogram skill in Codex
~/.agents/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram ~/.agents/skills/cloudbase-document-database-in-wechat-miniprogramInstall the cloudbase-document-database-in-wechat-miniprogram skill in Gemini CLI
~/.gemini/skills/cloudbase-document-database-in-wechat-miniprogram/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram ~/.gemini/skills/cloudbase-document-database-in-wechat-miniprogramInstall the cloudbase-document-database-in-wechat-miniprogram skill in Claude.ai
npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram cloudbase-document-database-in-wechat-miniprogram && zip -r cloudbase-document-database-in-wechat-miniprogram.zip cloudbase-document-database-in-wechat-miniprogram # claude.ai → Customize → Skills → + → Create skill → Upload a skill → cloudbase-document-database-in-wechat-miniprogram.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work · What to fix for more points
- Source repository linked and reachabletencentcloudbase/cloudbase-ai-toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram is public and reachablegithub.com/tencentcloudbase/cloudbase-ai-toolkit/tree/HEAD/c ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-11github.com/tencentcloudbase/cloudbase-ai-toolkit/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗Pass
- SKILL.md follows the Agent Skills formatthe description does not say when to use the skillgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗Finding
SKILL.md
View on GitHubSibling 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.
- Moving that Mini Program app's data onto CloudBase PG while keeping
wx.cloud.database()is pgdoc — read../postgresql-development-cloudbase/references/pgdoc.mdbefore changing any SDK call. CUSTOM security rules do not apply after pgdoc takes over.
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
_openidduring 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.cloudcorrectly 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
const db = wx.cloud.database();
const _ = db.command;
To target a specific environment:
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
-
Keep Mini Program code Mini Program-native
- Use
wx.cloud.database(). - Do not substitute browser SDK initialization patterns.
- Use
-
Respect ownership fields
_openidis system-managed for SDK writes.- Never set or override
_openidmanually in.add(),.set(), or.update()payloads.
-
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.
-
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
const todos = db.collection("todos");
const result = await todos.where({ completed: false }).get();
Document reference
const todo = db.collection("todos").doc("todo-id");
const result = await todo.get();
Best practices
- Create clear collection naming conventions.
- Use typed wrappers or model helpers in app code where possible.
- Design rules around real ownership and sharing patterns.
- Use pagination instead of large unbounded reads.
- Keep admin/operations logic in backend code, not Mini Program direct access.
Files in this skill
8cloudbase-document-database-in-wechat-miniprogram skill questions
How do I install the cloudbase-document-database-in-wechat-miniprogram skill in Claude Code?
Run npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-in-wechat-miniprogram ~/.claude/skills/cloudbase-document-database-in-wechat-miniprogram. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the cloudbase-document-database-in-wechat-miniprogram skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How do I initialize the CloudBase database in a WeChat Mini Program?
You can initialize the database using const db = wx.cloud.database(); or by specifying a specific environment like wx.cloud.database({ env: 'test' });.
Can I manually set the _openid field when updating a document?
No, you should never manually set or override the _openid field during create or update operations as it is system-managed.
What should I do if I encounter permission errors during a query?
Permission errors typically indicate that the relationship between your query shape and the collection security rules is incorrect, rather than the user being logged out.