← Back to Blog Claude Code Guide

How to Reduce Your Claude Code Context Window (2026)

Last updated: July 2026

Quick Answer

To reduce Claude Code's context window, run /compact to summarize and shrink history, use /clear between unrelated tasks, keep your CLAUDE.md lean, tell Claude which specific files to read instead of the whole repo, and delegate research to subagents so their output never lands in your main thread.

Table of Contents

  1. What Fills Claude Code's Context Window
  2. Why a Bloated Context Costs You Twice
  3. 8 Techniques to Reduce the Context Window
  4. How Terse Helps
  5. Summary

What Fills Claude Code's Context Window

Claude Code's context window is the total pool of tokens the model sees on every request. It is not just the message you type. Four things pour into it, and most of them grow silently as you work:

That last point is what surprises most developers. Nothing leaves the context on its own. Everything you and Claude add early in a session keeps riding along, turn after turn, quietly inflating the payload. Understanding that token optimization is really about managing this accumulating payload is the key to everything below.

Why a Bloated Context Costs You Twice

A full context window hurts you in two distinct ways: your wallet and your output quality.

Cost and speed

Because history re-sends every turn, a token you add on turn 1 gets billed again on every subsequent turn. Over a 40-turn session, a 5,000-token file read that stays in context can be transmitted dozens of times. Bigger context also means slower responses — the model has more to process before it can answer. This is why context size is one of the biggest levers on your Claude Code pricing and overall AI coding agent costs. If you want to see how the numbers move, the token calculator makes the compounding effect concrete.

Context rot

The subtler cost is quality. As the window fills, answers get worse — a phenomenon commonly called context rot. When the context is crowded with stale file contents, old tool output, and history from tasks you finished an hour ago, the model spends attention on irrelevant tokens and is more likely to lose the thread of your actual instructions. A lean context is not just cheaper; it is measurably sharper. Reducing the window is therefore a quality strategy as much as a cost one.

Where a typical Claude Code session's tokens go

CLAUDE.md + system instructions~15%
Your prompts (what you type)~10%
Conversation history (re-sent each turn)~30%
File reads + tool/command output~45%

8 Techniques to Reduce the Context Window

Here are the practical moves, roughly in order of impact. Most take seconds and pay off immediately.

1 Use /compact to summarize and shrink history

When a session gets long but you still need continuity, run /compact. It replaces the bulky conversation history with a concise AI-generated summary, preserving what matters while reclaiming a large share of the window. You can steer it — /compact focus on the auth refactor we just did — to keep the summary tight around the work that still matters. Compact when you feel responses slowing down or the context indicator climbing past two-thirds.

2 Use /clear between unrelated tasks

When you switch to something genuinely new — a different feature, a different bug — do not keep the old conversation around. Run /clear to wipe the context and start fresh. Carrying the debugging session for feature A into your work on feature B gives you all the cost and none of the benefit. As a rule: new task, new context.

3 Keep your CLAUDE.md lean

Because CLAUDE.md is injected on every turn, every line you cut saves tokens across the entire session. Trim it to durable, high-signal facts: build commands, architecture notes, hard rules. Move rarely-needed detail into separate docs that Claude reads only on demand. A tight 40-line CLAUDE.md beats a sprawling 400-line one that repeats things the model can infer from the code.

4 Be specific about which files to read

"Read the whole repo and figure it out" is the single most expensive instruction you can give. Instead, point Claude at the exact files or directories that matter: "Read src/auth/session.rs and its test." Specific reads keep the window small and, as a bonus, focus the model on the code that actually matters — a double win against context rot.

5 Use subagents for isolated research

When you need broad exploration — "find everywhere we validate tokens" — delegate it to a subagent. The subagent burns through files in its own context window and returns only a short conclusion to your main thread. All those file reads and dead-end searches never pollute your primary session. This is the cleanest way to do heavy research without paying for it on every subsequent turn.

6 Avoid re-reading the same file

If a file is already in context, do not ask Claude to read it again — the content is right there. Re-reading duplicates the entire payload and pushes you toward context rot faster. The same applies to re-running an identical search or command: each duplicate tool result is injected fresh and then re-sent every turn afterward. Duplicate tool calls are pure waste.

7 Prefer targeted edits over rewrites

Ask for surgical edits rather than having Claude reprint whole files. A targeted diff adds a handful of tokens; regenerating a 300-line file adds all 300 to the output and the history. Precise edits keep both the response and the growing context small.

8 Commit and start fresh for new features

When you finish a unit of work, commit it and then /clear. The commit is your durable record; you no longer need the whole conversation that produced it living in context. Starting each feature from a clean window is the most reliable way to keep sessions fast and sharp over a long day.

How Terse Helps

Terse for Claude Code attacks the context problem from two light-touch angles. First, it compresses the prompts you type before they ever enter the conversation — stripping filler, hedging, and padding on-device in under a millisecond, so the tokens you contribute stay minimal and, because history re-sends, stay minimal across every turn.

Second, Terse watches your Claude Code sessions and flags redundant work: duplicate tool calls and repeated file reads that quietly inflate your context. When Claude reads the same file twice or re-runs a search it already ran, Terse surfaces it so you can catch the waste. It is a nudge, not a takeover — the goal is to make the invisible growth of your context window visible.

Keep your Claude Code context lean

Terse compresses the prompts you type and flags duplicate tool calls and file reads in your Claude Code sessions. On-device, zero latency, no API calls.

Terse for Claude Code

Summary

Claude Code's context window fills with your CLAUDE.md, every file it reads, tool output, and a conversation history that re-sends on every turn. A bloated window costs you twice — real dollars from re-billed tokens, and degraded answers from context rot. The fixes are simple and habitual:

Do these consistently and you will spend less, get faster responses, and keep Claude sharp deep into a working session. For the cost side of the picture, dig into Claude Code pricing and the broader AI coding agent costs breakdown.

Further Reading

Related articles

How to Reduce Your Cursor Costs How to Reduce GitHub Copilot Costs How to Write Prompts That Use Fewer Tokens