Understanding unfamiliar code

10 min read text
Course contents (20 lessons)
  1. Meet Claude Code
  2. What Claude Code is and how it differs from a chat window
  3. Installing Claude Code and signing in
  4. Your first session: explore, ask, change
  5. Asking well and staying in control
  6. Asking for changes: context, goal, constraints and acceptance criteria
  7. Reading and approving edits
  8. Permission modes: how much freedom to give
  9. Project memory and slash commands
  10. CLAUDE.md: teaching the tool about your project
  11. Slash commands and custom commands
  12. Everyday coding workflows
  13. The plan-first workflow
  14. Understanding unfamiliar code
  15. Debugging with Claude Code
  16. Refactoring safely
  17. Writing tests with Claude Code
  18. Git, small changes, cost and security
  19. Git workflows: branches, commits and pull request descriptions
  20. Keeping changes small and reviewable
  21. Context and cost awareness
  22. Security habits: secrets, commands and untrusted input
  23. Extending the tool, teamwork and a final project
  24. Hooks and MCP servers explained
  25. Team practices for AI-assisted coding
  26. Final project: building a small app step by step

The most under-rated use

Many developers start by asking the tool to write code. I think the most useful first use is reading code. Joining a project, picking up a legacy system, looking at an open-source library: all of these start with the slow job of building a mental map. A tool that can search and read quickly saves hours.

Start with a tour

I am new to this codebase. Give me an orientation:
1. What the app does, in two sentences.
2. The main folders and what each is for.
3. The entry point and how a request or command flows through the code.
4. The main libraries and frameworks used.
5. Where tests live and how to run them.
Cite file paths for every claim. If you are unsure about something, say so.

Why it works

The structure gives a map. "Cite file paths" lets you verify and makes the tool less likely to invent. "If you are unsure, say so" invites honesty. The answer is a first draft of your mental model, and you will correct it as you learn.

Trace one flow

A tour tells you the layout. A trace tells you how things actually work.

Trace what happens when a user clicks "Pay now" on the checkout page. List each step in order: the UI handler, the API call, the controller, the service methods, the database writes and any external calls. For each step give file and function name. Mark any place where an error can occur and what happens then.

This is the single most useful prompt in my own work on unfamiliar code. Follow it by opening two or three of the named files yourself to see that it matches.

Find the conventions

I need to add a new API endpoint. Look at three existing endpoints and describe the pattern they follow: naming, validation, error handling, authorisation, response format, tests. Then list anything that is inconsistent between them.

Asking about inconsistency is helpful. Real codebases are not tidy, and it is good to know which examples to copy and which to avoid.

Ask "why" questions carefully

You can ask, "Why does this function retry three times?" The tool can read the code and comments and suggest a reason, but it cannot know the history. It may produce a plausible story. Treat such answers as guesses and check version history. Git can tell the truth:

git log --oneline -- path/to/file
git blame path/to/file

You can also ask the tool to run these and summarise the commit messages around that line. Then the answer rests on evidence.

Explain at your level

Explain the reconcile() function in src/billing/reconcile.py. I understand Python but not accounting terms. Define each domain term the first time you use it and give a tiny example with numbers.

Draw it out

Ask for a diagram in text form, such as a list of components and arrows written with plain characters, or a table of modules and their dependencies. You can put it into your own notes.

Keep a learning note

As you learn, ask the tool to write a short summary of what you found into a notes file, or propose lines for the project memory file. Next month, you or a new teammate will benefit.

Checking the claims

  • Open at least two files the tool cited in each answer.
  • Search for a term yourself and see that the results match its description.
  • Run the program and see the flow in logs when possible.

The tool reads many files, but it can miss one, especially in a large codebase with dynamic behaviour such as reflection, plugins or code generation. If something feels too simple, ask "What could make this flow differ at runtime?"

The common mistake

The common mistake is taking the first overview as truth, and then making changes based on it. An overview is a hypothesis. Spend ten minutes testing it before you act.

Try it yourself

Pick a part of your codebase that you rarely touch. Run the tour prompt, then the trace prompt for one feature. Verify three claims by opening the files. Write down one thing the tool got wrong or missed, and one thing you learned that you did not know.

This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.

Sign up free I already have an account