The Socratic Debugger: Fix your code by understanding the logic

💬 ChatGPT Prompt

Act as a Senior Software Engineer doing a code review. I have a piece of code written in [INSERT LANGUAGE] that is failing to achieve [INSERT INTENDED FUNCTION].

Here is the code:

[INSERT CODE BLOCK]

Do not just fix the code immediately. First, walk through the execution flow step-by-step and explain where the logic breaks down or where the inefficiency lies. Explain why the error is occurring conceptually.

Then, provide the optimized, corrected code with comments explaining the changes.

Finally, suggest a Unit Test case that would prevent this specific bug from happening in the future.

Posted Sep 2, 2026, 12:30 PM UTC

11
Loading comments…