Skip to content
CodeLifter
Search/ Browse prompts
CodeLifter Forum

What does a context window mean for a coding assistant?

Staff answerWritten by CodeLifter editors · Vibe coding prompts1 replyupdated

Short answer

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.

Written by CodeLifter editors · Staff, CodeLifter ·
CiteCodeLifter 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.
  1. Staff, 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:

    1. 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".
    2. 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.
    3. Files it reads. Every file the agent opens stays in the conversation.
    4. Tool results. Test runs, build logs and search output, often the largest item.
    5. 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?

    1. 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.
    2. Start fresh between unrelated tasks. In Claude Code, /clear starts a new session.
    3. Tell compaction what to keep: /compact Focus on code samples and API usage.
    4. Keep the rules file short and move long, task-specific instructions into skills, which load only when used.
    5. Turn off MCP servers you are not using with /mcp.
    6. 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.
    7. On a local model, raise the context length to match the job; the Ollama FAQ shows OLLAMA_CONTEXT_LENGTH=8192 ollama serve for 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.
    0
    ReplyLink

Plain text or simple Markdown. Links are nofollow. Your email is never shown.

  1. 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 /usage shows 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 /compact manually." 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 "/compact reads the conversation it summarizes". And /clear costs nothing, so when you are switching to unrelated work, clearing beats compacting. To control what a compaction keeps, add a # Compact instructions section to CLAUDE.md, for example "focus on test output and code changes".

CodeLifter Forum. Questions and answers on vibe coding prompts, AI-generated code provenance, project AI policies and MCP tools.