[FEATURE] Increase effective context window / reduce compaction overhead in Claude Code

Status Fixed / completed
Maintainer reply None cached
Activity 7 comments · opened Feb 26, 2026 · closed Mar 25, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Context window compaction overhead significantly reduces effective token utilization in Claude Code

Environment: Claude Code (Max plan, $115/mo)

Problem:
During extended agentic coding sessions, context window compaction kicks in frequently and consumes what feels like roughly half of the available tokens. This creates a frustrating loop where:

  1. Context fills up with codebase files, tool calls, and conversation history
  2. Compaction triggers and repacks the window
  3. Useful context from earlier in the session gets lost or compressed
  4. The agent then needs to re-read files or re-establish context, burning even more tokens

This is particularly painful when working on complex tasks that span multiple files or require deep understanding of a codebase - exactly the scenarios where an agentic coding tool should shine.

Expected behavior:
More of the context window should be available for productive work. At the Max tier pricing, the effective usable context feels disproportionately small relative to what's being paid for.

Suggestions:

  • Increase the base context window size for Claude Code sessions
  • Optimize the compaction algorithm to retain more relevant context
  • Consider a smarter eviction strategy that prioritizes keeping recently referenced files and key architectural context
  • Provide users with metrics on context utilization (productive vs. overhead tokens)

Proposed Solution

There should be a larger effective context window for Claude Code sessions, or a more efficient compaction strategy that preserves more usable context.

Ideally:

  • Compaction should prioritize retaining file contents and architectural decisions made during the session over conversation history
  • A smarter eviction strategy that keeps recently referenced files and key decisions intact
  • Optionally, a visible indicator showing how much context is productive vs. overhead, so users can plan when to break tasks into smaller chunks
  • Consider allowing Max plan users ($115/mo) to opt into a larger context window, even if it costs more tokens per session

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

Example scenario:

I ask Claude Code to implement an RBAC system across multiple files - routes, middleware, database schema, and tests. Midway through the task (~15-20 tool calls in), compaction triggers. After compaction, Claude loses track of the schema decisions it made earlier, re-reads the same files it already processed, and sometimes even contradicts its own prior implementation choices. I end up manually re-explaining the requirements or starting a new session, which defeats the purpose of an agentic workflow.

What should take one continuous session ends up split across 2-3 sessions with me copy-pasting context between them.

Additional Context

_No response_

View original on GitHub ↗

7 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/24315
  2. https://github.com/anthropics/claude-code/issues/27293
  3. https://github.com/anthropics/claude-code/issues/24179

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Vilis322 · 6 months ago

👎

m13v · 5 months ago

This is one of the most impactful issues for heavy Claude Code users. A few patterns we have found that help manage context window pressure in practice:

  1. Layered CLAUDE.md - instead of one massive CLAUDE.md, split instructions into a root-level file with core rules and subdirectory-specific files. Subagents spawned in subdirectories only pick up their local context, not the full monolith.
  1. Aggressive subagent delegation - dispatch focused tasks to subagents (Task tool) rather than doing everything in the parent. Each subagent gets a fresh context window. The parent only receives a summary of results.
  1. Git worktree isolation - when using parallel agents, worktree isolation prevents them from stepping on each other and reduces the context each agent needs to track.
  1. Explicit compaction hints - structuring your prompts with clear section headers helps the compaction algorithm identify what can be safely dropped vs what is critical context.

The fundamental constraint is the model's context limit, but smart session architecture can get you 3-5x more effective work per session.

m13v · 5 months ago

We run multiple parallel Claude Code agents daily using tmux orchestration with worktree isolation - here is how we structure sessions to maximize effective context: https://github.com/m13v/tmux-background-agents/blob/main/SKILL.md

The layered CLAUDE.md pattern and subagent delegation are core to our workflow: https://fazm.ai/gh

m13v · 5 months ago

the compaction overhead is real. we lose probably 20-30% of effective context to compaction artifacts in long sessions. one thing that helped us was being aggressive about what goes into context in the first place - we pre-filter file reads to only include relevant sections rather than dumping entire files, and we use structured summaries for tool results instead of raw output. doesn't fix the underlying issue but buys you more useful tokens before compaction kicks in.

m13v · 5 months ago

fwiw here's how we handle context management in our agent - the chat provider manages what goes into context and tries to minimize waste before compaction becomes necessary: https://github.com/m13v/fazm/blob/main/Desktop/Sources/Providers/ChatProvider.swift

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.