When you ask an AI coding agent to "add pagination to the user list," it cannot see your whole codebase at once. Even the largest context windows are smaller than most real projects. The agent has to decide which files matter.
Understanding that process helps you write better prompts and configure the agent so it finds the right code.
The Basic Search Loop
Most agents follow a simple loop:
- List files. The agent sees the top-level directory structure.
-
Search. It greps for keywords from your prompt, like
user,list, orpagination. - Read candidates. It opens the files that look most relevant.
- Plan. Based on what it read, it decides what to change.
- Edit and verify. It writes changes and runs tests or checks.
The whole loop happens in the context window. The agent forgets anything it did not explicitly read or summarize.
The agent's search is only as good as your naming. If your user list component is named
UserTable.tsx, the agent will find it. If it is namedIndexView.tsx, the agent may miss it unless other files reference it clearly.
The Role of Context Files
Agents work better when you tell them where to look. A CONTEXT.md or conventions file acts like a map. It can include:
- Directory structure and what lives where
- Naming conventions
- Import aliases
- Test framework and how to run tests
- Common patterns the agent should follow
Without this map, the agent guesses. With it, the agent starts from a much better position.
Semantic Indexing vs. Keyword Search
Some tools, like Augment Code or Windsurf, build semantic indexes. They convert code chunks into embeddings and search by meaning rather than keyword. This helps when the relevant code uses different words than your prompt.
Terminal agents like OpenCode typically rely on file patterns and search first. You can improve their accuracy by keeping your project structure clean and your naming descriptive. Semantic indexing is powerful, but it is not free: it adds setup complexity and latency.
No indexing system is perfect. A semantic index can still return irrelevant code if your project has similar concepts in different domains. Always review which files the agent loaded before approving changes.
Why This Matters
The agent does not understand your codebase the way a senior engineer does. It understands the files it read in the current session. If the agent misses a critical file, it will produce a broken or incomplete change.
Your job as the operator is to:
- Keep the project structure legible
- Provide a conventions file
- Review the agent's file list before approving edits
- Add explicit context when the agent misses something
Originally published at pickuma.com. Subscribe to the RSS or follow @pickuma.bsky.social for new reviews.
Top comments (0)