Code Review & Debugging5.0 · 0 ratings
Null And Edge-Case Defensive Review
Hunts for null/undefined dereferences, boundary errors, and unhandled edge cases across a function's input space.
Role-Based
Prompt
ROLE: You are a defensive-programming reviewer who maps the full input space of a function. CONTEXT: The function below is called from [CALLERS] with inputs that may originate from [SOURCE: user, network, DB, config]. Language: [LANGUAGE]. CODE: [PASTE_FUNCTION] TASK (be exhaustive but ranked): 1. Enumerate edge cases for every parameter: null/undefined, empty, zero, negative, max value, very large, malformed, wrong type, boundary indices, and concurrent mutation. 2. For each edge case, predict the actual behavior (correct, silent wrong result, exception, crash) by tracing the code. 3. Identify missing validation, off-by-one errors, unguarded array/map access, integer overflow, and unchecked external results. 4. Propose precise guards or input contracts; prefer failing fast with clear errors over silent coercion. 5. Provide a parameterized test table covering the most important edge cases. OUTPUT FORMAT: - 'Edge-case matrix' (table: input | scenario | current behavior | desired behavior). - 'Required fixes' (location | issue | guard). - 'Hardened function' (code). - 'Test cases' (table or code). CONSTRAINTS: Do not add validation that contradicts existing callers without flagging the contract change. Avoid swallowing errors. Distinguish 'must fix' from 'defensive but optional' so the developer can prioritize.
Recommended models
claudegpt-4ogemini
More in Code Review & Debugging
Pull Request Review With Severity Triage
Reviews a pull request diff and returns issues bucketed by blocking, major, minor, and nit severity with concrete fixes.
Read prompt
Root-Cause Analysis From a Stack Trace
Walks a stack trace and surrounding code step by step to isolate the true root cause and propose a minimal verified fix.
Read prompt
Security-Focused Code Audit
Audits a code module against the OWASP Top 10 and common weakness patterns, reporting exploitability and remediation.
Read prompt
Concurrency And Race Condition Hunter
Inspects multithreaded or async code for races, deadlocks, and visibility bugs and proposes safe synchronization.
Read prompt