注意
- Copilot prompt files are in 公共预览版 and subject to change. Prompt files are only available in VS Code. See 关于自定义 GitHub Copilot 聊天助手响应.
- For community-contributed examples of prompt files for specific languages and scenarios, see the Awesome GitHub Copilot Customizations repository.
此提示文件执行全面的代码评审,并在 Copilot 对话助手 中以一份综合报告的形式提供可执行的结构化反馈。
也可以在 Visual Studio Code 中使用 Copilot 代码评审,请参阅使用 GitHub Copilot 代码评审。 Copilot 代码评审 提供交互式的分步反馈,附带可直接应用的编辑器行内注释;而此提示文件提供包含教学说明的综合报告。
代码评审提示
--- mode: '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.
---
mode: '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.
如何使用此提示文件
- 在你的
.github/prompts
文件夹中将上述内容另存为review-code.prompt.md
。 - 在编辑器中打开要评审的代码文件。
- 在 Visual Studio Code 中,显示 Copilot 对话助手 视图,并输入
/review-code
以使用此提示文件触发自定义评审。 (可选)也可以通过键入focus=security
等内容,来指明希望重点评审的方面。
Further reading
- Use prompt files in Visual Studio Code in the Visual Studio Code documentation - Information on how to create and use prompt files
- 关于自定义 GitHub Copilot 聊天助手响应 - Overview of response customization in GitHub Copilot
- Awesome GitHub Copilot Customizations - Repository of community-contributed custom prompt files and other customizations for specific languages and scenarios