cloudbase-document-database-web-sdk skill
✓ VerifiedEnables agents to perform NoSQL CRUD operations, complex queries, and realtime data synchronization in web applications using the CloudBase JS SDK.
- GitHub stars
- 1,164
- Files
- 9
- Last commit
- Nov 11, 2026
- License
- MIT
- Allowed tools
- —
What does the cloudbase-document-database-web-sdk skill do?
cloudbase-document-database-web-sdk enables agents to perform NoSQL CRUD operations, complex queries, and realtime data synchronization in web applications using the CloudBase JS SDK.
Summary generated from the skill's SKILL.md.
About the cloudbase-document-database-web-sdk skill
Developers building web applications can use this skill to implement NoSQL document database operations directly within their frontend code. It is designed for agents tasked with writing or modifying browser-side JavaScript using the @cloudbase/js-sdk to manage data collections. The skill facilitates standard CRUD tasks, complex queries, pagination, and data aggregation, as well as real-time synchronization through the watch method.
When an agent is asked to implement application logic or modify existing web project files, it should load this skill to produce correct SDK implementations. It relies on the CloudBase JS SDK and requires careful coordination with authentication states to ensure security rules are respected. This skill is specifically for browser-based environments and should not be used for server-side cloud functions, Mini Program development, or SQL-based PostgreSQL operations.
What an agent can do with it
- 1Implement frontend CRUD operationsAn agent can write JavaScript code to add, retrieve, update, or delete documents in a specific collection.
- 2Set up real-time data listenersA developer can instruct an AI to implement live data updates in a web interface using the watch method.
- 3Develop paginated data feedsAn agent can create logic to fetch large datasets in manageable chunks using skip and limit commands.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the cloudbase-document-database-web-sdk 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-web-sdk skill in Claude Code
~/.claude/skills/cloudbase-document-database-web-sdk/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk ~/.claude/skills/cloudbase-document-database-web-sdkInstall the cloudbase-document-database-web-sdk skill in Claude Code (project)
.claude/skills/cloudbase-document-database-web-sdk/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk .claude/skills/cloudbase-document-database-web-sdkInstall the cloudbase-document-database-web-sdk skill in Codex
~/.agents/skills/cloudbase-document-database-web-sdk/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk ~/.agents/skills/cloudbase-document-database-web-sdkInstall the cloudbase-document-database-web-sdk skill in Gemini CLI
~/.gemini/skills/cloudbase-document-database-web-sdk/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk ~/.gemini/skills/cloudbase-document-database-web-sdkInstall the cloudbase-document-database-web-sdk skill in Claude.ai
npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk cloudbase-document-database-web-sdk && zip -r cloudbase-document-database-web-sdk.zip cloudbase-document-database-web-sdk # claude.ai → Customize → Skills → + → Create skill → Upload a skill → cloudbase-document-database-web-sdk.zip
Automated checks
Ran Nov 14, 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
- Source repository linked and reachabletencentcloudbase/cloudbase-ai-toolkit/config/.claude/skills/cloudbase-document-database-web-sdk 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
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 Web SDK
Activation Contract
Use this first when
- A browser or Web app must read or write CloudBase document database data through
@cloudbase/js-sdk. - The request mentions
app.database(),db.collection(),.where(),.watch(), pagination, aggregation, or geolocation queries in a Web frontend.
Read before writing code if
- The task is clearly browser-side, but you still need to decide between Web SDK, Mini Program SDK, or backend access.
- The request touches login state, collection permissions, or realtime updates.
Then also read
- Web login and caller identity ->
../auth-web-cloudbase/SKILL.md - General Web app structure ->
../web-development/SKILL.md - Mini Program database code ->
../cloudbase-document-database-in-wechat-miniprogram/SKILL.md
Do NOT use for
- Mini Program code using
wx.cloud.database(). - Server-side or cloud-function database access.
- SQL / MySQL database operations.
- Pure resource-permission administration with no browser SDK code.
- NEW business tables that the task explicitly asks to put in CloudBase PostgreSQL (CloudBase PG). Before applying this skill, call
queryEnv(action="info", envId=...)and readEnvInfo.RuntimeBackends. Ifpostgresql === trueAND the task asks for a new business table to live in PG, switch to thepostgresql-development-cloudbaseskill for that table: it goes throughapp.rdb(), uses PG row-level security (CREATE POLICY), and uploads viaapp.storage.from('<bucket>').upload('<key>', file)against an explicitly-created pgstore bucket.- Existing NoSQL collections in the same env keep using THIS skill — PG and NoSQL coexist in CloudBase PG environments. The rule is "follow the task / existing surface", not "PG env forbids NoSQL".
- Moving existing document data onto PG without changing the client code is pgdoc, not a rewrite to
app.rdb(). Read../postgresql-development-cloudbase/references/pgdoc.md: SDK calls and HTTP paths stay the same, but CUSTOM security rules no longer apply and data is not migrated automatically.
SDK Code vs MCP Tools
When to write SDK code (use this skill):
- The task explicitly asks to "modify code" or "use SDK"
- The task asks to implement app/frontend logic
- The task mentions specific SDK methods like
db.collection().add(),.get(),.update() - The context shows an existing Web project with SDK initialization (e.g.,
index.jsalready hascloudbase.init())
When to use MCP tools instead:
- The task asks to manage CloudBase resources (create collection, set permissions, etc.)
- The task involves admin/management operations without writing app code
- The task mentions tools like
writeNoSqlDatabaseContent,managePermissions, etc.
Key distinction: If the user says "使用 JS SDK 执行 XX 操作" (use JS SDK to perform XX operation) or "修改代码" (modify code), write SDK code in the project files. Do not use MCP database write tools for app-level data operations.
Common mistakes / gotchas
- Querying before the user is signed in when the collection rules require identity.
- Using
wx.cloud.database()or Node SDK patterns in browser code. - Initializing CloudBase lazily with dynamic imports instead of a shared synchronous app instance.
- Treating security rules as result filters rather than request validators.
- Expecting a
CUSTOMsecurity rule to take effect immediately after you callmanagePermissions(updateResourcePermission). The backend caches rule evaluators for 2–5 minutes; first writes after a rule change may silently fail or be rejected withDATABASE_PERMISSION_DENIEDeven when the expression is correct. Either (a) wait a few minutes and retry the same write before assuming the rule is wrong, or (b) verify the rule is live by readingresult.code/result.messageon every write and by doing aget()round-trip on the just-written_id; do not treat a resolved promise as success. Seesecurity-rules.md→ "Propagation And Verification" for the full pattern. - Misreading the return shape of
db.collection(...).add(...). In the CloudBase Web SDK, the created document ID is exposed at top-levelresult._id, notresult.id,result.data.id, orresult.insertedId. - For CMS-style collections that need app-level admin users to edit/delete all records while editors can only edit/delete their own records, do not oversimplify the rule to
READONLY. A validated pattern is aCUSTOMrule that reads role fromuser_rolesbyauth.uidand combines it withdoc.authorId == auth.uid, while frontend writes can stay on.doc(id).update()/.doc(id).remove(). - Forgetting pagination or indexes for larger collections.
Minimal checklist
- Confirm this is browser-side document database work.
- Initialize CloudBase once and reuse the same
app/dbinstance. - Verify auth expectations before CRUD.
- Read the right companion reference file for the specific operation.
Overview
This skill covers browser-side document database usage via @cloudbase/js-sdk.
Use it for:
- CRUD in a Web app
- complex queries and pagination
- aggregation
- realtime listeners with
watch() - geolocation queries
Canonical initialization
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "your-env-id"
});
const db = app.database();
const _ = db.command;
Important rules:
- Sign in before querying if the collection rules require identity.
- Keep a single shared app/database instance.
- Do not hide initialization inside ad-hoc async loaders unless the framework truly requires it.
Quick routing
- CRUD ->
./crud-operations.md - Complex queries ->
./complex-queries.md - Pagination ->
./pagination.md - Aggregation ->
./aggregation.md - Realtime listeners ->
./realtime.md - Geolocation ->
./geolocation.md - Security rules ->
./security-rules.md
Working rules for a coding agent
-
Start from the auth model
- If the page relies on logged-in user identity, read the Web auth skill before writing database code.
-
Keep browser code browser-native
- Use
app.database()and collection references. - Do not mix in MCP management flows or SQL mental models.
- Use
-
Respect security rules
- Collection rules can reject requests before data is read.
- If the requirement is simple owner-only write access,
READONLYcan be enough. - If the requirement is “app-level admin can edit/delete all, editor only own”, use a
CUSTOMrule. A validated CMS pattern isget(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid. - For that CMS pattern, frontend writes can stay on
.doc(id).update()/.doc(id).remove(). - Reuse whichever role collection already exists and can be addressed by
_id == auth.uid. In this CMS pattern,user_roleskeyed by uid is acceptable. - A
get()whose target document is missing fails the request with HTTP 500 — it does not evaluate tofalse, and||does not skip it. If the app cannot guarantee a role document per user, keep the role list in one shared document and testauth.uid in get(`database.admin_registry.lock`).adminsinstead. - If the task fails with permission issues, inspect the rule model rather than assuming the query syntax is wrong.
-
Return user-friendly errors
- Database errors must become readable UI or application errors, not silent failures.
- For writes, do not treat a resolved promise as success by default. Check write result fields such as
updated/deletedor surfacedcode/message.
-
Persist IDs from create operations correctly
- For Web SDK
.add(...), the newly created document ID isresult._id. - Do not look for the ID under
result.id,result.data, or other driver-specific fields.
- For Web SDK
Quick examples
Simple query
const result = await db.collection("todos")
.where({ completed: false })
.get();
Create and capture document ID
const result = await db.collection("posts").add({
title: "New article",
content: "...",
createdAt: new Date()
});
const articleId = result._id;
Ordered pagination
const result = await db.collection("posts")
.orderBy("createdAt", "desc")
.skip(20)
.limit(10)
.get();
Field selection
const result = await db.collection("users")
.field({ name: true, email: true, _id: false })
.get();
Best practices
- Define collection-level types or model wrappers in the app code.
- Use meaningful collection naming conventions.
- Select only required fields.
- Add indexes for frequent filters or sort keys.
- Pair frontend CRUD with explicit permission design.
- Use pagination instead of unbounded reads.
Error handling
try {
const result = await db.collection("todos").get();
console.log(result.data);
} catch (error) {
console.error("Database error:", error);
}
When the SDK returns an operation result, check error indicators and translate them into readable application behavior.
Files in this skill
9cloudbase-document-database-web-sdk skill questions
How do I install the cloudbase-document-database-web-sdk skill in Claude Code?
Run npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk ~/.claude/skills/cloudbase-document-database-web-sdk. 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-web-sdk 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 get the ID of a newly created document using the Web SDK?
The newly created document ID is located at the top-level result._id property of the response.
When should I use MCP tools instead of writing SDK code?
Use MCP tools for administrative tasks like managing CloudBase resources or setting permissions, rather than implementing application-level frontend logic.
Can I use this skill for PostgreSQL operations in CloudBase?
No, if the task involves PostgreSQL, CloudBase PG, or app.rdb(), you should use the postgresql-development-cloudbase skill instead.