Back to Examples

Loading Context for Large Codebases

Practical strategy for giving agents enough context without blowing the context window.

Context EngineeringIntermediatemarkdown
Example Code
Strategy for a 200k+ LOC codebase:

1. Start with a high-level directory summary (tree -L 2 plus the README).
2. Ask the agent to produce a "relevant files" list for the current task.
3. Feed only those files + a 1-2 paragraph summary of the rest of the system.
4. Use scratch files for intermediate reasoning.
5. For very large files, ask the agent to request specific functions or regions instead of the whole file.

The context-builder skill automates a lot of this process.

When to use this

Practical strategy for giving agents enough context without blowing the context window.