一键导入
code-review
单文件代码审查方法,6 个维度逐项检查(正确性、安全性、性能、可维护性、测试、无障碍)。方法语言无关,无障碍仅前端适用。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
单文件代码审查方法,6 个维度逐项检查(正确性、安全性、性能、可维护性、测试、无障碍)。方法语言无关,无障碍仅前端适用。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Execute the check workflow from this AI development team preset. Use when the user writes /check, asks for check, or wants the corresponding team process in Codex.
Execute the dev workflow from this AI development team preset. Use when the user writes /dev, asks for dev, or wants the corresponding team process in Codex.
Execute the fix workflow from this AI development team preset. Use when the user writes /fix, asks for fix, or wants the corresponding team process in Codex.
Execute the plan workflow from this AI development team preset. Use when the user writes /plan, asks for plan, or wants the corresponding team process in Codex.
Execute the project-preset workflow from this AI development team preset. Use when the user writes /project-preset, asks for project-preset, or wants the corresponding team process in Codex.
Execute the review-all workflow from this AI development team preset. Use when the user writes /review-all, asks for review-all, or wants the corresponding team process in Codex.
| name | code-review |
| description | 单文件代码审查方法,6 个维度逐项检查(正确性、安全性、性能、可维护性、测试、无障碍)。方法语言无关,无障碍仅前端适用。 |
本技能聚焦单文件内部的质量检查。跨文件一致性、变更完整性等由 /review-all 负责。 方法语言无关:下方示例为 TS,Python/其他语言同理套用对应写法;具体语言规则见
rules/。
查什么:逻辑是否正确、边界是否处理、错误是否捕获
怎么查:
常见问题:
// ❌ 未处理 null
const name = user.profile.name;
// ❌ 异步错误未 catch
const data = await fetch(url).then(r => r.json());
// ❌ 条件分支不完整
function getRole(user) {
if (user.isAdmin) return 'admin';
// 忘了处理普通用户的情况,返回 undefined
}
查什么:是否有注入、越权、密钥泄露等安全漏洞
怎么查:
$ 或 ` 模板字符串中拼接用户输入的位置innerHTML、dangerouslySetInnerHTML、JSX 中直接渲染用户输入exec、spawn、system 中拼接参数的位置OWASP Top 10 速查:
| 类别 | 检查项 | 搜索关键词 |
|---|---|---|
| 注入 | SQL/XSS/命令注入 | query(, innerHTML, exec( |
| 认证 | 密码哈希、Token 安全 | password, token, jwt |
| 授权 | 水平/垂直越权 | role, permission, userId |
| 密钥 | 无硬编码 | secret, key, password= |
| 输入 | 验证所有外部输入 | req.body, req.params, process.env |
查什么:是否有不必要的计算、查询、渲染
怎么查:
for/map/forEach 内的 await/query/fetchSELECT * 无 LIMITuseMemo、记忆化)常见问题:
// ❌ N+1 查询
for (const id of userIds) {
const user = await db.user.findUnique({ where: { id } });
}
// ❌ 每次渲染创建新对象
<Component style={{ color: 'red' }} />
// ❌ 无限制查询
const all = await db.logs.findMany(); // 百万行全查
查什么:代码是否清晰、是否易于修改
怎么查:
查什么:是否有测试、测试是否有意义
怎么查:
.test.ts 文件只对前端 UI 代码适用。后端 API、CLI、库、数据管道等跳过此维度(不算缺陷)。
查什么:UI 组件是否对辅助技术友好
怎么查:
aria-label 或可见文本alt 属性<button> 而非 <div onClick>)