Everyone talks about model quality. Almost nobody talks about the resource that actually decides whether your AI coding session succeeds: the context window. It is a budget, and you are spending it every turn.
What you are actually spending
A session with an agent loads your instructions, the files it read, its own earlier attempts, tool outputs, and your corrections. All of it sits in the same window. At the start of a session the model is sharp and follows your conventions. Ninety minutes later it is "forgetting" rules you stated up front. It didn't forget. Your rules got diluted by 40,000 tokens of stack traces and half-finished diffs.
The three leaks
1. Reading whole files when a function would do. Every cat entire-module.py costs you thousands of tokens that stay in the window for the rest of the session. Teach the agent to grep first, then read the narrowest range that answers the question.
2. Letting failed attempts accumulate. Three wrong turns leave three full diffs and their error output in context. The model starts pattern-matching on its own mistakes. When an approach fails twice, start a fresh session with a one-paragraph summary of what you learned, not the whole transcript.
3. Stuffing the context file. A 300-line CLAUDE.md is a tax on every single turn. Keep it under 80 lines and push detail into files the agent loads only when a task needs them.
What works instead
Treat context like memory in an embedded system. Small, deliberate allocations. Subagents for research, so their exploration never pollutes your main session. Explicit handoffs: when a session gets long, write the state to a file and restart clean. Hooks that re-inject the two or three rules that matter right before the model writes code, instead of hoping they survived from message one.
The teams getting reliable output from coding agents are not using smarter models. They are spending the window on purpose.
Where this is going
Context discipline is a workflow, not a setting. I packaged mine - context presets that stay small, subagent definitions that isolate exploration, hooks that re-assert rules at the moment of code generation - into The Agentic Coding Kit. 34 files, drop them into a repo. But the mindset is free: every token in the window is a token the model is not spending on your actual problem.
Top comments (0)