Agent skill
relational-database-web-cloudbase
Use when building frontend Web apps that talk to CloudBase Relational Database via @cloudbase/js-sdk – provides the canonical init pattern so you can then use Supabase-style queries from the browser.
Install this agent skill to your Project
npx add-skill https://github.com/sycsky/Soncho/tree/main/.codebuddy/rules/tcb/rules/relational-database-web-skill
SKILL.md
When to use this skill
Use this skill whenever you need to access CloudBase Relational Database from a browser app (React, Vue, vanilla JS) using @cloudbase/js-sdk.
Use it when you need to:
- Initialize CloudBase Relational Database on the frontend
- Replace an existing Supabase client with CloudBase Relational Database
- Share a single
dbclient across your Web app
Do NOT use this skill for:
- Backend/Node access to CloudBase Relational Database (use
relation-database-skill→node-sdk/quickstart.md) - MCP/agent database management (use
relation-database-skill→mcp-tools/mcp-guide.md) - Auth flows (use the Web/Node/Auth skills instead)
How to use this skill (for a coding agent)
- Confirm environment
- Ask the user for:
env– CloudBase environment ID
- Ask the user for:
- Follow the initialization pattern in this file exactly
- Only change values like
env, never the object shape.
- Only change values like
- After initialization, use Supabase knowledge for queries
- Treat
dbas a Supabase client – method names and patterns are identical.
- Treat
- Avoid re-initializing CloudBase
- Create a single shared
dbclient and reuse it across components.
- Create a single shared
Installation
npm install @cloudbase/js-sdk
Initialization pattern (canonical)
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "your-env-id", // CloudBase environment ID
});
const auth = app.auth();
// Handle user authentication separately (Web Auth skill)
const db = app.rdb();
// Use db exactly like a Supabase client
Rules:
- Do not invent new properties on the
cloudbase.initoptions. - Always call
app.rdb()to get the database client;appis not the DB client.
Scenario 1: Replace Supabase client in a React app
// lib/db.js (shared database client)
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "your-env-id",
});
export const db = app.rdb();
// hooks/usePosts.js
import { useEffect, useState } from "react";
import { db } from "../lib/db";
export function usePosts() {
const [posts, setPosts] = useState([]);
useEffect(() => {
async function fetchPosts() {
const { data } = await db.from("posts").select("*");
setPosts(data || []);
}
fetchPosts();
}, []);
return { posts };
}
Scenario 2: Basic query pattern (Supabase-style)
// Fetch latest posts
const { data, error } = await db
.from("posts")
.select("*")
.order("created_at", { ascending: false });
if (error) {
console.error("Failed to load posts", error.message);
}
Scenario 3: Insert / update / delete rows
// Insert
await db.from("posts").insert({ title: "Hello" });
// Update
await db.from("posts").update({ title: "Updated" }).eq("id", 1);
// Delete
await db.from("posts").delete().eq("id", 1);
Key principle: CloudBase Relational Database = Supabase API
- After you have
db = app.rdb(), use Supabase documentation and patterns for all queries. - This skill only standardizes Web initialization and client sharing.
- Do not duplicate Supabase docs into this skill; rely on the model's built-in Supabase knowledge for query shapes and options.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
spec-workflow
Standard software engineering workflow for requirement analysis, technical design, and task planning. Use this skill when developing new features, complex architecture designs, multi-module integrations, or projects involving database/UI design.
auth-web-cloudbase
Complete guide for CloudBase Auth v2 using Web SDK (@cloudbase/js-sdk@2.x) - all login flows, user management, captcha handling, and best practices in one file.
cloudbase-document-database-web-sdk
Use CloudBase document database Web SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.
auth-nodejs-cloudbase
Complete guide for CloudBase Auth using the CloudBase Node SDK – caller identity, user lookup, custom login tickets, and server-side best practices.
cloudbase-platform
CloudBase platform knowledge and best practices. Use this skill for general CloudBase platform understanding, including storage, hosting, authentication, cloud functions, database permissions, and data models.
miniprogram-development
WeChat Mini Program development rules. Use this skill when developing WeChat mini programs, integrating CloudBase capabilities, and deploying mini program projects.
Didn't find tool you were looking for?