with one click
code-review
结构化代码审查框架,覆盖代码质量、安全性、性能和测试标准。适用于 PR 审查、代码质量检查、安全审计、性能分析等场景。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
结构化代码审查框架,覆盖代码质量、安全性、性能和测试标准。适用于 PR 审查、代码质量检查、安全审计、性能分析等场景。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Git初始化新仓库、提交与推送规范指南。执行git init/commit/push前必须调用,确保遵循用户审核、原子提交、精准文件选择等原则。
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
| name | code-review |
| description | 结构化代码审查框架,覆盖代码质量、安全性、性能和测试标准。适用于 PR 审查、代码质量检查、安全审计、性能分析等场景。 |
阅读 PR 描述:
确认改动范围:
检查 CI/CD 或本地运行测试:
npm test 或 yarn testpytest 或 python -m unittestcargo testgo test ./...mvn test 或 gradle test架构与设计:
代码组织:
跨文件一致性:
命名:
函数:
类与对象:
错误处理:
代码质量:
数据流追踪:
对关键数据(如 bookId、token、配置项),追踪从输入到使用的完整路径:
用户输入 → 函数A → 归一化/转换 → 函数B → 使用示例:审查 normalizeBookId 时,追踪所有获取 bookId 的路径:
路径1: --book-id 参数 → normalizeBookId() → bookId ✅
路径2: URL 正则提取 → extractBookId() → bookId ← 这条路径归一化了吗?
路径3: HTML 解析 → extractBookId() → normalizeBookId() → bookId ✅
契约验证:
对每个有文档声明(如 JSDoc @returns、Python docstring Returns:、JavaDoc @return 等)的函数,逐一检查所有 return 路径:
encodeId 格式,是否所有路径都确保了这个格式?输入校验:
防御深度:
normalize(input || extract(target)) 而非在内层函数中各自处理库函数鲁棒性:
导出给外部使用的函数,必须对异常输入做防御:
null / undefined 输入是否会导致崩溃?number 而非 string)是否有类型转换或明确报错?认证与授权:
数据保护:
依赖检查:
算法:
数据库:
缓存:
资源管理:
测试覆盖:
测试质量:
测试命名:
# 好的命名
def test_user_creation_with_valid_data_succeeds():
pass
# 差的命名
def test1():
pass
代码注释:
函数文档:
def calculate_total(items: List[Item], tax_rate: float) -> Decimal:
"""
Calculate the total price including tax.
Args:
items: List of items to calculate total for
tax_rate: Tax rate as decimal (e.g., 0.1 for 10%)
Returns:
Total price including tax
Raises:
ValueError: If tax_rate is negative
"""
pass
README/文档:
外部引用与工具推荐:
建设性反馈:
✅ 好的反馈:
"建议将这段逻辑提取为独立函数,以提高可测试性和可复用性:
def validate_email(email: str) -> bool:
return '@' in email and '.' in email.split('@')[1]
这样更容易测试,也能在整个代码库中复用。"
❌ 差的反馈:
"这是错的,重写。"
具体明确:
✅ 好的反馈:
"第 45 行的查询可能导致 N+1 问题。建议使用
.select_related('author') 在单次查询中获取关联对象。"
❌ 差的反馈:
"这里有性能问题。"
问题分级:
肯定好的工作:
"策略模式用得很好!这样以后添加新的支付方式会非常方便。"
上帝类:
# 差:一个类包揽一切
class UserManager:
def create_user(self): pass
def send_email(self): pass
def process_payment(self): pass
def generate_report(self): pass
魔法数字:
# 差
if user.age > 18:
pass
# 好
MINIMUM_AGE = 18
if user.age > MINIMUM_AGE:
pass
深层嵌套:
# 差
if condition1:
if condition2:
if condition3:
if condition4:
# 嵌套过深的代码
# 好(提前返回)
if not condition1:
return
if not condition2:
return
if not condition3:
return
if not condition4:
return
# 扁平的代码
SQL 注入:
# 差
query = f"SELECT * FROM users WHERE id = {user_id}"
# 好
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))
XSS:
// 差
element.innerHTML = userInput;
// 好
element.textContent = userInput;
硬编码密钥:
# 差
API_KEY = "sk-1234567890abcdef"
# 好
API_KEY = os.environ.get("API_KEY")
Linter & Formatter:
安全工具:
代码质量平台: