frontend-developer-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFrontend Developer Skill
前端开发技能
Purpose
用途
Provides complete frontend development expertise for building production-ready web applications with modern frameworks (React, Vue, Next.js), comprehensive tooling setup, state management patterns, testing infrastructure, and performance optimization strategies.
提供完整的前端开发专业知识,用于使用现代框架(React、Vue、Next.js)、全面的工具设置、状态管理模式、测试基础设施和性能优化策略构建可投入生产的Web应用。
When to Use
适用场景
- Building new React, Vue, or Angular applications from scratch
- Setting up modern frontend tooling (Vite, ESLint, Prettier, testing frameworks)
- Implementing state management with Redux Toolkit, Zustand, or Context API
- Configuring authentication flows with token management and protected routes
- Optimizing bundle size and performance for production deployments
- Creating component libraries and design systems
- Setting up comprehensive testing (unit, integration, E2E)
- 从零开始构建新的React、Vue或Angular应用
- 设置现代前端工具(Vite、ESLint、Prettier、测试框架)
- 使用Redux Toolkit、Zustand或Context API实现状态管理
- 配置带有令牌管理和受保护路由的认证流程
- 优化生产部署的包体积和性能
- 创建组件库和设计系统
- 设置全面的测试(单元测试、集成测试、端到端测试)
Quick Start
快速开始
Invoke this skill when:
- Building React, Vue, or Angular applications
- Setting up frontend tooling (Vite, ESLint, Prettier)
- Implementing state management (Redux Toolkit, Zustand, Context)
- Configuring authentication flows
- Optimizing bundle size and performance
- Setting up testing (Vitest, Jest, Playwright)
Do NOT invoke when:
- Only backend API needed → Use backend-developer
- Database optimization → Use database-optimizer
- DevOps/deployment only → Use devops-engineer
- UI/UX design without code → Use ui-designer
在以下场景调用此技能:
- 构建React、Vue或Angular应用
- 设置前端工具(Vite、ESLint、Prettier)
- 实现状态管理(Redux Toolkit、Zustand、Context)
- 配置认证流程
- 优化包体积和性能
- 设置测试(Vitest、Jest、Playwright)
请勿在以下场景调用:
- 仅需要后端API → 使用后端开发专家技能
- 数据库优化 → 使用数据库优化专家技能
- 仅涉及DevOps/部署 → 使用DevOps工程师技能
- 无需编码的UI/UX设计 → 使用UI设计师技能
Decision Framework
决策框架
Framework Selection
框架选择
Frontend Framework Selection
├─ New Project (greenfield)
│ ├─ Needs SEO + server-side rendering
│ │ ├─ Team knows React → Next.js 14+
│ │ ├─ Team knows Vue → Nuxt.js 3+
│ │ └─ Team flexible → Next.js (ecosystem advantage)
│ │
│ ├─ SPA without SSR requirements
│ │ ├─ React experience → React 18+ (Vite)
│ │ ├─ Vue experience → Vue 3 (Vite)
│ │ └─ Enterprise/complex forms → Angular 15+
│ │
│ └─ Static site (blog, docs)
│ └─ Astro, Next.js SSG, or Vite + React
│
└─ Existing Project
└─ Continue with existing framework (consistency)Frontend Framework Selection
├─ New Project (greenfield)
│ ├─ Needs SEO + server-side rendering
│ │ ├─ Team knows React → Next.js 14+
│ │ ├─ Team knows Vue → Nuxt.js 3+
│ │ └─ Team flexible → Next.js (ecosystem advantage)
│ │
│ ├─ SPA without SSR requirements
│ │ ├─ React experience → React 18+ (Vite)
│ │ ├─ Vue experience → Vue 3 (Vite)
│ │ └─ Enterprise/complex forms → Angular 15+
│ │
│ └─ Static site (blog, docs)
│ └─ Astro, Next.js SSG, or Vite + React
│
└─ Existing Project
└─ Continue with existing framework (consistency)State Management Selection
状态管理选择
| Scenario | Library | Bundle Size | Use Case |
|---|---|---|---|
| Simple local state | useState, useReducer | 0 KB | Component-level state |
| Shared state (2-3 components) | Context API | 0 KB | Theme, auth, simple global |
| Medium app (<10 slices) | Zustand | ~1 KB | Most apps, good DX |
| Large app (10+ slices) | Redux Toolkit | ~11 KB | Enterprise, time-travel debug |
| Server state | TanStack Query | ~12 KB | API data, caching |
| 场景 | 库 | 包体积 | 适用场景 |
|---|---|---|---|
| 简单本地状态 | useState, useReducer | 0 KB | 组件级状态 |
| 共享状态(2-3个组件) | Context API | 0 KB | 主题、认证、简单全局状态 |
| 中型应用(<10个状态切片) | Zustand | ~1 KB | 大多数应用,良好的开发体验 |
| 大型应用(10+个状态切片) | Redux Toolkit | ~11 KB | 企业级应用,时间旅行调试 |
| 服务端状态 | TanStack Query | ~12 KB | API数据、缓存 |
Styling Approach
样式方案
Styling Decision
├─ Rapid prototyping → Tailwind CSS
├─ Component library → Radix UI + Tailwind
├─ Dynamic theming → CSS-in-JS (Styled Components, Emotion)
├─ Large team → CSS Modules or Tailwind + Design Tokens
└─ Performance-critical → Plain CSS / SCSSStyling Decision
├─ Rapid prototyping → Tailwind CSS
├─ Component library → Radix UI + Tailwind
├─ Dynamic theming → CSS-in-JS (Styled Components, Emotion)
├─ Large team → CSS Modules or Tailwind + Design Tokens
└─ Performance-critical → Plain CSS / SCSSBest Practices
最佳实践
- Use functional components - Modern React pattern
- Leverage hooks - Avoid class components when possible
- Memoize expensive operations - Use useMemo, useCallback
- Lazy load components - Reduce initial bundle size
- Type everything - Leverage TypeScript
- Test thoroughly - Unit, integration, and E2E tests
- Optimize images - Use modern formats and lazy loading
- Implement error boundaries - Catch errors gracefully
- Make it accessible - ARIA labels, keyboard navigation
- Monitor performance - Track Core Web Vitals
- 使用函数式组件 - 现代React模式
- 利用Hooks - 尽可能避免类组件
- 缓存昂贵操作 - 使用useMemo、useCallback
- 懒加载组件 - 减小初始包体积
- 全面类型化 - 利用TypeScript
- 充分测试 - 单元测试、集成测试和端到端测试
- 优化图片 - 使用现代格式和懒加载
- 实现错误边界 - 优雅捕获错误
- 确保可访问性 - ARIA标签、键盘导航
- 监控性能 - 跟踪核心Web指标
Common Patterns
常见模式
Custom Hooks
自定义Hooks
typescript
function useFetch<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
fetch(url)
.then(res => res.json())
.then(setData)
.catch(setError)
.finally(() => setLoading(false));
}, [url]);
return { data, loading, error };
}typescript
function useFetch<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
fetch(url)
.then(res => res.json())
.then(setData)
.catch(setError)
.finally(() => setLoading(false));
}, [url]);
return { data, loading, error };
}Container/Presentational
容器/展示组件模式
typescript
// Presentational (dumb)
const UserList = ({ users, onUserClick }: UserListProps) => (
<ul>
{users.map(user => (
<li key={user.id} onClick={() => onUserClick(user.id)}>
{user.name}
</li>
))}
</ul>
);
// Container (smart)
const UserListContainer = () => {
const { users, fetchUsers } = useUsers();
useEffect(() => fetchUsers(), [fetchUsers]);
return <UserList users={users} onUserClick={handleClick} />;
};typescript
// Presentational (dumb)
const UserList = ({ users, onUserClick }: UserListProps) => (
<ul>
{users.map(user => (
<li key={user.id} onClick={() => onUserClick(user.id)}>
{user.name}
</li>
))}
</ul>
);
// Container (smart)
const UserListContainer = () => {
const { users, fetchUsers } = useUsers();
useEffect(() => fetchUsers(), [fetchUsers]);
return <UserList users={users} onUserClick={handleClick} />;
};Troubleshooting
问题排查
Common Issues
常见问题
State not updating
- Check if using correct setter
- Verify dependency arrays in useEffect
- Ensure components are re-rendering
Component not re-rendering
- Check for unnecessary re-renders
- Verify memoization is working
- Review prop changes
Performance issues
- Profile with React DevTools
- Check for large bundle sizes
- Review unnecessary re-renders
- Implement code splitting
Tests failing
- Verify test setup
- Check mock implementations
- Review async handling
- Ensure proper cleanup
状态未更新
- 检查是否使用了正确的setter方法
- 验证useEffect中的依赖数组
- 确保组件正在重新渲染
组件未重新渲染
- 检查是否存在不必要的重新渲染
- 验证缓存是否正常工作
- 审查props变化
性能问题
- 使用React DevTools进行性能分析
- 检查包体积是否过大
- 审查不必要的重新渲染
- 实现代码分割
测试失败
- 验证测试设置
- 检查模拟实现
- 审查异步处理
- 确保正确的清理
Quality Checklist
质量检查清单
Architecture
架构
- Framework choice justified
- State management clear (server vs client state separated)
- Component structure logical
- Code splitting implemented
- 框架选择合理
- 状态管理清晰(服务端与客户端状态分离)
- 组件结构逻辑合理
- 已实现代码分割
Code Quality
代码质量
- TypeScript strict mode enabled
- ESLint + Prettier configured
- Tests exist for critical paths
- No prop drilling (use state management)
- 已启用TypeScript严格模式
- 已配置ESLint + Prettier
- 关键路径存在测试用例
- 无props透传(使用状态管理)
Performance
性能
- Bundle size optimized (<200KB gzipped)
- Expensive operations memoized
- Images optimized (lazy loading, WebP)
- Third-party libraries evaluated
- 包体积已优化(gzip压缩后<200KB)
- 昂贵操作已缓存
- 图片已优化(懒加载、WebP格式)
- 第三方库已评估
Testing
测试
- Testing framework configured
- Critical paths tested
- E2E tests exist
- 已配置测试框架
- 关键路径已测试
- 存在端到端测试
Security
安全
- Environment variables secured
- Input sanitization
- Auth tokens secure
- Dependencies audited
- 环境变量已安全存储
- 输入已净化
- 认证令牌安全
- 依赖已审计
Integration Patterns
集成模式
react-specialist
React专家
- Handoff: frontend-developer sets up tooling → react-specialist implements complex component logic
- Tools: Both use React; frontend-developer handles ecosystem tooling
- 交接: 前端开发专家设置工具 → React专家实现复杂组件逻辑
- 工具: 两者均使用React;前端开发专家负责生态系统工具
nextjs-developer
Next.js开发专家
- Handoff: When SSR/SEO required → hand off for Next.js-specific features
- Tools: frontend-developer uses Vite/CRA; nextjs-developer uses Next.js App Router
- 交接: 当需要SSR/SEO时 → 交接给Next.js开发专家处理特定功能
- 工具: 前端开发专家使用Vite/CRA;Next.js开发专家使用Next.js App Router
backend-developer
后端开发专家
- Handoff: frontend-developer implements API client → backend-developer provides API contracts
- Tools: frontend-developer uses Axios/Fetch, TanStack Query
- 交接: 前端开发专家实现API客户端 → 后端开发专家提供API契约
- 工具: 前端开发专家使用Axios/Fetch、TanStack Query
frontend-ui-ux-engineer
前端UI/UX工程师
- Handoff: frontend-developer sets up component structure → frontend-ui-ux-engineer styles
- Tools: Both use React; frontend-ui-ux-engineer adds Framer Motion, Tailwind design tokens
- 交接: 前端开发专家设置组件结构 → 前端UI/UX工程师负责样式
- 工具: 两者均使用React;前端UI/UX工程师添加Framer Motion、Tailwind设计令牌
Additional Resources
额外资源
- Detailed Technical Reference: See REFERENCE.md
- Code Examples & Patterns: See EXAMPLES.md
- 详细技术参考:查看REFERENCE.md
- 代码示例与模式:查看EXAMPLES.md