What does a context window mean for a coding assistant?
A context window is the most text, counted in tokens, that a model can work with in one request, including its own reply. For a coding assistant it holds the system prompt, your rules file, tool definitions, every file it has read, command output and the conversation so far. When it fills, the tool must summarise or drop something.
Cite
CodeLifter Forum, "What does a context window mean for a coding assistant?", https://codelifter.com/forum/posts/what-does-a-context-window-mean-for-a-coding-assistant/, accessed 2026-11-17.- CodeLifter editorsStaffStaff, CodeLifter ·
What is a token, and how big is a window?
A token is the unit a model reads and writes: a word, part of a word, a symbol or a space. OpenAI's help page on tokens, read on 16 October 2026, gives rough figures for English: "1 token is approximately 4 characters" and "100 tokens are approximately 75 words." It stresses that these are estimates and that counts depend on the model's encoding. Code, with its brackets and indentation, splits differently from prose, so count with the vendor's tool rather than guessing.
Anthropic's context windows page describes the window as "a 'working memory' for the model", separate from the data it was trained on. Window sizes vary a lot by setup:
Setup Context window Source, read 16 October 2026 Current Claude models such as Claude Opus 5.5 and Sonnet 5.5 1M tokens, with up to 128k output tokens per request Anthropic context windows page Other Claude models, including Sonnet 4.5 200k tokens Same page A model run through Ollama with default settings 4,096 tokens unless you raise it Ollama FAQ That last row surprises people: the same open model can behave very differently in a coding agent depending on the context length the runner gives it.
What fills the window during a coding session?
Anthropic's page lists what counts: "the system prompt, every message in
messages(including tool results, images, and documents), and your tool definitions", plus the output, "including its extended thinking". In a coding agent that means:- Instructions loaded at start. The tool's own system prompt and your rules file. Claude Code's costs page says
CLAUDE.md"is loaded into context at session start" and suggests keeping it "under 200 lines". - Tool definitions. Each tool, including MCP tools, comes with a name, description and schema. Claude Code defers MCP tool definitions by default, so only names and server instructions load until a tool is used.
- Files it reads. Every file the agent opens stays in the conversation.
- Tool results. Test runs, build logs and search output, often the largest item.
- The conversation. Every earlier turn. The costs page notes that "Claude Code sends your full conversation with every request."
So a long session is not only expensive; it also crowds the space the model has left for your next request. The AGENTS.md thread covers why a short rules file works better than a long one.
Why does a bigger window not fix everything?
Because models use long contexts unevenly. Anthropic's page says: "As token count grows, accuracy and recall degrade, a phenomenon known as context rot." A 2023 study, Lost in the Middle, found that "performance is often highest when relevant information occurs at the beginning or end of the input context, and significantly degrades when models must access relevant information in the middle of long contexts, even for explicitly long-context models." For coding, that means a function signature read 300k tokens ago may be used less reliably than one in the file you just named. How a model produces code from what is in its window is explained in the LLM thread.
What happens when the window fills up?
It depends on the layer:
- The API. On Anthropic's API, if the input alone is larger than the window, the request fails with a 400 error, "prompt is too long". If the reply runs into the limit, it stops with
stop_reason: "model_context_window_exceeded". - The coding tool. Claude Code compacts automatically: it summarises older history to free space as the session nears its auto-compact window. In VS Code, a context indicator in the prompt box shows how full the window is.
- Chat interfaces. Anthropic's page notes that apps such as claude.ai "can also manage the context window on a rolling 'first in, first out' basis", which means the oldest messages drop out first.
Summaries lose detail. If an early instruction matters, put it in the rules file, where it reloads every session, rather than trusting it to survive a summary.
How do you keep a coding assistant's context useful?
- Name the file and function. The costs page contrasts "improve this codebase", which triggers broad scanning, with "add input validation to the login function in auth.ts". The CodeLifter guide to writing a coding prompt covers the rest.
- Start fresh between unrelated tasks. In Claude Code,
/clearstarts a new session. - Tell compaction what to keep:
/compact Focus on code samples and API usage. - Keep the rules file short and move long, task-specific instructions into skills, which load only when used.
- Turn off MCP servers you are not using with
/mcp. - Send noisy work elsewhere. The costs page suggests subagents for test runs and log processing, so only a summary returns, and hooks that filter test output to failures.
- On a local model, raise the context length to match the job; the Ollama FAQ shows
OLLAMA_CONTEXT_LENGTH=8192 ollama servefor 8K.
Short version
- The context window is everything a model can consider in one request, measured in tokens, including its reply.
- In a coding agent it fills with instructions, tool definitions, files read, tool output and the conversation.
- Bigger windows still lose accuracy as they fill, especially for material in the middle.
- When full, tools summarise or drop old content; keep must-follow rules in the rules file.
- Clear between tasks, name exact files, and keep tool output out of the main conversation.
- Instructions loaded at start. The tool's own system prompt and your rules file. Claude Code's costs page says
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email already has an account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.
1 answer
- CodeLifter editorsStaffStaff, CodeLifter ·
How do you check how much context Claude Code is using? Run
/context. Anthropic's costs page, read on 16 October 2026, recommends it "to see what's consuming space", and/usageshows the session's token counts. You can also configure the status line to show context use all the time. In the VS Code extension, the VS Code page says the prompt box shows "how much of Claude's context window you're using", and that "Claude automatically compacts when needed, or you can run/compactmanually." Do not confuse that with the token count next to the spinner while Claude works. The costs page says that number counts only the output of the current turn, and leaves out "your prompt, the conversation history, and the rest of your context". Two cost notes follow from how the window works. Compaction is itself a big request, because "/compactreads the conversation it summarizes". And/clearcosts nothing, so when you are switching to unrelated work, clearing beats compacting. To control what a compaction keeps, add a# Compact instructionssection toCLAUDE.md, for example "focus on test output and code changes".