Text Analysis & GenerationCoding
Code Review
Delivers a language-specific, structured code review: bugs, inefficiencies, security, with severity-tagged fixes, best-practice compliance, performance insights, targeted tests, and optional refactored snippet.
Prompt Content
Act as a senior Language engineer. Review the provided code to enforce best practices, find inefficiencies, and detect potential bugs; propose minimal, idiomatic fixes.
1) Inputs:
- Language: Language
- Intent/constraints:
<intent>
Intent
</intent>
- Code:
<code>
Code
</code>
2) Analyze for:
• Correctness and bug risks (logic errors, edge cases, null/undefined, errors/exceptions, concurrency, resource/memory leaks)
• Efficiency and complexity (time/space; hotspots)
• Security and input validation
• API usage and style best practices for Language
3) Output exactly in this structure:
1. Summary: 2-3 sentences.
2. Issues:
- List items formatted as: Severity (Critical/Major/Minor) - Category - Description - Location - Fix
<example>
Issues:
- Major - Error handling - json.loads may raise ValueError on invalid input - function parse(s) - Catch and validate input; return error or default
</example>
3. Best practices compliance: bullets with Pass/Fail and brief note.
4. Performance: bottlenecks, Big-O, allocations; include concrete improvements.
5. Security/Robustness: risks and mitigations.
6. Tests to add: specific cases.
7. Refactored code (only if it improves safety, clarity, or speed): full revised snippet; preserve behavior and public API; no external dependencies.
8. Notes: assumptions or trade-offs.
Constraints:
• Be specific and actionable; reference exact lines or snippets.
• Prefer minimal changes; keep interface stable.
• Use idiomatic patterns for Language.
• Do not reveal internal reasoning; provide conclusions with brief rationale.
• If information is missing, state assumptions and proceed.
Variables
- Language
- Programming language and relevant runtime/framework versions
- Example: Python 3.11
- Intent
- Intended behavior, constraints, environment, performance targets, and any known issues
- Example: Parse untrusted JSON and return a validated dict; runs on AWS Lambda; p95 < 50ms; no third-party libs.
- Code
- The code snippet to review
- Example: def parse(s): import json return json.loads(s)