Learning to read code is just as important as writing it. These prompts help you understand unfamiliar code at any level of detail.
General Explanations
Explain this code to someone who's been coding for about [3 months / 1 year / just started]:
[paste code]
Break it down line by line. Explain what each part does and why it's there. Use simple analogies if helpful.
Give me a quick overview of what this code does:
[paste code]
In 2-3 sentences, explain the purpose and main logic. Don't go line by line, just the big picture.
Do a deep dive on this code:
[paste code]
Cover:
1. What it does overall
2. How the data flows through it
3. Any patterns or techniques being used
4. Potential edge cases or gotchas
5. How you'd improve it
Specific Concepts
I don't understand this syntax:
[paste the confusing part]
What does this syntax mean? When would you use it? Show me a simpler example of the same thing.
This code uses [specific technique, e.g., "recursion" or "reduce" or "closure"]:
[paste code]
Why was this approach chosen? What are the alternatives, and when would each be better?
Walk me through exactly what happens when this code runs with this input:
Code:
[paste code]
Input: [paste example input]
Show each step, what variables hold at each point, and the final output.
Learning & Context
I found this code and don't fully understand it:
[paste code]
What concepts or topics should I study to understand this better? Give me specific things to Google or learn about.
I've seen two ways to do the same thing:
Version A:
[paste first approach]
Version B:
[paste second approach]
What's the difference? Which is better and why? When would you use each?
Add clear comments to this code explaining what each part does:
[paste code]
Don't change the code, just add comments that would help someone new understand it.