Explain a codebase
Goal
Help the user understand a project well enough to work in it. A good tour is proportionate to the project, uses file paths the user can open, and says what was not looked at.
When to use
- The user is new to a project or a part of it.
- The user asks how something in a codebase works or where to start for a task.
- For tracking down a specific failure, use
use_skillwithdebugging.
Steps
- Top level: run
lson the root. Read the README, AGENTS.md or CONTRIBUTING.md, and the manifest (package.json, pyproject.toml, Cargo.toml, go.mod, pom.xml, *.csproj) withread_filefor the language, framework, scripts and dependencies. - Entry points: find where execution starts, such as main files, app bootstrap, server setup, CLI entry, routes and index files.
rghelps ("main(", "createServer", "app.listen", "@app.route"). - Structure: list the main folders and what each holds, one level deeper where it matters.
- Follow one real flow end to end. Pick the core use case (a request, a command, a button press) and follow it through the files, reading only what that path touches.
- For questions that would take many reads, ask
explore("Where is authentication checked?") and use its answer as a lead to verify. - Find how to run it: build, run and test commands from scripts, Makefile, docs or CI config.
- Stop exploring once you can explain the parts the user cares about.
- Explain, in this order:
- What it is: one paragraph on purpose, users and main technologies.
- Map: the key folders and files, each with one line.
- How it works: the main flow as numbered steps naming the files and functions involved.
- Key concepts: domain terms, core data models, important patterns or conventions.
- Run and test: exact commands.
- Where to start: for the user's task if they mentioned one, the files to read or change first. Otherwise good first areas.
Gotchas
- Read only. Do not modify anything while exploring.
- Describing files you did not open is guessing. Say what you did not look at.
- Reading everything wastes effort. Follow one flow and read only what it touches.
- Commands copied from the README may be out of date. Check them against the scripts and CI config.
- A small script gets a short answer. Do not inflate the tour.
Output
The six-part explanation above, with file paths the user can open, scaled to the size of the project.
