Guide October 30, 2026 · 6 min read

How to Understand Code You Didn't Write (With and Without AI)

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.

1. Start with the question you need answered

"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.

2. Find the entry point

Code is easier to read in the order it runs. Look for where execution starts:

3. Follow the data, not every line

Pick 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.

4. Get a first-pass explanation

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.

Explain any code in seconds

Paste a function and get a summary, a step-by-step walkthrough and the bugs to watch out for.

Open the Code Explainer

Explain one function or class at a time rather than a whole file. You get a more detailed answer, and it is easier to check.

5. Check the explanation against the code

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:

Don't paste secrets. Remove API keys, passwords, customer data and connection strings before pasting code into any online tool, including AI explainers.

6. Run it and watch

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"},
]))

7. Write down what you learned

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.

Summary

  1. Decide what question you need answered.
  2. Find the entry point and follow one piece of data through the code.
  3. Use the AI Code Explainer for a fast first pass on dense functions.
  4. Check the explanation against the code, and run the code to confirm.
  5. Leave a comment explaining the why.