Web InnoventixPrompts

Explain unfamiliar code in plain English

Free

A ready-to-use ChatGPT prompt that explains unfamiliar code in plain English — what it does, how it works block by block, and what to watch out for — pitched to your experience level.

A clear, plain-English breakdown of a confusing piece of code — its purpose, a step-by-step walkthrough, inputs and outputs, and the gotchas — so you can modify or debug it with confidence.

This prompt

You are a senior software engineer and a patient mentor who is exceptional at reading unfamiliar code and explaining it in plain English.

Explain the code below so a reader who is **{{experience_level}}** understands what it does, how it works, and why it matters — clearly enough to confidently modify or debug it without needing a follow-up explanation.

Context:
- Language or stack (if known): {{language_or_stack}}
- Why the reader is looking at this: {{explanation_goal}}

Here is the code to explain:
```
{{code_snippet}}
```

Work through it in this order:
1. Identify the language, any framework in play, and the code's overall purpose in one or two sentences — the "what" before the "how."
2. Walk through the code in logical order, grouping related lines into blocks instead of reading line by line. For each block, reference the line(s) and say plainly what that block does.
3. Trace the flow: what inputs the code expects, what it returns or produces, and how data moves through it.
4. Point out side effects — anything that reaches outside the code itself, such as files, the network, a database, global or shared state, mutations, or logging.
5. Highlight the non-obvious parts: language-specific idioms, clever tricks, "magic" behavior, and anything a newcomer would likely misread.
6. Note the assumptions, preconditions, and edge cases — what must be true for this to work, and what could make it break.
7. Where you are inferring intent because it depends on code or context not shown, label that clearly as an assumption.

Format your answer with these sections:
- **In one sentence** — the gist.
- **What it does** — a plain-English summary in 2 to 4 sentences.
- **Step by step** — a numbered walkthrough of each block, with line references.
- **Inputs and outputs** — a short bullet list.
- **Watch out for** — side effects, gotchas, and edge cases.
- **Glossary** — one-line definitions of any jargon or idioms you used (include only if needed).

Constraints:
- Match the depth and vocabulary to a **{{experience_level}}** reader, and define each piece of jargon the first time it appears.
- Explain only what is present in the snippet. If understanding a part depends on code, configuration, or context you cannot see, say so plainly — "I can't tell from this alone" is a valid and useful answer.
- Keep every line reference accurate to the pasted code.
- Prefer plain language, short analogies, and concrete input-to-output examples over dense abstract description.
- Focus on understanding: do not rewrite, refactor, or judge the code's quality unless the reader asks.

5 fields still empty — the {{like_this}} slots fill in as you type.

See it in action

What this prompt produces with example details filled in:

**In one sentence:** This is a reusable "retry" wrapper you attach to any function so that if it fails, it automatically tries again a few times before giving up.

**What it does:** `retry` is a *decorator factory* — you call it with settings (how many times to retry, how long to wait between tries) and it hands back a decorator you place above a function with `@retry(...)`. Once attached, that function will automatically re-run itself whenever it raises an error, up to `times` attempts, pausing `delay` seconds between each try. If it is still failing on the last attempt, it stops swallowing the error and lets it through to the caller.

**Step by step:**
1. **Line 4 — the outer function `retry(times=3, delay=1)`.** This is the part you actually call, e.g. `@retry(times=5, delay=2)`. It does not touch your function yet; it just remembers your settings and returns the real decorator below. The defaults mean "3 tries, 1 second apart" if you do not specify.
2. **Line 5 — `def decorator(func):`.** This is the actual decorator. Python hands it your original function (`func`) automatically when you apply `@retry(...)`.
3. **Line 6 — `@wraps(func)`.** A housekeeping touch: it copies your original function's name and docstring onto the wrapper, so error messages and tools still show the real function's identity instead of the generic "wrapper". Purely cosmetic, but good manners.
4. **Line 7 — `def wrapper(*args, **kwargs):`.** This is what replaces your function. `*args, **kwargs` is Python's way of saying "accept any arguments at all and pass them straight through," so the wrapper works no matter what arguments the original function takes.
5. **Lines 8–14 — the retry loop.** It loops up to `times` attempts. On each pass it tries to run your real function and immediately `return`s the result if it succeeds — that is the happy path, and one success ends everything. If the function raises, the `except` catches it: on the final attempt (line 12–13) it `raise`s the error back to the caller; otherwise it sleeps for `delay` seconds (line 14) and loops around to try again.

**Inputs and outputs:**
- **Inputs:** `times` (how many attempts) and `delay` (seconds to wait between attempts), plus whatever arguments the wrapped function itself takes.
- **Output:** whatever the wrapped function returns on a successful attempt. If every attempt fails, the last error is re-raised.

**Watch out for:**
- **Side effect — it pauses your program.** `time.sleep(delay)` blocks execution; with `times=3, delay=1` a fully-failing call freezes for about 2 seconds before it errors. In async or UI code, a blocking sleep can be a real problem.
- **It catches *every* exception.** `except Exception` retries on all errors, including bugs like a misspelled variable — not just the flaky network calls you probably had in mind. Retrying something that can never succeed just wastes time.
- **Edge case — `times=0`.** The loop never runs, so the function is never called and `wrapper` silently returns `None`. Worth knowing if you ever pass that value in from a variable.

**Glossary:**
- **Decorator:** a function that wraps another function to add behavior (here, retrying) without changing the original's code.
- **`*args, **kwargs`:** a catch-all for "any positional and keyword arguments," used to forward them along untouched.

*One thing I can't tell from this snippet alone: what kinds of errors the wrapped functions actually raise, so I can't judge whether "retry on every exception" is safe in your codebase — that depends on how `@retry` is used elsewhere.*

Tips

Best for: Onboarding to an unfamiliar codebase, Understanding a confusing snippet from a PR, Stack Overflow, or a tutorial, Learning a new language or framework by reading real code, Making sense of code written in a language you barely know
explain codecode explanationchatgpt prompt to explain codeunderstand codecode walkthroughonboardingdebugging

Built by Web Innoventix

Want the work done, not just prompted? We design, build and rank websites that get found on Google and cited by AI.

Get a free quote

More prompts

Browse all →
Development

Build a React component from a description

Turn a plain-English description into a production-ready, accessible React + Tailwind component with a usage example.

2 fieldsreacttailwind
Development

Senior code review that catches real bugs

Paste a snippet or PR diff and get a senior-engineer review: real issues ranked by severity, each with the exact input that breaks it and a concrete fix — not a wall of style nitpicks.

3 fieldscode-reviewpull-request
Development

Debug an error by root cause, not guesswork

Paste an error and its context to get a traced root-cause diagnosis, a fix that addresses the real cause, and a concrete way to verify the bug is gone.

2 fieldsdebuggingroot-cause-analysis
Development

Write thorough unit tests for a function or component

A fill-in prompt that turns any function or component into a runnable unit test suite covering happy paths, edge cases, boundaries, and error handling in your chosen framework.

4 fieldsunit testingunit tests
Development

Refactor a messy function into clean, maintainable code

A copy-paste ChatGPT prompt that refactors a messy function into clean, maintainable code without changing its behavior — it audits the code, rewrites it, explains each change, and suggests tests to prove nothing broke.

4 fieldsrefactoringclean-code
Development

Build a regex from a plain-English description (with test cases)

A fill-in-the-blank ChatGPT prompt that turns a plain-English rule into a working regex for your exact language — with a line-by-line breakdown and a pass/fail table of positive and negative test cases.

3 fieldsregexregular-expressions
Chat with us