3 Workflow: Build your own codebase knowledge builder
This chapter covers
- Build a workflow that turns any repo into a readable tutorial
- Prune a huge repo to fit the LLM's context window
- Force structured YAML output from an LLM
- Decompose a task with the overview-then-zoom-in pattern
- Encode domain knowledge in a swappable instructions file
Chatting with an LLM works for a 19-file codebase like nanoGPT because you already know what to ask. Your questions about vocab_size = 50304 and gradient accumulation were driven by your own expertise. That approach breaks down on a 500-file codebase you've never seen before. You don't know which questions to ask, and you can't paste the entire project into the context window.
What you need is a systematic approach: a tool that reads the whole codebase, identifies the core concepts, and explains them in a logical order, mapping out their dependencies. This is a pipeline that asks the right questions for you, not a conversation where you hope to stumble on them yourself. That's what you will build in this chapter: a Codebase Knowledge Builder. The full code is available at github.com/zachary62/Crack-Any-Codebase-with-AI/tree/main/ch03-workflow. By the end, you'll have learned three techniques that are reused throughout this book: forcing structured output from LLMs, decomposing a problem with an overview-then-zoom-in strategy, and encoding domain knowledge in instruction files.