Explain code, execution flow and side effects
Understand what existing code accepts, returns and changes, without asking for an unnecessary rewrite.
What to provide
- The code, its language and relevant runtime or library versions.
- Enough surrounding context to understand referenced functions and values.
Example Illustrative example
Input
Illustrative editorial example — not a recorded model test. JavaScript: const doubled = [1, 2, 3].map(n => n * 2); Detail level: beginner.
Output
The array contains 1, 2 and 3. map calls the supplied function for each value and creates a new array from the returned values. Multiplication by 2 produces doubled = [2, 4, 6]. The expression does not perform network or file operations. This explanation assumes standard JavaScript Array.map behaviour.
Improve the result
- List what cannot be determined from this snippet and suggest small checks to confirm its behaviour.
How to use this prompt
Include the call site and relevant types when the snippet relies on outside values. Ask for unknown dependencies to be listed rather than guessed.
What to check in the result
Reading code is not the same as executing it. Hidden dependencies, runtime state and omitted configuration can change behaviour.