Reading an unfamiliar codebase
You've taken over a project you've never seen. In half an hour, understand its structure, main flows and pitfalls, then start making changes.
1. Get the map first, not the details
Don't open by asking about a specific function. First ask for the big picture:
This is a project I just took over. Please don't change any code. Help me map it out:
1. Tech stack and module breakdown (one sentence on each module's responsibility)
2. Program entry points and the call chain of one typical request
3. Commands to build, start and test
4. The pitfalls you think newcomers most often fall into
It will run ls on its own, read pom.xml / package.json, find the entry classes, and then give you a map. Say explicitly "don't change code", and it will only read, never write.
2. Follow one real flow all the way through
With the map in hand, pick a feature you're about to change and have it walk through the flow in full:
For the "Export Excel" feature, from the front-end button click to the file download, which files and methods does it pass through?
List them in call order, and note the file path and line number for each step.
Asking for "file path + line number" has two benefits. You can open each one directly to check it, and it has to actually read the code rather than make things up from memory.
3. Ask it to find "why it was written this way"
Many strange-looking pieces of old code have a reason. Ask directly:
None of the SQL uses resultType="map"; instead, dedicated DTO classes were created. Why is that?
Is there any related comment, commit record or document that explains it?
It will go through comments, git log and the project docs. Many "historical decisions" can be recovered this way.
4. Compare two implementations
Large projects often have an old and a new implementation running side by side, which is where mistakes are most likely:
The project seems to have two intelligent data query implementations (module A and module B).
Where does each one enter, and how do they work differently? Which one should I change for data queries?
Once you've worked it out, write the conclusion into CLAUDE.md, so that next time it (and your colleagues) won't mix them up.
5. Hand large-scale searches to a subagent
When you need to find a certain pattern across dozens of files, the main conversation gets flooded with search results. In that case, have it dispatch a subagent to search, so only the conclusion comes back:
Use a subagent to search the whole project for every place that directly concatenates SQL strings.
List the files and line numbers by risk level, and don't paste full code.
A subagent has its own independent context. After searching, it hands back only the conclusions, which keeps the main conversation clean (covered in detail in Part 04).
6. Keep the understanding
Once you've got a handle on it, have it organize the key conclusions into the project's CLAUDE.md:
Organize the module responsibilities, call chain highlights and the differences between the two implementations we just worked out
into concise entries in CLAUDE.md. Don't write things we can already see directly from the code.
Only write what the code doesn't show: design reasons, counter-intuitive conventions, and points that are easy to confuse. The code structure itself doesn't need to be written down, because it can always read it for itself.
Common pitfalls
| Pitfall | Better approach |
|---|---|
| Asking for details right away | Get the map first, then go deeper along the flow |
| Accepting answers like "it should be…" | Require file paths and line numbers |
| Leaving conclusions only in the conversation | Write them into CLAUDE.md so you can reuse them next time |
| Running large-scale searches in the main conversation | Hand it to a subagent and ask only for the conclusion |