Inherited a codebase, reviewing a pull request in a language you rarely use, or staring at a snippet an AI wrote for you? Here is a step-by-step way to work out what code does — and where an AI explainer helps.
"Understand this codebase" is too big to finish. "What happens when a user resets their password?" or "Why does this function return None sometimes?" are questions you can answer in an afternoon. Write yours down before you start reading — it tells you which code you can skip.
Code is easier to read in the order it runs. Look for where execution starts:
if __name__ == "__main__": in Python, or the main function in Java, C, C++ and GoPick one input and trace it: where it comes in, which functions transform it, and where it ends up — a database, an API response, the screen. Skim functions that don't touch it. Your editor's Go to Definition and Find All References are faster than searching by hand.
For a dense function, a regular expression or a language you don't use daily, a plain-English summary saves a lot of time. Paste the function into the free AI Code Explainer and you get three things: a short summary, a walkthrough of the code in order, and a list of bugs and edge cases worth knowing about. Choose the beginner level if you're learning, or experienced for a concise version.
Paste a function and get a summary, a step-by-step walkthrough and the bugs to watch out for.
Open the Code ExplainerExplain one function or class at a time rather than a whole file. You get a more detailed answer, and it is easier to check.
An AI explanation is a hypothesis, not a fact. Models are usually right about what common code does, but they can be confidently wrong about unusual code, about behaviour that depends on configuration or data they can't see, and about functions defined elsewhere in your project. Before you rely on it:
Reading only gets you so far. Set a breakpoint and step through, add a temporary print or console.log, or call the function from a test with a small input. If there is a test suite, read the tests — they show how the code is meant to be used and what the author thought could go wrong.
# A quick experiment often answers more than an hour of reading
from orders import top_customers
print(top_customers([
{"customer": "ana", "amount": 30, "status": "paid"},
{"customer": "ben", "amount": 50, "status": "cancelled"},
]))
A few comments on the non-obvious parts — why the code does something, not what it does — will save the next person (often you, six months later) from repeating the work. If the code came from an AI assistant and is full of comments that only repeat the code, the Code Humanizer can strip those and keep the useful ones.