Coding & Software
Write Unit Tests for a Function
Generates focused unit tests for one function, covering normal cases, boundaries and invalid input without mocking more than needed.
- Customizable fields
- 3 fields
Coding & Software
A structured review prompt that checks correctness, failure handling, security and tests, and labels every finding by severity.
Designed for general-purpose AI assistantsPublished November 2026
Fill in the fields and the prompt updates. What you type stays in this page and is never saved or sent.
You are a careful senior {{programming language}} reviewer. Review the change below as if you will be on call for it.
What the change should do: {{what the change should do}}
Review in this order, and skip any category where you find nothing:
1. Correctness: logic errors, off-by-one mistakes, unhandled edge cases, wrong assumptions.
2. Failure handling: swallowed errors, missing validation, unsafe retries or timeouts.
3. Security: injection, exposed secrets, unsafe deserialization, missing authorization checks.
4. Performance: needless work in hot paths, N+1 queries, unbounded memory use.
5. Readability and tests: unclear names, and missing tests for the risky paths.
For every finding give the line or snippet, why it matters, and a concrete fix. Label each finding Blocker, Should fix, or Nit. If you are unsure about something, say what you would need to see to be sure instead of guessing. Finish with a one-sentence verdict: approve, approve with changes, or request changes.
Code to review:
{{code}}3 required fields are empty and will stay as a {{placeholder}} in the copied text.
Illustrative only. Real answers depend on your input and the assistant you use.
Blocker: retry loop in fetchInvoice (lines 41-52) Why it matters: the loop retries every error, including 400 responses, with no delay and no limit. A malformed request will spin until the process is killed. Fix: retry only on 429 and 5xx, cap attempts at 3, and wait with exponential backoff. Should fix: missing authorization check in deleteInvoice (line 88) Why it matters: the handler checks that the user is signed in but not that the invoice belongs to them. Fix: load the invoice with the user id in the query and return 404 when it is not found. Nit: the variable "d" in formatTotals (line 63) is easy to misread; "discount" would be clearer. Verdict: request changes. The retry loop and the missing ownership check should be fixed before merging.
Coding & Software
Generates focused unit tests for one function, covering normal cases, boundaries and invalid input without mocking more than needed.
Coding & Software
Paste an error and the code around it to get ranked causes, the smallest fix and a quick check to confirm the diagnosis.
Coding & Software
Turns a diff and a ticket into a pull request description with context, changes, risk and a test plan that reviewers can follow.