Skip to Content

Claude Code Context Full? 7 Ways to Free Up Context

September 15, 2026 by
aliakram

If Claude Code has started repeating itself, forgetting a file you showed it three messages ago, or telling you that the conversation is too long, you've run into the context window.

It's not necessarily a bug. Think of context as Claude Code's working memory: every message, file read, command result, tool definition, memory file, and system instruction competes for space.

The good news is that you don't have to wait until Claude Code hits a hard limit. You can check what's consuming context, compact a long session, clear unrelated work, reduce MCP/tool overhead, and move large exploration tasks into separate subagents.

This guide explains how Claude Code context works and 7 practical ways to free up context without losing the information that actually matters.

What Is the Claude Code Context Window?

The context window is the amount of information Claude can hold and reason about during a session.

In Claude Code, that can include:

  • Your messages and Claude's responses
  • Files Claude has read
  • Command and tool output
  • CLAUDE.md instructions
  • Auto memory
  • Loaded skills
  • MCP tool definitions
  • System instructions and other tool information

The important point is that context isn't just your conversation.

If Claude reads a large source file, runs a verbose test suite, receives a huge search result, or has access to many MCP tools, that information can contribute to the context Claude needs to process.

Anthropic's own Claude Code training describes context as Claude's working memory: prompts, files, tool calls, and tool results all consume space.

Context Is a Budget

A useful way to think about it is:

Context window = everything Claude currently needs to see in order to answer your next request.

The bigger the amount of irrelevant material inside that window, the harder it becomes to keep the important information prominent.

That's why a session can become less useful even before you see an obvious "context limit reached" message.

How Big Is the Claude Code Context Window?

This is one area where older Claude Code articles can be misleading.

The standard context window is 200,000 tokens, while supported extended-context models can use a 1-million-token context window.

Current Claude Code documentation lists Claude Opus 4.7, Opus 4.6, and Sonnet 4.6 as supporting 1M-token context for long sessions. Availability depends on your model, plan, and provider.

You can select an extended-context model with the [1m] variant, for example:

/model opus[1m]

or:

/model sonnet[1m]

The exact models and availability can change, so don't assume that every Claude model automatically has a 1M context window.

Also, 1M context isn't necessarily included in every subscription. Current Claude Code documentation says Opus 1M is included on Max, Team, and Enterprise, while Sonnet 1M and some other access paths can require usage credits.

Why a Bigger Window Doesn't Solve Everything

A larger context window gives Claude more room, but it doesn't make irrelevant context useful.

A 1M-token session filled with:

  • old debugging attempts
  • huge logs
  • irrelevant file reads
  • unused MCP tools
  • outdated instructions

can still become harder to work with than a smaller, focused context.

The goal isn't to maximize context usage.

The goal is to keep the right context available.

Why Does Claude Code Context Fill Up So Fast?

Several normal coding activities can consume context quickly.

Reading Large Files

If Claude reads multiple large source files, generated files, configuration files, or documentation pages, their contents can add substantial context.

Verbose Terminal Output

A long test run, build log, stack trace, or repository-wide search can return thousands of lines even when only a few lines contain the answer.

Long Debugging Sessions

A conversation containing dozens of:

Try this → here's the error → try that → here's another error

turns every failed attempt into additional history.

Large CLAUDE.md Files

CLAUDE.md provides persistent instructions, but unnecessarily long instructions consume context and can make important rules harder to follow.

MCP and Tool Definitions

This is an easy one to overlook.

MCP servers can add tool definitions to the context even when you don't actually call those tools during the current task. Anthropic specifically recommends disabling unused MCP servers when context is tight.

Exploration Without a Narrow Goal

If you ask Claude to broadly "investigate the entire authentication system," it may read many files and produce lots of intermediate information.

For large exploration tasks, a subagent can often do the investigation separately and return only the useful result to the main session.

How to Check Claude Code Context Usage

The first step is to stop guessing.

Run:

/context

Claude Code shows a breakdown of what's consuming the current context, including categories such as messages, tools, system information, memory, and other context components.

This helps answer a much more useful question than:

"Why is my context full?"

You can instead ask:

"What's actually taking up my context?"

Check Usage and Cost

Current Claude Code versions use:

/usage

for usage information.

Older /cost and /stats commands remain available as shortcuts, but Claude Code documentation notes that these were merged into /usage.

What Happens When Claude Code Context Fills Up?

Claude Code has automatic context management.

As the context approaches its limit, Claude Code can automatically compact the conversation. The system can first clear older tool outputs and then summarize conversation history when necessary.

The important part is that compaction can lose details.

A summary may preserve:

  • important decisions
  • code changes
  • current task
  • relevant files
  • major findings

while dropping less important conversational details.

That's why Claude can sometimes appear to "forget" a specific instruction from much earlier in a long session.

It's not necessarily that Claude has no memory of the project. The original conversation may have been compressed.

Compaction Can Fail Too

If the context is already extremely full, Claude Code may not have enough room to generate the compaction summary.

In that situation you can see an error such as:

Conversation too long

Claude Code's current troubleshooting guidance recommends stepping back with /rewind, compacting again, or starting fresh with /clear if necessary.

7 Ways to Free Up Context in Claude Code

1. Use /clear Between Unrelated Tasks

When you finish one feature and move to something completely different, don't feel obligated to carry the entire conversation forward.

Run:

/clear

This starts the current session with an empty conversation context. Your previous session isn't simply destroyed; Claude Code saves sessions so they can be resumed later.

When should you use /clear?

Use it when:

  • you've finished a feature
  • you're switching to an unrelated bug
  • you're starting a new feature
  • the conversation contains too many failed approaches
  • Claude keeps making the same mistake

Anthropic's current best-practice guidance specifically recommends /clear between unrelated tasks because irrelevant long-session context can reduce performance.

A useful practical rule:

One focused task is usually better than turning one Claude Code session into a giant junk drawer.

2. Use /compact When You Need to Keep the Thread

/clear is not always the right choice.

If you're still working on the same feature and simply need more room, use:

/compact

Claude Code summarizes the conversation and continues with a smaller context.

You can also tell it what matters:

/compact Focus on the API changes, current implementation, modified files, and unresolved test failures.

This is particularly useful for long debugging sessions where you don't want to throw away the entire thread.

Anthropic's official guidance explicitly recommends focused compaction when you want to preserve specific information.

/clear vs /compact

CommandBest for
/clearStarting an unrelated task
/compactContinuing the same task with less history
/rewindSelectively changing or summarizing part of a session

3. Use /rewind to Compress Only Part of the Conversation

This is one of the most useful additions to modern Claude Code context management.

Press:

Esc + Esc

or run:

/rewind

The rewind interface lets you move back through session checkpoints.

Depending on the available options, you can restore conversation/code state or summarize a selected portion of the conversation. Current Claude Code guidance also supports using rewind to selectively summarize part of a session rather than compacting the entire history.

This is useful when:

  1. You spent 30 minutes exploring possible solutions.
  2. You finally found the correct approach.
  3. You want to compress the old exploration.
  4. You don't want the recent successful implementation summarized away.

Instead of destroying the whole thread, you can selectively reduce the historical noise.

/compact vs /rewind

Think of it this way:

  • /compact = compress the conversation broadly
  • /rewind = choose where the historical boundary should be

That gives you more control over what stays detailed.

4. Keep CLAUDE.md Small and Useful

CLAUDE.md is valuable because it gives Claude persistent project instructions.

But don't turn it into a 1,000-line encyclopedia.

Put things Claude genuinely needs to know repeatedly:

  • project architecture
  • important commands
  • coding conventions
  • testing requirements
  • deployment rules
  • important constraints
  • project-specific decisions

Avoid filling it with information Claude can easily discover from the repository.

A useful strategy is progressive disclosure.

Instead of putting every frontend, backend, testing, and deployment rule directly into one file, keep CLAUDE.md as a concise index pointing Claude toward more specific documentation when necessary.

For example:

# Project Instructions

## Frontend
Read docs/frontend-rules.md for frontend-specific conventions.

## Backend
Read docs/backend-rules.md for API conventions.

## Testing
Read docs/testing.md before changing the test suite.

This keeps always-loaded context smaller while preserving access to deeper documentation.

Current Claude Code guidance also notes that project and memory instructions survive compaction, so persistent rules belong in files rather than being repeated only in conversation.

5. Disable MCP Servers and Tools You Don't Need

MCP can be extremely useful, but every connected tool has a context cost.

For example, you might have:

  • GitHub
  • database
  • browser automation
  • documentation
  • design tools
  • monitoring
  • project management

connected at the same time.

If you're working only on a backend bug, many of those tools may be irrelevant.

Claude Code's troubleshooting documentation specifically recommends disabling unused MCP servers because their tool definitions can consume context.

For example:

/mcp disable <server-name>

You can re-enable the server later when you actually need it.

Why This Matters

The problem isn't necessarily the number of MCP servers.

It's the amount of tool information Claude has to carry around.

One community discussion reported significant initial-context overhead from multiple MCP servers, illustrating why tool selection can matter in real-world sessions. Treat those community numbers as anecdotal rather than universal benchmarks.

6. Delegate Large Exploration to Subagents

Don't make your main Claude Code session read the entire internet—or entire repository—when you only need the conclusion.

Subagents can operate in separate context and return a result to the main agent.

For example:

Use a subagent to investigate where authentication token refresh is implemented.
Return the relevant files, functions, and a short explanation.
Don't modify any code.

Instead of filling your main context with:

  • dozens of file reads
  • grep results
  • failed searches
  • exploratory reasoning

you can receive a compact result such as:

Token refresh is handled in:

src/auth/token.ts
src/auth/session.ts

The main flow begins in refreshAccessToken().

Anthropic's Claude Code 101 course specifically recommends subagents for tasks where you only need the result, because they can keep exploratory work out of the main context.

Important Caveat

Subagents aren't a magic context bypass.

Current Claude Code documentation warns that subagents can inherit MCP tool definitions from the parent session, meaning a heavily loaded MCP setup can still create context problems. Disable unnecessary MCP servers before spawning subagents when context is tight.

7. Reduce What You Put Into the Context

The easiest context to manage is context you never loaded in the first place.

Instead of pasting a 2,000-line file into your prompt, tell Claude where the file is.

Instead of pasting an entire 20,000-line build log, point Claude toward the log and ask it to find the relevant failure.

Instead of asking:

Read the whole repository and figure out how authentication works.

be more specific:

Find the files responsible for login and token refresh.
Trace the authentication flow from the API endpoint to token storage.
Only inspect files relevant to that flow.

Specific prompts can actually save context because they reduce unnecessary exploration. Anthropic's Claude Code training makes the same point: vague instructions can force Claude to explore more of the codebase, consuming more context.

Use File References When You Know the File

If you already know the relevant file, reference it directly rather than making Claude search the entire repository.

For example:

Review @src/auth/session.ts and explain why refresh tokens are expiring.

This narrows the information Claude needs to inspect and can make the interaction faster and more focused.

Bonus: Use /btw for Quick Side Questions

Sometimes you need to ask Claude something that shouldn't become part of the main development conversation.

For example:

"What's the difference between JWT and session cookies?"

Instead of adding another turn to your main thread, use:

/btw

Claude Code's side-question feature allows you to ask a quick question without adding the response to the main conversation history.

This is useful for:

  • checking an assumption
  • asking about an API
  • understanding a small piece of code
  • getting a quick explanation

without polluting your primary task context.

Advanced: Find Context Bloat Instead of Guessing

If /context shows that tools or system information are consuming a surprisingly large amount of space, don't automatically delete everything.

First identify what's actually responsible.

Current Claude Code documentation exposes context usage by categories, while advanced users have also developed techniques for inspecting the underlying request payload to identify unusually large tool definitions.

The important lesson is:

Measure first, then remove the actual source of bloat.

For example, if one unused MCP integration contributes a large collection of tool definitions, disabling that integration can be much more effective than randomly trimming project files.

A Better Context-Management Workflow

Instead of waiting for Claude Code to complain, use a simple workflow.

Step 1: Start with a focused task

Tell Claude exactly what you want changed.

Fix the authentication refresh bug.
Only modify the auth module.
Run the relevant tests after the fix.

Step 2: Let Claude explore only what it needs

Avoid dumping the entire repository into the conversation.

Step 3: Use subagents for broad research

If the task requires extensive exploration, delegate that exploration when appropriate.

Step 4: Check /context

Use:

/context

when a session becomes large or before beginning another major phase.

Step 5: Compact at a natural breakpoint

If you're continuing the same feature:

/compact Focus on the current implementation, decisions, modified files, and remaining test failures.

Step 6: Clear when the task changes

If you've finished authentication and now want to work on a completely unrelated UI feature:

/clear

Step 7: Preserve important knowledge outside the conversation

If something needs to survive future sessions, put it in an appropriate persistent location such as CLAUDE.md or project documentation instead of trusting a long conversation to remember it forever.

Quick Reference: Claude Code Context Commands

CommandWhat it does
/contextShows what's consuming the current context
/clearStarts fresh with an empty conversation context
/compactSummarizes the current conversation to free space
/rewindRewinds or selectively summarizes part of a session
/usageShows current usage information
/modelChanges the active model/context configuration
/mcpManage MCP servers
/btwAsk a side question without adding it to the main history

Frequently Asked Questions

Does /clear delete my code changes?

No.

/clear affects the conversation context, not files already written to disk. Claude Code also preserves the previous session so you can resume it later if needed.

Still, always use normal Git practices for important work.

Why does Claude Code seem to forget something before the context is full?

One common reason is compaction.

When Claude Code automatically compacts a long conversation, earlier details may be summarized or dropped. Current Claude Code documentation explicitly warns that instructions from earlier in a conversation can be lost during compaction.

If an instruction is important enough to survive across sessions, don't rely solely on chat history. Put it in the appropriate project instructions or documentation.

Is a 1M-token context window always better?

No.

It gives Claude more room, but a huge amount of irrelevant context can still make a session less focused.

The goal isn't:

"Use as many tokens as possible."

The goal is:

"Give Claude the information it needs and remove what it doesn't."

Should I use /compact at 50%?

Not as a strict rule.

There is no universal percentage at which every session should be compacted.

A better approach is to look at what you're doing.

If you're still deep inside the same feature and the context is useful, continuing may make sense.

If you're switching tasks or the context is filled with failed approaches and irrelevant exploration, /clear can be better.

If you need to continue the same task but want to reduce accumulated history, /compact is appropriate.

What if /compact fails?

If the conversation is already too large, Claude Code may not have enough free context to create the compaction summary.

Try:

/rewind

or press:

Esc + Esc

and step back to an earlier point.

Then compact again.

If that doesn't work, start fresh with:

/clear

Anthropic's current troubleshooting documentation recommends this sequence for "Conversation too long" situations.

Does context affect cost?

It can.

A long session can contain substantially more input context than a fresh session. Depending on your Claude Code plan and billing setup, reducing unnecessary context can therefore matter for both performance and usage.

But don't sacrifice useful context merely to save tokens. The better strategy is to eliminate irrelevant context rather than aggressively deleting everything.

What should I do if Claude keeps making the same mistake?

Don't keep adding corrections forever.

If you've corrected the same issue repeatedly, the conversation may be accumulating failed approaches and contradictory instructions.

Current Claude Code best practices specifically recommend using /clear when you've corrected Claude more than twice on the same issue, then restarting with a more precise prompt.

A clean context plus a better prompt can be more effective than another five correction messages.

Should I use /clear after every task?

Not necessarily.

The right rule is:

Keep related work together; separate unrelated work.

A long session can be useful when Claude needs the accumulated understanding of the same feature or codebase.

But once the conversation becomes a mixture of unrelated features, old experiments, failed approaches, and obsolete instructions, starting fresh usually makes more sense.

The Bottom Line

Claude Code's context window is a limited working-memory budget, not simply a counter for how many messages you've sent.

Files, commands, tool results, MCP definitions, memory, system instructions, and conversation history can all contribute to that budget.

The best strategy isn't to obsess over the percentage.

Instead:

  1. Use /context to see what's actually consuming space.
  2. Use /clear when switching to an unrelated task.
  3. Use /compact when continuing the same task.
  4. Use /rewind when you want more selective context cleanup.
  5. Keep CLAUDE.md concise and focused.
  6. Disable MCP servers and tools you don't need.
  7. Use subagents and focused prompts for large exploration tasks.
  8. Use /btw for side questions that don't belong in the main thread.
  9. Put important long-term instructions in persistent project documentation instead of relying on conversation history.

The biggest mindset shift is simple:

Don't try to maximize Claude Code's context. Try to maximize the relevance of what's inside it.

A clean 200K context can be more useful than a cluttered 1M context.

And when Claude Code starts acting like it has forgotten what you told it, don't immediately blame the model. First check the context.