
关于
AI 驱动的代码审查专家,结合自动化静态分析、智能模式识别和现代 DevOps 实践。利用 AI 工具进行全面代码质量评估。
name: performance-testing-review-ai-review description: "AI 驱动的代码审查专家,结合自动化静态分析、智能模式识别和现代 DevOps 实践。利用 AI 工具(GitHub Copilot、Qodo、GPT-5、Claude 4.5 Sonnet)配合成熟平台(SonarQube、CodeQL、Semgrep)识别缺陷、漏洞和性能问题。" risk: unknown source: community date_added: "2026-02-27"
AI 驱动的代码审查专家
结合自动化静态分析、智能模式识别和现代 DevOps 实践的 AI 代码审查专家。利用 AI 工具(GitHub Copilot、Qodo、GPT-5、Claude 4.5 Sonnet)配合成熟平台(SonarQube、CodeQL、Semgrep)识别缺陷、漏洞和性能问题。
适用场景
- 处理 AI 驱动的代码审查任务或工作流
- 需要 AI 代码审查的指导、最佳实践或检查清单
不适用场景
- 任务与 AI 代码审查无关
- 需要其他领域或工具
操作说明
- 明确目标、约束和所需输入。
- 应用相关最佳实践并验证结果。
- 提供可操作的步骤和验证方法。
- 如需详细示例,请打开
resources/implementation-playbook.md。
上下文
多层代码审查工作流与 CI/CD 流水线集成,在 Pull Request 上提供即时反馈,架构决策保留人工审核。跨 30+ 种语言的审查结合了基于规则的分析和 AI 辅助的上下文理解。
需求
审查:$ARGUMENTS
执行全面分析:安全性、性能、架构、可维护性、测试和 AI/ML 特定关注点。生成带有行号引用、代码示例和可操作建议的审查评论。
自动化代码审查工作流
初始分类
- 解析 diff 确定修改的文件和受影响的组件
- 将文件类型匹配到最优的静态分析工具
- 根据 PR 大小调整分析深度(>1000 行浅层分析,<200 行深度分析)
- 分类变更类型:功能、缺陷修复、重构或破坏性变更
多工具静态分析
并行执行:
- CodeQL:深度漏洞分析(SQL 注入、XSS、认证绕过)
- SonarQube:代码异味、复杂度、重复、可维护性
- Semgrep:组织特定规则和安全策略
- Snyk/Dependabot:供应链安全
- GitGuardian/TruffleHog:密钥检测
AI 辅助审查
# Context-aware review prompt for Claude 4.5 Sonnet
review_prompt = f"""
You are reviewing a pull request for a {language} {project_type} application.
**Change Summary:** {pr_description}
**Modified Code:** {code_diff}
**Static Analysis:** {sonarqube_issues}, {codeql_alerts}
**Architecture:** {system_architecture_summary}
Focus on:
1. Security vulnerabilities missed by static tools
2. Performance implications at scale
3. Edge cases and error handling gaps
4. API contract compatibility
5. Testability and missing coverage
6. Architectural alignment
For each issue:
- Specify file path and line numbers
- Classify severity: CRITICAL/HIGH/MEDIUM/LOW
- Explain problem (1-2 sentences)
- Provide concrete fix example
- Link relevant documentation
Format as JSON array.
"""
模型选择(2025)
- 快速审查(<200 行):GPT-4o-mini 或 Claude 4.5 Haiku
- 深度推理:Claude 4.5 Sonnet 或 GPT-4.5(200K+ tokens)
- 代码生成:GitHub Copilot 或 Qodo
- 多语言:Qodo 或 CodeAnt AI(30+ 种语言)
审查路由
interface ReviewRoutingStrategy {
async routeReview(pr: PullRequest): Promise<ReviewEngine> {
const metrics = await this.analyzePRComplexity(pr);
if (metrics.filesChanged > 50 || metrics.linesChanged > 1000) {
return new HumanReviewRequired("Too large for automation");
}
if (metrics.securitySensitive || metrics.affectsAuth) {
return new AIEngine("claude-3.7-sonnet", {
temperature: 0.1,
maxTokens: 4000,
systemPrompt: SECURITY_FOCUSED_PROMPT
});
}
if (metrics.testCoverageGap > 20) {
return new QodoEngine({ mode: "test-generation", coverageTarget: 80 });
}
return new AIEngine("gpt-4o", { temperature: 0.3, maxTokens: 2000 });
}
}
架构分析
架构一致性
- 依赖方向:内层不依赖外层
- SOLID 原则:
- 单一职责、开闭原则、里氏替换
- 接口隔离、依赖倒置
- 反模式:
- 单例(全局状态)、上帝对象(>500 行,>20 个方法)
- 贫血模型、散弹式修改
微服务审查
type MicroserviceReviewChecklist struct {
CheckServiceCohesion bool // Single capability per service?
CheckDataOwnership bool // Each service owns database?
CheckAPIVersioning bool // Semantic versioning?
}
兼容工具
Claude CodeCursor
标签
AI与机器学习