Nguyen Le Phong

Using AI to Read a Codebase You Didn't Write

How to use AI in your first days on an unfamiliar codebase: prompts that trace real flows, how to check what the tool tells you and which paths to read yourself.

Day one on a new repo. The folders look tidy, the tests have sensible names and the README opens with a confident paragraph. Then you try to answer one simple question, "what happens when a customer places an order?", and the answer turns out to be spread across a route, two services, an adapter, a queue consumer and a feature flag nobody mentioned.

That's normal. A field study of 78 professional developers across seven real projects found they spent about 58% of their time on program comprehension, and senior developers spent a smaller share of their time on it than juniors (Xia et al., Measuring Program Comprehension). Reading code was always most of the job. AI tools make that reading faster. They also make it easier to feel you've understood something you haven't.

An engineer compares an AI-generated summary of a codebase with a dependency map printed on paper.
Let AI draw the first map. Then walk the roads yourself.

Let AI draw the first map

The first pass is where AI earns its keep. Ask it to summarize a module, find the entry points, list the files behind a feature or sketch how a request moves through the system. You won't get a complete answer. You'll get a short list of doors worth opening first, which beats wandering every hallway at once.

Coding agents now read the repo themselves, so you no longer paste files into a chat. As of November 2026, the Claude Code docs suggest the rhythm most experienced engineers already use: start with broad questions, narrow down to specific areas, ask about the project's conventions and request a glossary of project-specific terms (Claude Code, Common workflows). The glossary tip is underrated. Half of a new codebase is vocabulary: what "settlement" means here, and why there are three different things called "account".

Where a fluent summary misleads

The risk sits right next to the benefit: a tidy summary shows up before you've understood anything. The model might name an architecture pattern the code only half follows. It might skip a feature flag, a fallback branch or a test helper that changes what production actually does. The prose sounds organized while the code stays messier than the explanation.

Summaries also lean toward the code as it was meant to be. Comments, folder names and the README all describe the intended design. Old workarounds, dead branches and the one service that still bypasses the rule won't show up in that story unless you ask for them by name.

Treat the answer as a reading plan

A better habit is to use the AI's answer to decide what to open next, and hold your conclusions until you've opened it.

  • The tool says the payment flow passes through three services? Open those three files and follow the calls.
  • It says the queue consumer is idempotent? Find the idempotency key and the retry logic.
  • It calls a module "legacy"? Ask what in the code supports that label: the last commit date, the remaining callers, a deprecation note.

On its own, the summary is worth little. What you're really getting is speed: a set of guesses you can check in minutes.

Prompts that stay close to the code

Vague prompts get vague answers. A few swaps that help:

VagueConcrete
"Explain this repo.""Trace how a new order goes from the HTTP request to the database write. List every file and function you used as evidence."
"Is this design good?""Where are the discount rules enforced? Which callers could skip that check?"
"What does this module do?""List the public functions in this module, who calls each one and which ones have no tests."
"Is this endpoint safe?""Show every place this endpoint uses user input before it's validated."

The concrete version asks for evidence, so you can check each claim against a file and a line instead of trusting the tone. If your tool supports it, give it proper code navigation too. The same Claude Code docs recommend installing a code intelligence plugin for your language so the agent gets precise "go to definition" and "find references".

Use it to compare, too

AI is handy for spotting patterns across files: two near-identical modules, inconsistent names for the same idea, tests that describe one behavior in different words. Reading a codebase is partly noticing repeated shapes and deciding whether each one is deliberate or an accident. "Where else does this pattern appear, and where does it differ?" can save you an afternoon of grep.

Where you still read line by line

Some areas deserve slow, direct reading: security boundaries, anything that moves money, data deletion, migrations and permissions. AI can gather the context for you (files, callers, recent changes). The confidence still has to come from the source, the tests, the logs and what production actually does.

How you use the tool also shapes what you learn. In Anthropic's January 2026 trial, engineers learning a new library who asked the AI follow-up and conceptual questions scored much higher on a later quiz than those who handed it the whole task (How AI assistance impacts the formation of coding skills). For code reading, that means asking "why" and "what would break if" questions, and saving "just tell me" for code you'll never have to debug. There's more on this in Cognitive Debt: When AI Writes Code Faster Than Your Team Can Understand It.

Keep two lists

While you read, keep notes in two columns: what you've verified in the code, and what the tool suggested that you haven't checked yet. Keep the split when you share findings. "The AI thinks the retry is idempotent" and "the retry uses the order ID as its idempotency key, see charge.ts" are very different messages, and your teammate should know which one they're getting.

Try this week

  • Pick one user action in your repo and ask AI to trace it end to end, with files and functions as evidence. Open every file it names.
  • Ask for a glossary of project terms, fix the wrong entries with a teammate and commit the corrected version to the docs.
  • Keep a "verified / not checked yet" note during your next investigation and share it as it is.
  • Before your next change that touches money or permissions, read that path yourself first, then compare with what the AI says.

AI makes the first hour in a new codebase a lot less lonely. The mental model still gets built the old way: open the file, follow the call, check the guess. The tool just gets you to the right file sooner.

What did you think?

Frequently asked questions

Can AI help me understand an unfamiliar codebase?
Yes, especially on the first pass. It can summarize modules, find entry points, list the files behind a feature and trace how a request moves through the system. Treat the answer as a list of places to read next, and confirm each claim in the code.
What prompts work best for reading code with AI?
Concrete prompts that ask for evidence. For example: trace how a new order goes from the HTTP request to the database write, and list every file and function you used. Asking for a glossary of project terms also helps a lot in a new repo.
Why can an AI summary of a codebase be misleading?
Summaries lean on comments, folder names and the README, which describe the intended design. They can miss feature flags, fallback branches, workarounds and test helpers that change real behavior, while still sounding well organized.
Which parts of a codebase should I still read myself?
Security boundaries, payment and money flows, data deletion, migrations and permissions. AI can gather context for these areas, but the confidence should come from the source, tests, logs and production behavior.
How much of a developer's time goes into reading code?
A field study by Xia and colleagues, covering 78 professional developers and 3,148 working hours, found that developers spent about 58% of their time on program comprehension, with senior developers spending a smaller share than juniors.