frontend-dev skill
Enforces coding standards for Vue 3 and React, including UI constraints, TypeScript rules, and API handling protocols.
- GitHub stars
- 1,061
- Files
- 4
- Last commit
- Aug 26, 2026
- License
- —
- Allowed tools
- —
What does the frontend-dev skill do?
frontend-dev enforces coding standards for Vue 3 and React, including UI constraints, TypeScript rules, and API handling protocols.
Summary generated from the skill's SKILL.md.
About the frontend-dev skill
Enforcing professional frontend coding standards for Vue 3 and React is what this skill enables for developers building enterprise-grade web applications. It provides a strict framework for UI design, ensuring that interfaces remain clean and professional by prohibiting neon gradients, glassmorphism, and excessive decorative elements in favor of a restrained black, white, and gray palette.
When an agent loads this skill, it applies specific technical constraints across various file types including .vue, .tsx, and .ts files. It guides the implementation of Vue 3 with Pinia or React 18 with Zustand, while mandating the use of Vite for builds. The skill produces code that adheres to strict TypeScript rules, such as requiring generic constraints for API calls and forbidding the use of any to bypass type safety. It also ensures that developers handle essential interaction states like loading, empty, and error through specific component patterns.
What an agent can do with it
- 1Standardize Vue 3 component structureGenerate a Vue 3 component using the script setup pattern with proper props, emits, and lifecycle hooks.
- 2Enforce type-safe API integrationRefactor an API call to use generics instead of returning unknown or using type assertions.
- 3Implement consistent error handlingEnsure all network requests include error handling and user notifications for non-success responses.
- 4Apply UI style constraintsReview a UI design to ensure it does not use prohibited styles like cyber-punk or heavy gradients.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the frontend-dev skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the frontend-dev skill in Plugin
/plugin marketplace add doccker/cc-use-exp /plugin install cc-use-exp@cc-use-exp
Install the frontend-dev skill in Claude Code
~/.claude/skills/frontend-dev/SKILL.md
$ npx degit doccker/cc-use-exp/skills/frontend-dev ~/.claude/skills/frontend-devInstall the frontend-dev skill in Claude Code (project)
.claude/skills/frontend-dev/SKILL.md
$ npx degit doccker/cc-use-exp/skills/frontend-dev .claude/skills/frontend-devInstall the frontend-dev skill in Codex
~/.agents/skills/frontend-dev/SKILL.md
$ npx degit doccker/cc-use-exp/skills/frontend-dev ~/.agents/skills/frontend-devInstall the frontend-dev skill in Gemini CLI
~/.gemini/skills/frontend-dev/SKILL.md
$ npx degit doccker/cc-use-exp/skills/frontend-dev ~/.gemini/skills/frontend-devInstall the frontend-dev skill in Claude.ai
npx degit doccker/cc-use-exp/skills/frontend-dev frontend-dev && zip -r frontend-dev.zip frontend-dev # claude.ai → Customize → Skills → + → Create skill → Upload a skill → frontend-dev.zip
SKILL.md
View on GitHub前端开发规范
参考来源: Vue 官方风格指南、Element Plus 最佳实践
UI 风格约束
严格禁止(常见 AI 风格)
- ❌ 蓝紫色霓虹渐变、发光描边、玻璃拟态
- ❌ 大面积渐变、过多装饰性几何图形
- ❌ 赛博风、暗黑科技风、AI 风格 UI
- ❌ UI 文案中使用 emoji
后台系统(默认风格)
| 要素 | 要求 |
|---|---|
| 主题 | 使用组件库默认主题 |
| 配色 | 黑白灰为主 + 1 个主色点缀 |
| 动效 | 克制,仅保留必要交互反馈 |
技术栈
| 层级 | Vue(首选) | React(备选) |
|---|---|---|
| 框架 | Vue 3 + TypeScript | React 18 + TypeScript |
| 构建 | Vite | Vite |
| 路由 | Vue Router 4 | React Router 6 |
| 状态 | Pinia | Zustand |
| UI 库 | Element Plus | Ant Design |
Vue 编码规范
组件基础
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import type { User } from '@/types'
// Props & Emits
const props = defineProps<{ userId: number }>()
const emit = defineEmits<{ (e: 'update', value: string): void }>()
// 响应式状态
const loading = ref(false)
const user = ref<User | null>(null)
// 计算属性
const displayName = computed(() => user.value?.name ?? '未知用户')
// 生命周期
onMounted(async () => { await fetchUser() })
// 方法
async function fetchUser() {
loading.value = true
try {
user.value = await api.getUser(props.userId)
} finally {
loading.value = false
}
}
</script>
<template>
<div class="user-card">
<h3>{{ displayName }}</h3>
</div>
</template>
<style scoped>
.user-card { padding: 16px; }
</style>
命名约定
| 类型 | 约定 | 示例 |
|---|---|---|
| 组件文件 | PascalCase.vue | UserCard.vue |
| Composables | useXxx.ts | useAuth.ts |
| Store | useXxxStore.ts | useUserStore.ts |
状态管理(Pinia)
// stores/user.ts
export const useUserStore = defineStore('user', () => {
const user = ref<User | null>(null)
const token = ref<string>('')
const isLoggedIn = computed(() => !!token.value)
async function login(username: string, password: string) {
const res = await api.login(username, password)
token.value = res.token
user.value = res.user
}
return { user, token, isLoggedIn, login }
})
交互状态处理
必须处理的状态: loading、empty、error、disabled、submitting
<template>
<el-skeleton v-if="loading" :rows="5" animated />
<el-result v-else-if="error" icon="error" :title="error">
<template #extra>
<el-button @click="fetchData">重试</el-button>
</template>
</el-result>
<el-empty v-else-if="list.length === 0" description="暂无数据" />
<template v-else>
<!-- 正常内容 -->
</template>
</template>
TypeScript 规范
// types/user.ts
export interface User {
id: number
username: string
role: 'admin' | 'user'
}
export interface ApiResponse<T = unknown> {
code: number
message: string
data: T
}
API 调用类型安全
| 规则 | 说明 |
|---|---|
| ✅ API 工具函数支持泛型 | get<T>(url): Promise<T> 而非返回 unknown |
| ✅ 调用处指定泛型或断言 | get<UserInfo>(url) 或 data as typeof ref.value |
❌ 禁止 as any 绕过 |
掩盖类型问题,后续维护踩坑 |
// ❌ get() 返回 unknown,赋值报 TS2322
const data = await get('/contact/config')
contact.value = data
// ❌ as any 绕过
contact.value = data as any
// ✅ 泛型约束(推荐)
const data = await get<ContactConfig>('/contact/config')
contact.value = data
// ✅ 类型断言(最小改动)
contact.value = data as typeof contact.value
性能优化
| 场景 | 方案 |
|---|---|
| 大列表 | 虚拟滚动 |
| 路由 | 懒加载 () => import() |
| 计算 | 使用 computed 缓存 |
| 大数据 | 使用 shallowRef |
// 路由懒加载
const routes = [
{ path: '/dashboard', component: () => import('@/views/Dashboard.vue') }
]
// 请求防抖
import { useDebounceFn } from '@vueuse/core'
const debouncedSearch = useDebounceFn((keyword) => api.search(keyword), 300)
目录结构
src/
├── assets/
│ └── styles/ # 全局/共享样式
├── api/ # API 请求
├── components/ # 通用组件
├── composables/ # 组合式函数
├── router/ # 路由配置
├── stores/ # Pinia stores
├── types/ # TypeScript 类型
├── utils/ # 工具函数
├── views/ # 页面组件
├── App.vue
└── main.ts
样式管理规范
| 规则 | 说明 |
|---|---|
❌ 禁止在 .vue 中写大段样式 |
<style> 块不超过 20 行 |
❌ 禁止在 .tsx 中写大段内联样式 |
样式对象/CSS-in-JS 不超过 20 行 |
✅ 共享样式抽到 src/assets/styles/ |
按模块拆分文件 |
| ✅ 组件内只保留极简样式 | Vue: scoped 微调;React: className 引用 |
src/assets/styles/
├── variables.scss # 变量(颜色、间距、字号)
├── common.scss # 通用样式
└── [module].scss # 按模块拆分
请求体完整性规范
| 规则 | 说明 |
|---|---|
| ❌ 禁止 UI 可选字段未传入 API | 用户选择/输入的字段必须全部传入请求体 |
| ✅ 提交函数与表单字段一一对应 | 用 TypeScript interface 约束请求体 |
// ❌ UI 有支付方式选择器,但请求体没传 payMethod
const payMethod = ref<'wechat' | 'points' | 'mixed'>('wechat')
async function createOrder() {
await api.createOrder({
items: orderItems.value,
addressId: selectedAddress.value.id,
// payMethod 忘记传了!支付方式选择 UI 形同虚设
})
}
// ✅ 请求体与 UI 表单字段对应
interface CreateOrderRequest {
items: OrderItem[]
addressId: number
payMethod: 'wechat' | 'points' | 'mixed' // 类型约束确保不遗漏
}
async function createOrder() {
const request: CreateOrderRequest = {
items: orderItems.value,
addressId: selectedAddress.value.id,
payMethod: payMethod.value, // TypeScript 会提示缺少字段
}
await api.createOrder(request)
}
API 错误处理规范
| 规则 | 说明 |
|---|---|
| ❌ 禁止静默忽略非成功响应 | res.code !== 200 时必须提示用户 |
| ✅ 统一错误提示 | 非成功响应统一 message.error 提示 |
| ✅ 网络异常也要处理 | try/catch 捕获请求异常 |
// ❌ 只处理成功,非 200 静默忽略
const res = await api.getList(params)
if (res.code === 200) {
list.value = res.data
}
// ✅ 成功 + 失败都处理
try {
const res = await api.getList(params)
if (res.code === 200) {
list.value = res.data
} else {
message.error(res.message || '加载失败')
}
} catch (e) {
message.error('网络异常,请稍后重试')
}
类型复用规范
| 规则 | 说明 |
|---|---|
| ❌ 禁止多个文件重复定义相同接口 | PageResponse、BaseResult 等 |
✅ 通用类型统一放 @/types/common.ts |
全局导出,各处引用 |
// ❌ 每个 api 文件都定义一遍
// api/user.ts
interface PageResponse<T> { list: T[]; total: number }
// api/order.ts
interface PageResponse<T> { list: T[]; total: number } // 重复
// ✅ 统一定义,各处引用
// types/common.ts
export interface PageResponse<T> {
list: T[]
total: number
}
// api/user.ts
import type { PageResponse } from '@/types/common'
详细参考
| 文件 | 内容 |
|---|---|
references/frontend-style.md |
UI 风格、Vue 3 规范、Pinia、API 封装、性能优化 |
references/miniapp-pitfalls.md |
uni-app 陷阱:页面栈只读、Storage 清理时机、生命周期双触发、前端校验镜像 |
references/date-time.md |
dayjs/date-fns 日期加减、账期计算、禁止月末对齐 |
📋 本回复遵循:
frontend-dev- [具体章节]
Files in this skill
4frontend-dev skill questions
How do I install the frontend-dev skill in Claude Code?
Run npx degit doccker/cc-use-exp/skills/frontend-dev ~/.claude/skills/frontend-dev. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the frontend-dev skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What are the prohibited UI styles?
The standards strictly forbid neon gradients, glowing borders, glassmorphism, large-scale gradients, excessive decorative geometric shapes, cyber/AI styles, and the use of emojis in UI copy.
How should API errors be handled?
You must not silently ignore non-successful responses; if the response code is not 200, a unified error message must be shown to the user, and network exceptions must be caught using try/catch.
What are the naming conventions for Vue components and composables?
Component files should use PascalCase (e.g., UserCard.vue), and composables should follow the useXxx.ts pattern (e.g., useAuth.ts).