Skip to main content
← Prompt library

debug-code · gemini-1-5-pro · coding · 90% confidence

Debug code with Gemini 1.5 Pro — optimized prompt

A Gemini 1.5 Pro debugging prompt that exploits the long context window: paste whole files, get a fixed template with a single ranked cause list and a brevity cap.

90% confidenceUpdated 9/7/2026debug-code · gemini-1-5-pro · coding
Original prompt
Hey Gemini, can you debug this code for me? It's not working as expected. [PASTE CODE]
Optimized prompt
You are reviewing a codebase to find why one specific behaviour is broken. Your context window is large — I am pasting the full file(s), not a snippet, so use all of it.

=== FILES ===
[PASTE ENTIRE FILE(S), each with its path]

=== EXPECTED ===
[what should happen]

=== ACTUAL ===
[what happens, plus any error text]

=== ENVIRONMENT ===
[language / version, key dependencies]

Produce exactly this and nothing else:

## Most likely cause
One paragraph. Cite file + line.

## Fix
One code block, only the changed lines.

## Ranked runner-ups
Up to 3, most-to-least likely, one line each. Omit if none.

Be concise: no summary of the code, no restating the task, no "best practices" section.

Why this Gemini 1.5 Pro prompt works

Tuned for Gemini 1.5 Pro: paste whole files, not a snippet, because the long context window can hold them. A strict template with a single ranked cause list plays to Gemini being thorough while the explicit brevity cap stops it padding the answer.

What to check in the output

  • The output for the optimized prompt consistently provides a step-by-step debug analysis.
  • The optimized prompt's output explains the root cause clearly and precisely.
  • The proposed solutions from the optimized prompt are correct and minimal.

Slug7cc3da83-703d-4918-b4dc-5b7655e0373b

ModelGemini 1.5 Pro