cloudbase-document-database-web-sdk skill
✓ 検証済みCloudBase JS SDKを使用して、Webアプリケーション内でのNoSQL CRUD操作、複雑なクエリ、およびリアルタイムのデータ同期をエージェントが実行できるようにします。
- GitHubスター
- 1,164
- ファイル
- 9
- 最終コミット
- 2026年11月11日
- ライセンス
- MIT
- 許可されたツール
- —
cloudbase-document-database-web-sdk skillは何をしますか
cloudbase-document-database-web-sdkはAgent Skillsです。 CloudBase JS SDKを使用して、Webアプリケーション内でのNoSQL CRUD操作、複雑なクエリ、およびリアルタイムのデータ同期をエージェントが実行できるようにします。.
skillのSKILL.mdから生成された要約。
cloudbase-document-database-web-sdk skill について
Webアプリケーションを構築する開発者は、このSKILLを使用して、フロントエンドコード内でNoSQLドキュメントデータベースの操作を直接実装できます。これは、@cloudbase/js-sdkを使用してデータコレクションを管理する、ブラウザ側のJavaScriptの記述または修正を担当するエージェント向けに設計されています。このSKILLは、標準的なCRUDタスク、複雑なクエリ、ページネーション、データ集計、およびwatchメソッドによるリアルタイム同期を容易にします。
エージェントがアプリケーションロジックの実装や既存のWebプロジェクトファイルの修正を求められた場合、このSKILLをロードすることで、正しいSDK実装を生成できます。このSKILLはCloudBase JS SDKに依存しており、セキュリティルールが遵守されるように、認証状態との慎重な連携が必要です。このSKILLはブラウザベースの環境に特化しており、サーバーサイドのクラウド関数、ミニプログラムの開発、またはSQLベースのPostgreSQL操作には使用しないでください。
エージェントができること
- 1フロントエンドのCRUD操作の実装エージェントは、特定のコレクション内のドキュメントを追加、取得、更新、または削除するためのJavaScriptコードを記述できます。
- 2リアルタイムデータリスナーの設定開発者はAIに対し、watchメソッドを使用してWebインターフェースにライブデータ更新を実装するよう指示できます。
- 3ページネーション付きデータフィードの開発エージェントは、skipおよびlimitコマンドを使用して、大規模なデータセットを管理可能なチャンクで取得するロジックを作成できます。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
cloudbase-document-database-web-sdk skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。Claude Codeにcloudbase-document-database-web-sdk skillをインストールする
~/.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-sdkClaude Code (project)にcloudbase-document-database-web-sdk skillをインストールする
.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-sdkCodexにcloudbase-document-database-web-sdk skillをインストールする
~/.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-sdkGemini CLIにcloudbase-document-database-web-sdk skillをインストールする
~/.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-sdkClaude.aiにcloudbase-document-database-web-sdk skillをインストールする
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
自動チェック
実行日 2026年11月15日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。エージェントに実行させる前にスクリプトを読んでください。 チェックの仕組み · 点数を上げるための改善点
- ソースリポジトリがリンクされており、アクセス可能tencentcloudbase/cloudbase-ai-toolkit/config/.claude/skills/cloudbase-document-database-web-sdk is public and reachablegithub.com/tencentcloudbase/cloudbase-ai-toolkit/tree/HEAD/c ↗合格
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit 2026-11-11github.com/tencentcloudbase/cloudbase-ai-toolkit/commits ↗合格
- スクリプトにダウンロード実行や認証情報の窃取がないNo scripts in the skill folder合格
- SKILL.md に隠れた指示がないNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗合格
- 事前許可ツールが限定されているNo pre-approved tools; the agent asks before using onegithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗合格
- SKILL.md が Agent Skills の形式に従っているthe description does not say when to use the skillgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗検出事項
SKILL.md
GitHubで表示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 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.
このスキルのファイル
9cloudbase-document-database-web-sdk skillに関する質問
Claude Codeにcloudbase-document-database-web-sdk skillをインストールするには
npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/cloudbase-document-database-web-sdk ~/.claude/skills/cloudbase-document-database-web-sdkを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
cloudbase-document-database-web-sdk skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
Web SDKを使用して、新しく作成されたドキュメントのIDを取得するにはどうすればよいですか?
新しく作成されたドキュメントIDは、レスポンスのトップレベルにある result._id プロパティに格納されています。
SDKのコードを書く代わりに、いつMCPツールを使用すべきですか?
アプリケーションレベルのフロントエンドロジックを実装する場合ではなく、CloudBaseリソースの管理や権限の設定などの管理タスクにMCPツールを使用してください。
CloudBaseでのPostgreSQL操作にこのSKILLを使用できますか?
いいえ、PostgreSQL、CloudBase PG、または app.rdb() が関わるタスクの場合は、代わりに postgresql-development-cloudbase SKILLを使用してください。