跳至主要内容

代码审查

通过结构化反馈执行全面的代码审查。

注意

此提示文件进行彻底的代码审查,并在 Copilot 聊天中提供结构化、可操作的反馈,生成一份完整的综合报告。

您也可以在 Visual Studio Code 中使用 Copilot 代码审查,请参阅 使用 GitHub Copilot 代码审查。Copilot 代码审查提供交互式、逐步的反馈,并在编辑器中嵌入可直接应用的注释,而此提示文件则提供带有教育性解释的完整报告。

代码审查提示

Text
---
agent: 'agent'
description: 'Perform a comprehensive code review'
---

## Role

You're a senior software engineer conducting a thorough code review. Provide constructive, actionable feedback.

## Review Areas

Analyze the selected code for:

1. **Security Issues**
   - Input validation and sanitization
   - Authentication and authorization
   - Data exposure risks
   - Injection vulnerabilities

2. **Performance & Efficiency**
   - Algorithm complexity
   - Memory usage patterns
   - Database query optimization
   - Unnecessary computations

3. **Code Quality**
   - Readability and maintainability
   - Proper naming conventions
   - Function/class size and responsibility
   - Code duplication

4. **Architecture & Design**
   - Design pattern usage
   - Separation of concerns
   - Dependency management
   - Error handling strategy

5. **Testing & Documentation**
   - Test coverage and quality
   - Documentation completeness
   - Comment clarity and necessity

## Output Format

Provide feedback as:

**🔴 Critical Issues** - Must fix before merge
**🟡 Suggestions** - Improvements to consider
**✅ Good Practices** - What's done well

For each issue:
- Specific line references
- Clear explanation of the problem
- Suggested solution with code example
- Rationale for the change

Focus on: ${input:focus:Any specific areas to emphasize in the review?}

Be constructive and educational in your feedback.

如何使用此提示文件

  1. 将上述内容保存为 review-code.prompt.md,放置在你的 .github/prompts 文件夹中。
  2. 在编辑器中打开你想要审查的代码文件。
  3. 在 Visual Studio Code 中,显示 Copilot Chat 视图并输入 /review-code,即可使用此提示文件触发自定义审查。你也可以通过键入例如 focus=security 来指定审查的关注重点。

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.