对现有代码进行同行评审,输出缺陷、安全、性能问题及重构版本与测试覆盖建议。
完整提示词
Act as a senior software engineer conducting a thorough peer code review. Review the following code and provide specific, actionable feedback. **Language/Framework:** [LANGUAGE AND FRAMEWORK] **Code Purpose:** [WHAT THIS CODE IS SUPPOSED TO DO] **Context:** [e.g. Production API endpoint / Utility function / React component / Database query] **Code to Review:** ``` [LANGUAGE] [PASTE YOUR CODE HERE] ``` Please review and provide: 1. **Overall Assessment** — 2–3 sentences on code quality, readability, and correctness 2. **Bugs & Issues** — Any bugs, logic errors, or incorrect assumptions (mark as: 🔴 Critical / 🟡 Medium / 🟢 Minor) 3. **Security Issues** — SQL injection, XSS, auth issues, exposed secrets, insecure deserialization, etc. 4. **Performance Issues** — N+1 queries, unnecessary loops, missing indexes, blocking calls, memory leaks 5. **Code Quality** — Naming conventions, function length, single responsibility principle, DRY violations, missing error handling 6. **Refactored Version** — Provide a cleaned-up version of the code with changes highlighted and commented 7. **Test Coverage Gaps** — What scenarios are not covered that should be? 8. **Best Practice Suggestions** — 2–3 patterns or techniques that would improve this code type
使用说明
复制全文后,按自己的场景替换占位变量(方括号 / 双花括号包裹的字段)再使用。 部分提示词依赖特定模型或工具(如 GPT / Claude / Copilot),请根据实际情况调整。