AI-101

Lesson 10

Exploring a Codebase

AI Confidence: 90%

AI-generated

Exploring a Codebase

Learning Objectives

Ask effective questions about unfamiliar code

Use @ to reference files and directories directly

Find relevant code for features and bugs

Trace execution flows through a codebase

Build understanding without reading every file yourself

Introduction

One of the best uses of Claude Code is exploring code you did not write. Whether you joined a new team, inherited a project, or need to understand a library, Claude Code can be your guide. You ask questions, and Claude reads the files to give you answers.

This is different from searching documentation or reading code yourself. Claude Code looks at your actual files, not generic information. When it explains how authentication works, it describes your authentication system, not authentication in general.

This lesson teaches you how to ask good exploration questions, reference specific files, and trace how code flows through your project. By the end, you will be able to understand new codebases faster than ever.

Starting with Overview Questions

When you first encounter a codebase, start broad. Claude Code can give you a high-level picture before you dive into details.

Good starting questions:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude reads key files like README.md, package.json, and main source files to summarize the project's purpose.

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude identifies frameworks, libraries, and tools from configuration files and import statements.

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude describes how the project is organized and what each major directory contains.

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude finds where the application starts, whether that is a main function, an index file, or a server startup script.

These broad questions give you orientation. You understand what you are looking at before examining specific parts.

Follow-up questions:

Once you have the overview, go deeper:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude traces through files to answer these questions. It might read multiple files and explain how they connect.

Referencing Files with @

Sometimes you know exactly which file you want Claude to examine. The @ symbol lets you reference files directly:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

When you use @, Claude reads that file immediately. It does not have to search for it. This is faster and more precise.

File references:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude reads and analyzes this specific file.

Directory references:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude shows the directory listing and can summarize what each file does.

Multiple references:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

You can reference multiple files in one question.

Relative and absolute paths:

Both work. Use whatever is most convenient:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

When you reference a file with @, Claude Code also loads any CLAUDE.md files in that file's directory and parent directories. This ensures project context is included.

Finding Relevant Code

Often you do not know which files matter. You describe what you are looking for, and Claude finds it.

Finding code by feature:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude searches for files with relevant names, imports, and code patterns.

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Finding code by pattern:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Finding code by error:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude searches for where this error message is defined or thrown.

The key is describing what you are looking for in plain terms. Claude translates your description into file searches and code analysis.

Tracing Execution Flows

Understanding code often means tracing how data or control flows through the system. Claude Code can follow these paths.

Request flows:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude walks through the code from the login form to authentication to session creation.

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Data flows:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Error flows:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

These questions ask Claude to read multiple files and explain the connections. The answers show you how pieces fit together, not just what individual files contain.

Asking About Architecture

Beyond specific code, you can ask about design decisions and patterns:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude identifies architectural patterns by examining how code is organized and how components interact.

Comparing to standards:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Claude can evaluate code against common standards and point out deviations.

Exploration Best Practices

These patterns make exploration more effective:

Start broad, then narrow. Begin with overview questions, then zoom into specific areas. This builds context that makes detailed questions more useful.

Use @ when you know the file. Direct references are faster than making Claude search. If you know the file name, use it.

Ask about connections, not just files. Questions like "how do these work together" reveal more than "what does this file do" asked twice.

Let Claude build context. Early questions help Claude understand the codebase. Later questions benefit from this understanding. Do your exploration in one session when possible.

Trust but verify. Claude's explanations are based on actually reading your code. But for critical understanding, follow up by reading the key files yourself.

Key Takeaways

Start exploration with broad overview questions about purpose and structure

Use @ to reference specific files when you know what to examine

Ask Claude to find relevant code when you do not know file names

Trace execution flows to understand how code works together

Build understanding incrementally from broad to specific

Claude reads your actual code, not generic documentation

Try It Yourself

Explore a codebase with these steps:

Open Claude Code in a project you are not fully familiar with.

Ask "what does this project do?" and read the overview.

Ask "what technologies does this project use?"

Ask "explain the folder structure."

Pick a feature and ask "how is [feature] implemented?"

Find a specific file using @ and ask for explanation.

Ask Claude to trace a flow: "trace what happens when [action]."

Ask an architecture question: "what patterns does this code use?"

By the end, you should understand the project significantly better than when you started.

Sources

https://code.claude.com/docs/en/common-workflows - Codebase exploration workflows

https://code.claude.com/docs/en/best-practices - Effective prompting patterns for exploration

https://code.claude.com/docs/en/quickstart - Basic exploration questions