Skip to content

devlog/model-bench/whole-repo-prompts-without-blowing-your-context-window-689.md

Whole-Repo Prompts Without Blowing Your Context Window

Your terminal can collect more than a model can use

The tempting whole-repo workflow is simple: concatenate files, paste everything into your coding agent, and ask for a cross-cutting change. In 2026, larger context windows make that increasingly feasible. They do not make every repository worth stuffing into one request.

A context window is the token budget available to a model invocation. Your instructions, conversation history, source files, and tool results consume it. Depending on the API, generated output and reasoning tokens also affect the available budget. Check the actual endpoint limits rather than trusting a model name or a headline number.

Budget the patch before packing the repository

Suppose an endpoint documents a 128,000-token window. That is an illustrative budget, not a promise about any particular model. Sending 125,000 tokens of source leaves little room for instructions, investigation, and a useful answer. A large patch can fail even when the initial request fits.

My starting rule is to reserve roughly a quarter of the documented window for output, tool results, and follow-up work, then adjust using observed usage. Check maximum output separately: a large input window does not guarantee an equally large response.

  • Count tokens with the target tokenizer whenever one is available.
  • Exclude generated assets, dependency directories, binaries, and unrelated lockfiles first.
  • Keep extra headroom when tool calls return unpredictable amounts of text.
  • Record actual usage after each run instead of guessing forever.

Build a repository map before a repository dump

Start with the directory tree, build commands, package manifests, and a short description of module boundaries. Then include the files directly involved in the task, their callers, and relevant tests. Use git ls-files to inventory tracked files and ripgrep to follow symbols before expanding the bundle.

For an authentication change, that might mean middleware, session storage, route guards, configuration, and integration tests. It probably does not mean every migration and frontend asset. Whole-repo awareness is the goal; whole-repo serialization is only one possible technique.

Give each included file an unambiguous path boundary and preserve line numbers when your tooling supports them. Ask the agent to name missing dependencies before editing. That exposes blind spots earlier than discovering them through a broken build.

Test long-context retrieval, not just advertised capacity

Capacity and reliable attention are different measurements. A model can accept a large request yet miss a small constraint buried in the middle. Put the task and acceptance criteria up front, keep the source bundle organized, and restate critical constraints briefly after it.

If you are comparing Claude Sonnet 5.5 with Gemini 3.1 Pro, use the same repository snapshot and evaluation script. Verify each endpoint's current window, output limit, and caching behavior rather than assuming parity. Score compile success, test results, missed requirements, latency, and total billed tokens—not whether the explanation sounds confident.

Keep stable context cacheable and secrets out

Where prefix caching is supported, keep stable instructions and unchanged source first, with the changing task later. Avoid timestamps or shuffled file ordering at the beginning. Cache behavior is provider-specific, so inspect usage fields and documented retention rules. A cache hit can reduce processing cost without making that context disappear from the window.

Review the bundle before sending it. Tracked files can still contain credentials, customer data, or private fixtures. Repository text is also untrusted input: comments that tell an agent to ignore instructions should remain source material, not become operating instructions.

Measure relay costs across repeatable repo tasks

Fluxo provides one key and one base URL, https://api.fluxorelay.com, for Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK, making repeatable endpoint comparisons easier.

Billing is per real token, including cache reads and writes, with no monthly fee. Compare complete task costs, including retries and repeated context. If you want to try this workflow, create a Fluxo account. Users also earn a referral share when people they invite pay.

The practical default for 2026 is selective context, explicit budgets, and executable verification. Reach for a whole-repo prompt when the task genuinely crosses repository boundaries—not simply because the window has room.

Next in the buffer

Sign up in a minute and get credit to try every model mentioned here. Sign up →