← Prompt library

Code Review Prompt: Bugs, Evidence and Focused Fixes

Review a code snippet using its expected behavior, runtime and error details. Ask for reproducible findings, small fixes and useful tests.

Copyable promptPractical instructions
Code Review Prompt: Bugs, Evidence and Focused Fixes

Illustrative cover; not a verified result from this prompt.

Read the full prompt

Review the following code in [LANGUAGE AND VERSION]. Expected behavior: [BEHAVIOR]. Actual behavior or error: [OBSERVATION]. Code: [CODE]. Identify issues with line references and explain a reproducible failure or relevant assumption for each. Prioritize correctness and security before style. Propose the smallest useful fix, explain its tradeoffs and suggest tests for normal and boundary cases. Do not claim to have run code or measured performance unless execution evidence is supplied. Do not invent an employer or credentials.

Supply behavior, not just a code block

Include the language version, a small input and the expected result. Remove passwords, access tokens and private customer data before pasting. A focused function is easier to inspect than an entire application without context.

Example: an empty collection

Review this Python function: “def average(values): return sum(values) / len(values)”. Say that average([2, 4]) should return 3 and an empty list should raise a clear ValueError. Ask for the smallest change and two tests.

The important issue is division by zero on the empty input. Decide whether raising an error matches the caller's needs; returning zero would silently change the meaning. A reviewer should explain that choice instead of simply rating the code.

Validate the proposed fix

Run the relevant tests in your own environment and inspect the diff. Check whether new dependencies or changed return types affect callers. Performance claims need measurements on suitable data. If the answer lists speculative race conditions, ask which shared state and execution path make each one possible.