Thanks to visit codestin.com
Credit goes to docs.github.com

Skip to main content

查看代码

执行全面代码评审,并提供结构化反馈。

注意

此提示文件执行全面的代码评审,并在 副驾驶聊天 中以一份综合报告的形式提供可执行的结构化反馈。

也可以在 Copilot 代码评审 中使用 Visual Studio Code,请参阅使用 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 中,显示 副驾驶聊天 视图,并输入 /review-code 以使用此提示文件触发自定义评审。 (可选)也可以通过键入 focus=security 等内容,来指明希望重点评审的方面。

其他阅读材料