{"meta":{"title":"查看代码","intro":"执行全面代码评审，并提供结构化反馈。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/tutorials","title":"教程"},{"href":"/zh/copilot/tutorials/customization-library","title":"定制化库"},{"href":"/zh/copilot/tutorials/customization-library/prompt-files","title":"提示文件"},{"href":"/zh/copilot/tutorials/customization-library/prompt-files/review-code","title":"查看代码"}],"documentType":"article"},"body":"# 查看代码\n\n执行全面代码评审，并提供结构化反馈。\n\n> \\[!NOTE]\n>\n> * Copilot 提示文件为 公共预览版，可能随时更改。 提示文件仅适用于 VS Code、Visual Studio 和 JetBrains IDE。请查看 [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/prompting/response-customization#about-prompt-files)。\n> * 如需获取社区提供的有关特定语言和场景的提示文件示例，请参阅[出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md)仓库。\n\n此提示文件执行全面的代码评审，并在 副驾驶聊天 中以一份综合报告的形式提供可执行的结构化反馈。\n\n也可以在 Copilot 代码评审 中使用 Visual Studio Code，请参阅[使用 GitHub Copilot 代码审查](/zh/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=vscode)。 Copilot 代码评审 提供交互式的分步反馈，附带可直接应用的编辑器行内注释；而此提示文件提供包含教学说明的综合报告。\n\n## 代码评审提示\n\n```text copy\n---\nagent: 'agent'\ndescription: 'Perform a comprehensive code review'\n---\n\n## Role\n\nYou're a senior software engineer conducting a thorough code review. Provide constructive, actionable feedback.\n\n## Review Areas\n\nAnalyze the selected code for:\n\n1. **Security Issues**\n   - Input validation and sanitization\n   - Authentication and authorization\n   - Data exposure risks\n   - Injection vulnerabilities\n\n2. **Performance & Efficiency**\n   - Algorithm complexity\n   - Memory usage patterns\n   - Database query optimization\n   - Unnecessary computations\n\n3. **Code Quality**\n   - Readability and maintainability\n   - Proper naming conventions\n   - Function/class size and responsibility\n   - Code duplication\n\n4. **Architecture & Design**\n   - Design pattern usage\n   - Separation of concerns\n   - Dependency management\n   - Error handling strategy\n\n5. **Testing & Documentation**\n   - Test coverage and quality\n   - Documentation completeness\n   - Comment clarity and necessity\n\n## Output Format\n\nProvide feedback as:\n\n**🔴 Critical Issues** - Must fix before merge\n**🟡 Suggestions** - Improvements to consider\n**✅ Good Practices** - What's done well\n\nFor each issue:\n- Specific line references\n- Clear explanation of the problem\n- Suggested solution with code example\n- Rationale for the change\n\nFocus on: ${input:focus:Any specific areas to emphasize in the review?}\n\nBe constructive and educational in your feedback.\n```\n\n## 如何使用此提示文件\n\n1. 将上述内容另存为 `review-code.prompt.md`，并将其保存在 `.github/prompts` 文件夹中。\n2. 在编辑器中打开要评审的代码文件。\n3. 在 Visual Studio Code 中，显示 副驾驶聊天 视图，并输入 `/review-code` 以使用此提示文件触发自定义评审。 （可选）也可以通过键入 `focus=security` 等内容，来指明希望重点评审的方面。\n\n## 其他阅读材料\n\n* Visual Studio Code 文档中的[使用 Visual Studio Code 中的提示文件](https://code.visualstudio.com/docs/copilot/customization/prompt-files) - 有关如何创建和使用提示文件的信息\n* [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/response-customization) - GitHub Copilot 中的响应自定义概述\n* [出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.prompts.md) - 社区提供的自定义提示文件的仓库以及特定语言和场景的其他自定义内容"}