注意
- Copilot 提示文件目前处于公共预览阶段,可能会有所更改。提示文件仅在 VS Code、Visual Studio 和 JetBrains IDE 中可用。请参阅关于自定义 GitHub Copilot 响应。
- 有关特定语言和场景的社区贡献提示文件示例,请参阅 Awesome GitHub Copilot Customizations 仓库。
此提示文件进行彻底的代码审查,并在 Copilot 聊天中提供结构化、可操作的反馈,生成一份完整的综合报告。
您也可以在 Visual Studio Code 中使用 Copilot 代码审查,请参阅 使用 GitHub Copilot 代码审查。Copilot 代码审查提供交互式、逐步的反馈,并在编辑器中嵌入可直接应用的注释,而此提示文件则提供带有教育性解释的完整报告。
代码审查提示
---
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.
---
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.
如何使用此提示文件
- 将上述内容保存为
review-code.prompt.md,放置在你的.github/prompts文件夹中。 - 在编辑器中打开你想要审查的代码文件。
- 在 Visual Studio Code 中,显示 Copilot Chat 视图并输入
/review-code,即可使用此提示文件触发自定义审查。你也可以通过键入例如focus=security来指定审查的关注重点。
延伸阅读
- 在 Visual Studio Code 中使用提示文件,位于 Visual Studio Code 文档中——有关如何创建和使用提示文件的信息
- 关于定制 GitHub Copilot 响应 - GitHub Copilot 响应定制概览
- 优秀的 GitHub Copilot 定制 - 社区贡献的自定义提示文件及其他针对特定语言和场景的定制仓库