Prompt Library 💻 Coding & Dev Explain Code
GPT-4o 💻 Coding & Dev Basic

Explain Code

Get a clear, thorough explanation of any code snippet, function, or module in plain language.
👁 3 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Explain Code

You are a senior software engineer and technical educator. Explain the following code clearly and thoroughly so that a developer of [AUDIENCE_LEVEL] can fully understand it.

## Code to Explain
```
[PASTE_CODE_HERE]
```

## Context
- **Programming language:** [LANGUAGE]
- **Where this code lives in the project:** [CONTEXT — e.g., API route handler, database migration, React component, utility function]
- **My experience level:** [LEVEL — junior / mid-level / senior / non-developer]
- **Specific parts I find confusing:** [CONFUSING_PARTS]

## Explanation Structure

### 1. Plain Language Summary
In 2–3 sentences, explain what this code does as if explaining to someone who does not code. No jargon.

### 2. Purpose and Context
Explain why this code exists — what problem it solves and where it fits in the larger system.

### 3. Line-by-Line Walkthrough
Walk through the code section by section (or line by line for short snippets). For each meaningful block:
- What it does
- Why it does it this way
- Any important assumptions or dependencies

### 4. Key Concepts Explained
Identify any programming concepts, patterns, or language features used in this code (e.g., closures, async/await, recursion, dependency injection) and explain each in clear terms.

### 5. Inputs, Outputs, and Side Effects
- What does this code take as input?
- What does it return or produce?
- Does it have any side effects (writing to a database, making API calls, modifying state)?

### 6. Potential Issues or Edge Cases
Point out any bugs, performance concerns, security vulnerabilities, or edge cases I should be aware of.

### 7. How I Would Improve It
Suggest 2–3 improvements to make this code cleaner, more efficient, or more maintainable.

📝 Fill in the blanks

Replace these placeholders with your own content:

[AUDIENCE_LEVEL]
[PASTE_CODE_HERE]
[LANGUAGE]
[CONTEXT — e.g., API route handler, database migration, React component, utility function]
[LEVEL — junior / mid-level / senior / non-developer]
[CONFUSING_PARTS]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.