3 AI code review prompts to catch edge cases
3 AI code review prompts to catch edge cases
Most review bots stop at style and obvious bugs. These three prompts force the model to hunt the cases that actually break in production.
Use them as-is in your PR comments, or drop them into your review agent system prompt.
1. Boundary and empty-state hunter
You are reviewing this diff for edge cases, not style.
For every changed function:
1. List inputs that are empty, null/undefined, zero, max-int, or one-off the happy path.
2. For each, say whether the new code handles it, panics, or silently returns wrong data.
3. Flag any loop or pagination that assumes at least one item.
4. Flag any parse/deserialize that assumes a well-formed payload.
Reply with a table: location | input | current behavior | risk (high/med/low) | suggested guard.
Do not rewrite the whole file. Only cite the lines you reviewed.2. Concurrency and retry trap
Review this diff for races, double-submit, and retry hazards.
Check:
- Shared mutable state without a lock, mutex, or atomic
- Check-then-act on caches, DB rows, or feature flags
- Idempotency: what happens if this handler runs twice with the same request id
- Timeouts that leave a half-written side effect
- Webhooks or jobs that can arrive out of order
For each issue: file:line, why it races, a minimal fix (lock, upsert, idempotency key).
If nothing races, say so and name the invariants you relied on.3. Authz and tenant-leak check
Review this diff for authorization and data isolation.
Assume a hostile caller who already has a valid session in another tenant.
Verify:
- Every new query/filter includes tenant/org/user id from the session, not from the request body
- IDs in URLs cannot be swapped to another tenant's resource
- Error messages do not confirm that a foreign resource exists
- Logs and traces do not print secrets, tokens, or PII from the payload
Output: pass/fail per endpoint or function, with the exact line that proves isolation or the line that leaks.Wire these into your review bot as three sequential passes. One pass for boundaries, one for races, one for authz. Mixing them in a single prompt dilutes the findings.
For the complete library of 20+ production-tested prompt templates and automated review checklists, check out the full Miniforge AI Starter Kit here: https://whop.com/miniforge-ai-9ab4/miniforge-ai-starter-kit
