All posts
4 min read

What Is a Context Window? Why AI Tools 'Forget' Things

An AI model can only consider so much text at once — its context window. What's in it, why long sessions get worse, what 'compacting' does, and practical habits for working with Claude Code and other tools so the right information is always in view.

getting startedAI agentscontextbeginner

You've been working with an AI coding tool for an hour. It started sharp. Now it's repeating mistakes you corrected earlier, forgetting decisions, and re-reading files it already read. It hasn't got tired. It's running out of context.

What a context window is

An AI model has no memory between requests. Every time it responds, it reads everything it needs, from scratch: your instructions, the conversation so far, the files it opened, and the output of commands it ran. That whole bundle is its context.

The context window is the maximum amount the model can read at once, measured in tokens — chunks of text roughly three to four characters long. (What Are Tokens in AI?.) Current Claude models have windows of hundreds of thousands of tokens, and some go to a million. That sounds huge — hundreds of pages — but a coding session fills it faster than you'd think.

Think of it as the model's desk. Whatever's on the desk, it can see. Whatever isn't, doesn't exist for it.

What fills it up

In an AI coding tool, the context holds:

  • System instructions from the tool itself.
  • Your instruction files, like CLAUDE.md.
  • Every message you've sent and every reply.
  • Every file the tool has read — whole files, not just the part it needed.
  • Every command's output — test results, build logs, error traces.
  • Tool descriptions, including those from any connected MCP servers. (What Is MCP?.)

A few large files and a verbose test run can take a big bite in one step.

Why long sessions get worse

Two things happen as the context grows:

  1. Quality drops before the limit. Models get less reliable at finding and using the important details when there's a lot of material. An early instruction buried under 100,000 tokens of logs gets less attention than it did at the start.
  2. Things have to be dropped. When the window is nearly full, something must go.

Compaction

Claude Code handles a full context by compacting: summarising the conversation so far into a shorter version and continuing from the summary. It does this automatically when needed, and you can trigger it with /compact, optionally telling it what to keep:

/compact keep the decisions about the database schema and the list of failing tests

A summary is lossy. Details that seemed unimportant at the time — the exact error message, the reason you rejected an approach — may not survive. That's often when the "forgetting" begins.

Habits that help

1. One task per session. When you finish a task, start fresh with /clear rather than carrying the old conversation along. Smaller context, sharper model, lower cost.

2. Put lasting knowledge in files, not in chat. Anything that should survive the session — conventions, architecture decisions, commands to run — belongs in CLAUDE.md or project docs, which are read at the start of every session. (How to Write a CLAUDE.md.)

3. Have the agent write notes for long tasks. Ask it to keep a PLAN.md or NOTES.md with progress and decisions, and to re-read it. A file survives compaction; a chat message may not.

4. Be specific about what to read. "Fix the date bug in src/lib/schedule.ts" loads one file. "Find and fix the date bug" may load twenty.

5. Keep noisy output out. Ask for the failing test's output only, not the whole suite's. Paste the relevant error, not the whole log.

6. Use subagents for exploration. Claude Code can hand a research task to a subagent that works in its own context and returns only a summary, keeping the main session clean. (Claude Code Subagents.)

7. Check what's in there. Claude Code's /context command shows what's using the space.

Context windows vs memory

A bigger context window isn't memory. It's a bigger desk that's still cleared after every session. Real continuity comes from things that persist outside the model: files, notes, Git history, and a working environment that's still there tomorrow. (Why AI Agents Forget goes deeper.)

You can also resume a previous Claude Code conversation with claude --continue or claude --resume, which reloads its history. (How to Resume a Claude Code Session.)

The summary

  • The context window is everything the model can see at once, measured in tokens.
  • Files, command output, and conversation history all fill it.
  • Quality drops as it fills; compaction summarises and loses detail.
  • Short, focused sessions plus knowledge stored in files beat marathon conversations.

EasySpawn gives Claude Code a persistent workspace, so your CLAUDE.md, notes files, and project state are still there tomorrow — even when the conversation isn't. See how it works or join the waitlist.

Related: What Is an LLM? · Why AI Coding Agents Need Persistent Workspaces · Keep Claude Code Costs Down

Keep reading