---
name: convention-audit
description: 'Use when: reviewing code for compliance with Robot Admin project conventions, or when generating a compliance report. Triggers on: convention check, 规范检查, audit, 代码审查, code review, 命名规范, naming convention, 代码规范.'
---
# Skill: 规范审计(convention-audit)
对 Robot Admin 项目中的代码进行**规范合规性审查**,检测违反编码约定的问题并给出修正建议。
---
## 触发
- 代码审查请求(code review)
- 新代码提交前的合规性检查
- 项目级别的规范巡检
- 手动请求"帮我检查代码规范"
---
## 审计维度
### 1. 文件结构审计
**目录命名:**
| 类型 | 约定 | 示例 | 反例 |
| ------------ | ------------------ | -------------------------- | ----------------------- |
| 全局组件目录 | `C_` + PascalCase | `C_Header/`, `C_Settings/` | `header/`, `cHeader/` |
| 局部组件目录 | `c_` + camelCase | `c_detail/`, `c_role/` | `Detail/`, `c-detail/` |
| Demo 目录 | `数字编号-功能名` | `01-icon/`, `10-table/` | `icon/`, `table-demo/` |
| Store 目录 | 领域名(kebab-case) | `user/`, `theme/` | `userStore/`, `s_user/` |
**文件三件套:**
每个页面/组件目录必须包含:
- `index.vue` — 主组件
- `index.scss` — 样式(scoped)
- `data.ts` — 配置数据(页面级)或 `types.ts`(组件级)
### 2. 命名审计
**变量/函数:**
| 类型 | 约定 | 示例 | 反例 |
| ------------ | -------------------------- | --------------------------------------- | --------------------------- |
| Store 导出 | `s_` + camelCase + `Store` | `s_userStore` | `useUserStore`, `userStore` |
| Composable | `use` + PascalCase | `useLoginController` | `loginController` |
| 工具函数文件 | `d_` 前缀 | `d_auth.ts` | `auth.ts`, `authUtils.ts` |
| 组件 name | PascalCase | `defineOptions({ name: 'UserManage' })` | 缺少 name |
| API 函数 | 动词 + 资源 + `Api` | `getUserListApi` | `getUsers`, `userList` |
| 类型/接口 | PascalCase | `UserInfo`, `FormOption` | `userInfo`, `form_option` |
**组件引用:**
| 场景 | 约定 | 示例 |
| ------------- | ---------- | ------------------------------- |
| 模板中组件 | PascalCase | ``, `` |
| 自有组件库 | `C_` 前缀 | ``, `` |
| Naive UI 组件 | `N` 前缀 | ``, `` |
### 3. SFC 结构审计
**`