add-frontend-development
Frontend architecture: state, data fetching, components, forms, routing. Stack-agnostic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Frontend architecture: state, data fetching, components, forms, routing. Stack-agnostic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Consolidated view of the add-pro ecosystem - commands, skills, relationships and dependencies. Loaded by /add as source of truth.
Source of truth for ADD doc rules, depth floors, IDs, refs, validation gate. Load before any doc write.
Use when running agent-judged QA validation (read-PNG by default; the playwright plugin adds live driving) — the Level C judge rubric, severity taxonomy, dual-judge (@ux-agent review ∥ @qa-agent) method, report schema/template, and the config.json/screens.json formats. Consumed by /add.qa and both judges.
Use when a state-materializing command starts or is asked to upgrade — reads the setup receipt, compares the recorded contract against the shipped one, executes the declared upgrade deltas sequentially, and rewrites the receipt even on a verified-current no-op. Consumed by /add.qa-setup STEP 1.5 and STEP 11.
Internal skill for developing ADD framework artefacts (commands, skills, agents, scripts). Use when add-framework--plan analyzes viability of new framework features, when add-framework--build implements framework artefacts, or when creating/modifying commands, skills, or agents. Always use this skill before proposing or implementing changes to the framework itself.
Use when building, styling, or theming UI components, pages, layouts, dashboards, charts, tables, or forms for SaaS products.
| name | add-frontend-development |
| description | Frontend architecture: state, data fetching, components, forms, routing. Stack-agnostic. |
Stack-agnostic skill for frontend architecture and implementation patterns.
Use for: Pages, State, Data Fetching, Types, API integration, Forms, Routing, Components Do not use for: UI/Design (ux-design), Backend (backend-development), mobile-native (React Native/Flutter), build tooling/bundler config
Stack orientation: Consult CLAUDE.md ## Architecture Contract for the frontend framework, UI library, state management, and data-fetching tool. Apply the principles below using that framework's APIs.
Reference: Always consult CLAUDE.md for general project standards.
BEFORE implementing any frontend component:
{{skill:add-ux-design/SKILL.md}})The ux-design skill provides the SaaS UX Pattern Library (Dashboard, Settings, Billing, Auth, DataTables, Workspace), context auto-detection, mobile-first requirements (touch 44px, inputs 16px+), state patterns (loading/empty/error), and component patterns (layout, cards, forms, tables).
RULE: Never implement frontend without either design.md OR ux-design skill loaded.
Organize source files by concern. Exact paths and extensions depend on the framework (see CLAUDE.md).
[frontend-src]/
├── pages/[page-name].* # Route-level page components
├── components/
│ ├── features/[feature]/ # Domain components (logic + presentation)
│ │ ├── [feature]-card.*
│ │ ├── [feature]-form.*
│ │ ├── [feature]-table.*
│ │ └── [feature]-columns.*
│ ├── ui/ # Design system primitives (from UI library)
│ └── layout/ # Structural components (header, sidebar, footer)
├── composables|hooks/ # Data-fetching and reusable logic
├── stores/[feature]-store.* # UI state stores
├── types/ # Shared TypeScript interfaces/types
├── lib/api.* # Centralized API client
└── routes.* # Route definitions
{"rules":["interfaces not classes","Date fields -> string (JSON serialization)","Enums -> union types (no backend imports)","sync with backend DTOs field-by-field","never use any","centralized location"]}
{"separation":"UI state (local, ephemeral) vs Server state (cache of backend data) — NEVER mix them","requirements":["consistent hierarchical cache keys (e.g. ['resource'], ['resource', id])","loading indicator while fetching","error state handled and displayed","invalidate related cache after mutations","conditional fetching when prerequisites missing (e.g. ID exists)","return library primitives directly — do not wrap unnecessarily"]}
Use the project's data-fetching library (see CLAUDE.md) to handle server state.
Separate state into two categories — never mix them:
| Category | What belongs here | Where it lives |
|---|---|---|
| UI state | Sidebar open/close, modals, selections, filters, local toggles | Client-side store (see CLAUDE.md) |
| Server state | Data from the backend, CRUD results, cached responses | Data-fetching library cache |
UI state is local and ephemeral — losing it on refresh is acceptable. Server state is a cache of the backend (the source of truth). Never store fetched data in a UI store.
{"rules":["single centralized instance for the entire app","base URL from environment variable — never hard-code","request interceptors for auth token injection","response interceptors for global error handling (401 -> logout, 5xx -> notification)","all data-fetching composables/hooks use this client"]}
{"patterns":["schema-based validation (Zod or equivalent) for every form","form data type inferred from schema — no manual duplication","schema mirrors the backend DTO for the endpoint","validate on client (UX) AND server (security) — both mandatory","inline validation errors immediately on blur or submit","error messages match the project's language/locale"]}
{"mandatory_states":["Loading — spinner or skeleton while data loads","Error — error message with retry option","Empty — empty-state message when collection is empty"],"patterns":["data-fetching logic at top of component, before conditionals","container/layout wrapper for consistent spacing","fallback to empty array for list data"]}
{"patterns":["route structure mirrors feature architecture","auth-required routes wrapped in protected-route guard","each route lazy-loaded to reduce initial bundle size","nested routes for shared layouts (sidebar, header)","detail routes use dynamic params (e.g. /users/:id)"]}
{"rules":["centralized auth state (current user, token, isAuthenticated)","token stored securely (httpOnly cookies vs localStorage based on threat model)","auth state persisted across page refreshes","API client automatically attaches token to requests","protected route guard redirects unauthenticated users to login","logout clears auth state and cached data"]}
| What | Convention | Example |
|---|---|---|
| Files | kebab-case | user-profile-card.* |
| Components | PascalCase | UserProfileCard |
| Functions/variables | camelCase | getUserById, isLoading |
| Types/interfaces | PascalCase | UserProfile, CreateUserRequest |
| Stores | camelCase with domain prefix | useAuthStore, uiStore |
| Constants | UPPER_SNAKE_CASE | MAX_RETRY_COUNT |
anydesign.md