Back to Examples
Loading Context for Large Codebases
Practical strategy for giving agents enough context without blowing the context window.
Context Engineering•Intermediate•markdown
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.
Quick Info
Difficulty: Intermediate
Language: markdown
Copy the block above and adapt it to your project.
Related Examples
Complete AGENTS.md for Next.js + TypeScript
A production-grade AGENTS.md used by real teams. Covers principles, skills, workflows, and review standards.
Real Grok Build Skill Definition (advanced-code-reviewer)
A complete, production-ready skill definition you can download and use.
Research → Implement → Review → Ship Workflow
A complete multi-step workflow used for feature development with agents.