Understanding unfamiliar code
Course contents (20 lessons)
- Meet Claude Code
- What Claude Code is and how it differs from a chat window
- Installing Claude Code and signing in
- Your first session: explore, ask, change
- Asking well and staying in control
- Asking for changes: context, goal, constraints and acceptance criteria
- Reading and approving edits
- Permission modes: how much freedom to give
- Project memory and slash commands
- CLAUDE.md: teaching the tool about your project
- Slash commands and custom commands
- Everyday coding workflows
- The plan-first workflow
- Understanding unfamiliar code
- Debugging with Claude Code
- Refactoring safely
- Writing tests with Claude Code
- Git, small changes, cost and security
- Git workflows: branches, commits and pull request descriptions
- Keeping changes small and reviewable
- Context and cost awareness
- Security habits: secrets, commands and untrusted input
- Extending the tool, teamwork and a final project
- Hooks and MCP servers explained
- Team practices for AI-assisted coding
- 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