Ask, Then Think: Does Socratic Prompting Help LLMs on Code Tasks?
Antonio Della Porta, Jonan Richards, Lucageneroso Cammarota, Stefano Lambiase, Fabio Palomba, Mairieli Wessel
Large Language Models (LLMs) are widely used for software engineering tasks such as code generation, repair, and explanation, yet they remain error-prone when instructions are ambiguous, relevant information is missing, or initial assumptions are incorrect. Existing prompting strategies can structure the reasoning process, but they do not explicitly encourage models to question their own assumptions and intermediate conclusions. Motivated by the possibility of operationalizing theories of human reasoning to steer LLM behavior, we introduce MIND, a prompting framework that translates principles of classical Socratic reasoning into a structured self-interrogation process for LLMs. We evaluated MIND across 12 LLMs from four model families and three size categories on four benchmarks covering code generation, repair, explanation, and efficiency, comparing it with Chain-of-Thought, Self-Ask, Self-Refine, and ReAct. We further conducted an ablation study to disentangle the contribution of the individual Socratic reasoning components. Our results show that MIND does not outperform established prompting strategies. It falls below Chain-of-Thought, which achieves the highest average performance, as well as below Self-Refine and, in most settings, Self-Ask, while introducing substantial inference-time overhead. MIND is ahead of ReAct overall, mostly because of its advantage on code efficiency, but not on every benchmark, and its gap to the strongest baselines narrows only for the largest models. The ablation analysis shows that most Socratic components do not pay off, as removing them often improves performance and only premise seeking seems to impact positively more often than the others. Overall, our findings indicate that transferring a theory of human reasoning into a prompt as a whole does not improve LLM performance on code tasks, and that any benefit depends on selecting the few mechanisms that actually support the model’s reasoning.