Working in a large codebase
Everything so far worked on three files. The defaults that make that pleasant are the same defaults that fill a context window in ten minutes on a monorepo.
Nothing breaks at scale. What changes is that reading becomes expensive, one CLAUDE.md covering every subsystem becomes noise, and a search that matches four hundred files stops being useful. Each of those has a fix, and they layer.
Put the conventions next to the code
Lesson 11 said files in subdirectories load when Claude reads something in that directory. In a monorepo that is the whole strategy: a small root CLAUDE.md for what is true everywhere, and a file per package for what is true there.
Skills work the same way. A per-directory skill for the deployment procedure of one service loads when that service is the work, and costs nothing the rest of the time.
Stop it reading what it should not
Build output, generated code and vendored dependencies are the biggest waste in a large repository, and deny rules are the cheapest fix in this course.
{
"permissions": {
"deny": [
"Read(**/dist/**)",
"Read(**/node_modules/**)",
"Read(**/*.generated.*)"
]
}
}The rules from lesson 16 with a different purpose: not safety, cost. A generated file read into context is money spent on something no human would have opened.
Give it less to look at
| Problem | What helps |
|---|---|
| Worktrees check out everything | worktree.sparsePaths, so a new worktree holds only the directories the task needs |
| It scans files to find a definition | A code intelligence plugin, which answers from the language server instead |
| The task needs a sibling package | --add-dir, or additionalDirectories, rather than starting at the repository root |
| Irrelevant CLAUDE.md files load | claudeMdExcludes for packages you never touch |
Where you start the session matters more than any of them. Starting in the package you are working on, rather than at the root, changes what loads, what gets searched, and which settings apply.
/context, from lesson 7. When most of the window is files you did not need, one of the fixes above is the answer, and which one is usually obvious from what is in there.- Run
/contextin your largest repository after a normal task. - Add one deny rule for your build output and repeat the task.
Slow is fine. Stopping is the only problem.