Understand a codebase
Ask an agent to explore and explain code before it changes anything, and use what it finds to plan the work.
The fastest way to get a bad change is to ask for one in code nobody has read. Before an agent edits a codebase that is new to you, or new to it, have it explore and explain first. You get a map of the code, and the agent fills its context with the parts that matter. This lesson shows how to ask for that, and how to keep the agent from changing anything while it looks.
Explore without changing anything
Set Permission mode in the composer to Plan before you send. In Plan mode the agent can read files, search, and look at git history, but it cannot change files, run commands, or push. It investigates, then answers.
This is the safest way to point an agent at unfamiliar code. You get its understanding without any risk of half-finished edits. When you want it to start changing things, switch the mode back to Auto or Ask. The new mode applies from the next turn.
Ask questions that lead somewhere
A broad request such as "explain this repository" gets a broad answer. A question tied to something you need to do gets one you can act on.
Good exploration questions:
- Follow a path. "Walk me through what happens when a user submits the signup form, from the button to the database."
- Find the owner. "Where is the pricing for a plan calculated? List every file that changes the total."
- Map the edges. "Which parts of this code call the payments API, and how do they handle errors?"
- Find the conventions. "How are new API routes added here? Show me one recent example to copy."
Ask the agent to cite file paths and function names for every claim. That turns its answer into a reading list you can check, and it keeps the agent honest about what it actually read.
Look at what the agent sees
The agent's page has apps you can open beside the conversation. Select Open app to add one:
- Files lists the files on the agent's computer, so you can open the ones it mentions.
- Git shows what has changed in each repository.
- Terminal opens a shell on the agent's computer, where you can run a command yourself.
- Browser opens a server running on the agent's computer, once something listens on a port.
You can also type @ in a follow-up message to point the agent at a specific file in the repository.
For a bigger picture, the Map this codebase starter under the composer on the Agents page asks an agent to read the code and publish an interactive page that maps its architecture: the main modules, how a request flows through them, and where to start reading.
Turn understanding into a plan
Exploration pays off when it feeds the next step. Once the agent has explained the code, ask it for a plan in the same conversation, while what it read is still in its context:
If you think the knowledge is worth keeping, ask the agent to remember the key facts as a note for the repository, so the next agent starts with them. The next lesson covers taking a plan like this through to a pull request.
Key points
- Use Plan mode to let an agent read and search without changing anything.
- Ask questions tied to a task, and ask for file paths and function names behind each answer.
- Open Files, Git, Terminal, or Browser beside the conversation to see what the agent sees.
- Ask for a plan in the same conversation, while what the agent read is still in context.