The context window
If you only learn one thing from these Foundations, learn this. The context window is the single constraint that shapes how every AI tool behaves. Get a feel for it and everything else (better prompts, cleaner workflows, fewer wrong answers) follows almost for free.
What it is
Section titled “What it is”The context window is the model’s working memory: a finite space holding everything it is considering right now. That includes more than your last message:
- Your messages, and the model’s own replies so far
- The contents of any file it has read
- The output of any command it ran
- Its standing instructions (system prompt, your persistent-instructions file)
If something is not in that window, the model does not know it; see How AI coding tools work. The window is the model’s entire awareness of your task.
It fills, and it degrades
Section titled “It fills, and it degrades”The window has a fixed size, measured in tokens (roughly, pieces of words). Today’s models hold context measured in the hundreds of thousands of tokens, and some now reach a million. That sounds enormous. It runs out faster than you’d think. The part people miss: it gets worse long before it runs out.
There are two distinct failure modes:
- It fills up. A long session of reading files and running commands packs the window. When it hits the limit, the oldest content falls out or the tool compresses it, and detail is lost.
- It degrades. Long before the hard limit, a window stuffed with old tangents, dead ends, and irrelevant output buries the signal. The model loses the thread, repeats itself, forgets an instruction you gave ten minutes ago, or contradicts an earlier decision. People call this context rot.
Manage it aggressively
Section titled “Manage it aggressively”Treat the context window like a desk, not a warehouse. Keep what you’re using on it and clear the rest. The exact commands differ per tool, but the moves are the same everywhere:
| Move | When to use it | Typical form |
|---|---|---|
| Start fresh | You’re switching to an unrelated task | New chat, or /clear in a terminal agent |
| Compact | The thread is long but still matters | A /compact or “summarize and continue” step |
| Watch usage | Always | The token / context indicator the tool shows you |
| Scope tightly | Every prompt | Point at the 2–3 relevant files, not the whole repo |
The biggest single habit: a fresh conversation per task. Carrying a finished task into the next one is the most common way people quietly poison their results.
Why this is the linchpin
Section titled “Why this is the linchpin”Almost every advanced technique in these guides is, underneath, a way of putting the right things in the context window and keeping the wrong things out. Choosing which files to load, writing a persistent-instructions file, planning before doing: all of it is context management. That craft has a name: Context engineering.
Where you’ll see this
Section titled “Where you’ll see this”Context limits and the commands to manage them show up in every tool, most visibly here: