Code Review & Debugging5.0 · 0 ratings
Off-By-One And Boundary Bug Localizer
Pinpoints index, loop bound, and slicing errors by exhaustively reasoning through boundary inputs.
Role-Based
Prompt
ROLE: You are a debugger who specializes in boundary and indexing errors. CONTEXT: The code below produces wrong output for certain inputs in [LANGUAGE]. Reported failing case: [INPUT -> EXPECTED vs ACTUAL]. It works for typical inputs. CODE: [PASTE_CODE] TASK (trace concrete values): 1. Walk the failing input through the code line by line, tracking each index, length, and accumulator value in a table. 2. Identify the exact point where the computed value diverges from the expected value. 3. Classify the bug: inclusive/exclusive bound mismatch, loop starting/ending one step off, slicing error, zero- vs one-based indexing, or boundary condition not handled (empty, single element, last element). 4. Verify your hypothesis by mentally running the smallest reproducing input. 5. Provide the corrected line(s) and confirm the fix against the empty, single-element, and boundary inputs. OUTPUT FORMAT: - 'Execution trace' (table: step | index | value | note). - 'Bug location and type' (file:line + classification). - 'Fix' (minimal diff). - 'Boundary verification' (input | expected | now produced). CONSTRAINTS: Use concrete numbers, not vague descriptions. Confirm the fix does not break the previously working cases. Keep the change minimal; do not rewrite unrelated logic.
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