Start With a Map
Before diving into individual files, get the AI to give you a mental map of the project. In Claude Code, navigate to the project root and ask:
# Get a high-level overview:
> Read the directory structure and main files.
Describe this project in 3-5 sentences: what does it do,
what technology stack does it use, and how is it organized?
# Understand the entry points:
> Where does a web request enter this application?
Trace the path from the URL to the first PHP/Python file that handles it.
# Find the database:
> What database tables exist in this project?
Find schema files, migration files, or CREATE TABLE statements.
List each table and its main purpose.
# Map the major components:
> What are the main "areas" of this codebase?
For example: auth, products, orders, admin panel.
Which files/directories handle each area?
Explain Code Prompts
Once you have the map, zoom in on specific pieces:
> Explain this code line by line in simple terms:
[paste 10-30 lines of code]
> What does this function do and what does it return?
[paste function]
> I see this pattern used everywhere in this codebase:
[paste code pattern]
What is this pattern called and why is it used here?
> This code uses the Repository pattern. Can you explain it in
simple terms and show me which classes are repositories in this project?
> Read the UserModel class. Describe:
1. What data it manages
2. What each public method does (one sentence each)
3. Any non-obvious design choices
4. What other classes depend on it
> Read the AuthController. Walk me through the login flow step by step,
from when the form is submitted to when the user reaches the dashboard.
Trace Data Flow
One of the most valuable uses of AI: tracing how data moves through a system.
# Trace a user action:
> Trace exactly what happens when a user clicks "Place Order" on the checkout page.
Follow the code path: which files are executed in which order,
what data is passed between them, and what is ultimately saved to the database.
# Trace data through layers:
> How does a product get from the database to the HTML page?
Trace from the SQL query through any transformations to the final output.
# Find where something is set/read:
> In which files is the $_SESSION['user_id'] variable set and read?
Find every place it is used and what it is used for.
# Find dependencies:
> Which parts of the code depend on the PaymentGateway class?
If I change its interface, which files would break?
Document With AI
Turn undocumented code into well-documented code using AI:
# Add PHPDoc to all methods:
> Add PHPDoc comments to every public method in this class.
Include @param, @return, and a one-sentence description.
[paste class]
# Write a README section:
> Read the /app/services/ directory. Write a README.md section
that explains what each service class does and when to use it.
# Document the database schema:
> Read all the CREATE TABLE statements in /database/schema.sql.
Write a DATABASE.md file that describes each table's purpose,
important columns, and relationships to other tables.
# Document a complex algorithm:
> This function implements a complex calculation. Add inline comments
that explain the purpose of each step, not just what the code does.
[paste function]
Onboarding Prompts
Use these when joining a new project or picking up an old one after a long break:
# Step 1: Get oriented (run this first in a new project):
> I am new to this codebase. Read the project files and answer:
1. What does this application do?
2. What is the tech stack?
3. How do I run it locally?
4. Where is the main configuration?
5. What are the 5 most important files to understand first?
# Step 2: Understand the architecture:
> Describe the architecture of this application.
How is the code organized? Does it use MVC, service layer,
repository pattern, or something else?
# Step 3: Find the important stuff:
> Where is:
- User authentication handled?
- The database connection configured?
- The main routing logic?
- Email sending?
- Error logging?
# Step 4: Understand the data model:
> Read the database schema and draw (in text) the entity relationships.
Which tables are central and which are peripheral?
Before You Change Anything
Before modifying any code in an unfamiliar codebase, use AI to understand the risk:
> I want to change the getUserById() method in UserModel.
Which other files call this method?
What would break if I change its return type from array to object?
> I want to rename the 'email' column in the users table to 'email_address'.
Find every place in the codebase that references 'email' in a database query
or result. List the files and lines I would need to update.
> I want to add a required 'tenant_id' parameter to the UserModel constructor.
How many places create a new UserModel? List them all.
> Before I modify the checkout flow, which automated tests cover it?
Run the test suite and show me which tests would be affected.
As you use AI to understand a project, keep a running NOTES.md file. After each AI explanation, write a 2-3 sentence summary in your own words. This forces comprehension and gives you a personal reference document. After a day of AI-assisted onboarding, you will have documentation that would normally take a week to write manually.