Agent skill
web-development
Web frontend project development rules. Use this skill when developing web frontend pages, deploying static hosting, and integrating CloudBase Web SDK.
Install this agent skill to your Project
npx add-skill https://github.com/sycsky/Soncho/tree/main/.codebuddy/rules/tcb/rules/web-development-skill
SKILL.md
When to use this skill
Use this skill for Web frontend project development when you need to:
- Develop web frontend pages and interfaces
- Deploy static websites to CloudBase static hosting
- Integrate CloudBase Web SDK for database, cloud functions, and authentication
- Set up modern frontend build systems (Vite, Webpack, etc.)
- Handle routing and build configurations for static hosting
Do NOT use for:
- Mini-program development (use miniprogram-development skill)
- Backend service development (use cloudrun-development skill)
- UI design only (use ui-design skill, but may combine with this skill)
How to use this skill (for a coding agent)
-
Follow project structure conventions
- Frontend source code in
srcdirectory - Build output in
distdirectory - Cloud functions in
cloudfunctionsdirectory - Use modern frontend build systems (Vite, etc.)
- Frontend source code in
-
Use CloudBase Web SDK correctly
- Always use SDK built-in authentication features
- Never implement login logic in cloud functions
- Use
envQuerytool to get environment ID
-
Deploy and preview properly
- Build project first (ensure
npm installis executed) - Use relative paths for
publicPathconfiguration - Use hash routing for better static hosting compatibility
- Deploy to subdirectory if user doesn't specify root directory
- Build project first (ensure
Web Frontend Development Rules
Project Structure
-
Directory Organization:
- Frontend source code should be stored in
srcdirectory - Build output should be placed in
distdirectory - Cloud functions should be in
cloudfunctionsdirectory
- Frontend source code should be stored in
-
Build System:
- Projects should use modern frontend build systems like Vite
- Install dependencies via npm
-
Routing:
- If the frontend project involves routing, use hash routing by default
- Hash routing solves the 404 refresh issue and is more suitable for static website hosting deployment
Deployment and Preview
-
Static Hosting Deployment:
- For frontend projects, after building, you can use CloudBase static hosting
- First start local preview, then confirm with user if deployment to CloudBase static hosting is needed
- When deploying, if user has no special requirements, generally do not deploy directly to root directory
- Return deployed address in markdown link format
-
Local Preview:
- To preview static web pages locally, navigate to the specified output directory and use
npx live-server
- To preview static web pages locally, navigate to the specified output directory and use
-
Public Path Configuration:
- When web projects are deployed to static hosting CDN, since paths cannot be known in advance,
publicPathand similar configurations should use relative paths instead of absolute paths - This solves resource loading issues
- When web projects are deployed to static hosting CDN, since paths cannot be known in advance,
CloudBase Web SDK Usage
- SDK Integration:
- If user's project needs database, cloud functions, and other features, need to introduce
@cloudbase/js-sdk@latestin the web application
- If user's project needs database, cloud functions, and other features, need to introduce
Important: Authentication must use SDK built-in features. It is strictly forbidden to implement login authentication logic using cloud functions!
const app = cloudbase.init({
env: 'xxxx-yyy'; // Can query environment ID via envQuery tool
});
const auth = app.auth();
// Check current login state
let loginState = await auth.getLoginState();
if (loginState && loginState.user) {
// Logged in
const user = await auth.getCurrentUser();
console.log('Current user:', user);
} else {
// Not logged in - use SDK built-in authentication features
// Method 1: Redirect to default login page (recommended)
await auth.toDefaultLoginPage();
// Method 2: Anonymous login
// await auth.signInAnonymously();
}
Authentication Best Practices
-
Must use SDK built-in authentication: CloudBase Web SDK provides complete authentication features, including default login page, anonymous login, custom login, etc.
-
Forbidden to implement login using cloud functions: Do not create cloud functions to handle login logic, this is the wrong approach
-
User data management: After login, user information can be obtained via
auth.getCurrentUser(), then stored to database -
Error handling: All authentication operations should include complete error handling logic
Build Process
Web project build process: Ensure npm install command has been executed first, then refer to project documentation for building
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.
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.
Didn't find tool you were looking for?