Awesome-omni-skill web-development
Web frontend project development rules. Use this skill when developing web frontend pages, deploying static hosting, and integrating CloudBase Web SDK.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/web-development-binggg" ~/.claude/skills/diegosouzapw-awesome-omni-skill-web-development && rm -rf "$T"
skills/development/web-development-binggg/SKILL.mdWhen 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
directorysrc - Build output in
directorydist - Cloud functions in
directorycloudfunctions - 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
tool to get environment IDenvQuery
-
Deploy and preview properly
- Build project first (ensure
is executed)npm install - Use relative paths for
configurationpublicPath - 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
directorysrc - Build output should be placed in
directorydist - Cloud functions should be in
directorycloudfunctions
- 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,
and similar configurations should use relative paths instead of absolute pathspublicPath - 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
in the web application@cloudbase/js-sdk@latest
- 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!
import cloudbase from "@cloudbase/js-sdk"; 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(); }
Initialization rules (Web, @cloudbase/js-sdk):
- Always use synchronous initialization with the pattern above
- Do not lazy-load the SDK with
import("@cloudbase/js-sdk") - Do not wrap SDK initialization in async helpers such as
with internalinitCloudBase()
cachesinitPromise - Keep a single shared
/app
instance in your frontend app; reuse it instead of re-initializingauth
Web SDK API usage rules
- Only use documented CloudBase Web SDK methods
- Before calling any method on
,app
,auth
, or other SDK objects, confirm it exists in the official CloudBase Web SDK documentationdb - If a method or option is not mentioned in the official docs (for example some guessed method name), do NOT invent or use it
Local development proxy for default login page
When using
auth.toDefaultLoginPage() in local development, you must proxy the /__auth path to your CloudBase Web hosting domain. For example, in a Vite + React project:
// vite.config.ts import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [react()], base: "./", // Use relative paths to avoid asset issues on static hosting server: { host: "127.0.0.1", proxy: { "/__auth": { target: "https://envId-appid.tcloudbaseapp.com/", // Replace with your CloudBase Web app domain changeOrigin: true, }, }, allowedHosts: true, }, });
The CloudBase Web hosting domain can be obtained via the CloudBase MCP
envQuery tool (Static hosting config); in the response, use the value from the StaticDomain field.
In other dev servers/build tools (Webpack dev server, Next.js custom dev server, etc.), implement an equivalent proxy rule so that all
/__auth requests are forwarded to the CloudBase domain during local development.
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
, then stored to databaseauth.getCurrentUser() -
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