Web development

From bighardperson/computer-science-skills-collection · View interactive version

Web development is an AI agent skill from the GitHub repository bighardperson/computer-science-skills-collection. Web frontend project development rules. Use this skill when developing web frontend pages, deploying static hosting, and integrating CloudBase Web SDK.

How to use this skill

Skill file

Activation Contract

Use this first when

Read before writing code if

Then also read

Do NOT use for

Common mistakes / gotchas

When to use this skill

Use this skill for Web frontend project development when you need to:

Do NOT use for:


How to use this skill (for a coding agent)

  1. Follow project structure conventions
  1. Use CloudBase Web SDK correctly
  1. Deploy and preview properly

Web Frontend Development Rules

Project Structure

  1. Directory Organization:
  1. Build System:
  1. Routing:

Deployment and Preview

  1. Static Hosting Deployment:
  1. Local Preview:
  1. Public Path Configuration:

CloudBase Web SDK Usage

  1. SDK Integration:

CDN quick start (static HTML / no-build):

<script src="https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js"></script>
<script>
const app = cloudbase.init({
  env: "xxxx-yyy",
});
</script>

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
    
  // Collect user's phone number into variable `phoneNum` by providing a input UI

  // Send SMS code
  const verificationInfo = await auth.getVerification({
    phone_number: `+86 ${phoneNum}`,
  });
  
  // Collect user's phone number into variable `verificationCode` by providing a input UI 
  
  // Sign in
  await auth.signInWithSms({
    verificationInfo,
    verificationCode,
    phoneNum,
  });
}

Initialization rules (Web, @cloudbase/js-sdk):

Web SDK API usage rules

Authentication Best Practices

  1. Must use SDK built-in authentication: CloudBase Web SDK provides complete authentication features, including login by SMS, anonymous login, custom login, etc.
  1. Forbidden to implement login using cloud functions: Do not create cloud functions to handle login logic, this is the wrong approach
  1. User data management: After login, user information can be obtained via auth.getCurrentUser(), then stored to database
  1. 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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.