Back to articles
Stop Feeding Your Entire Codebase to AI: A File Selection Strategy

Stop Feeding Your Entire Codebase to AI: A File Selection Strategy

via Dev.to BeginnersNova Elvaris

"Just paste the whole repo." I see this advice everywhere. And every time, the AI returns garbage — hallucinated imports, wrong function signatures, confused architecture. Not because the model is bad, but because you drowned it in context it doesn't need. Here's how I select files for AI context, and why less really is more. Why "Everything" Doesn't Work Modern models advertise 128K or even 1M token context windows. That doesn't mean they use all of it equally. Research consistently shows that LLMs have a middle attention gap — they pay most attention to the beginning and end of context, and lose focus in the middle. When you paste 50 files, the model: Loses track of which function belongs to which file Confuses similar-looking patterns across different modules Hallucinates imports from the wrong file Generates code that's technically valid but architecturally wrong The 3-Ring Strategy I think of file selection like concentric rings around my current task: Ring 1: The Target (always i

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
4 views

Related Articles