Why I let Claude read the whole repo before asking

I have a habit that surprised a friend when I told him: I let the agent read the whole repo before asking my first question. Even when the question is small. Even when the change is one line.

The friend thought this was wasteful. The agent uses more tokens. The first response is slower. Why spend the budget on a small question?

The answer is that small questions live inside the codebase. The agent that hasn’t read the codebase is making decisions based on a guess about what the code looks like. The agent that has read the codebase is making decisions based on what the code actually is.

The case study

A bug report: the morning agent stopped sending email on Tuesday. The first guess (and the friend’s) was “the email creds expired.” It was a reasonable guess. The actual cause was that I had added a new line to the email template and the template engine choked on a stray % in the new copy. Nothing to do with the creds.

The agent that read the repo would have seen the template change. The agent that didn’t read the repo would have started checking the SMTP credentials, the OAuth token, the network reachability, the email service status. All of that is in the codebase, and the agent that read the codebase would have skipped it.

The size budget

For repos under 50k tokens, I let the agent read the whole thing. The cost is one extra API call at the start of the session. The benefit is that every subsequent question is grounded in the actual code.

For repos over 50k tokens, I have to be selective. I use a few strategies:

  • I use the agent’s context-aware features. Most agents now support “include this file” or “include this directory” or a smart RAG over the codebase. I use the smart RAG, not the explicit include.
  • I write a one-paragraph summary of the repo at the top of the CLAUDE.md. The summary includes the file layout, the entry points, the key abstractions, and the things that are “spicy” (legacy code, weird patterns, the one thing everyone avoids).
  • For specific questions, I include the relevant files explicitly. “Look at parser.py and parser_test.py and tell me why this case is failing” is a much better prompt than “the parser is broken.”

The thing I unlearned

I used to think “the agent has a big context window, I can dump everything in.” That’s true in the sense that the model can technically hold 200k tokens. It’s not true in the sense that the model is equally attentive to all 200k tokens. The middle of a long context gets less attention than the beginning and the end.

If you have a 200k context window, the effective attention is more like 30-50k tokens of high-attention content, plus the rest as low-attention reference. The model is good at finding things in the high-attention part and bad at finding things in the low-attention part.

So I don’t dump everything in. I put the relevant 20-30k tokens in the context, and I leave the rest out. The model performs better.

The pattern that works

For a typical session:

  1. Open with a CLAUDE.md or AGENTS.md that summarizes the repo
  2. Include the specific files the question is about
  3. Ask the question
  4. Read the answer
  5. If the answer references code I didn’t include, ask the agent to show me that code
  6. Iterate

This is the loop. The loop is what the model is good at. The “dump everything and ask one question” pattern is what the model is bad at.

The exception

The exception is when I’m doing a “learn this codebase” pass. Then I do dump the whole thing in. The agent’s job is to give me a tour, not to answer a specific question. The tour doesn’t need precise attention to every line. The tour is the agent telling me “here’s the structure, here’s the main flow, here’s where the interesting parts are.” For that, the whole repo is the right input.

For everything else, the relevant files are the right input.


← back to all posts