Claude Code Context Window Exceeded (2026)
The Error
Warning: Context window usage at 95% (190,000 / 200,000 tokens).
Claude Code will begin compacting conversation history.
# Or:
Error: Context window exceeded. Cannot process this request.
Total tokens (system + messages + tools): 201,347
Maximum context window: 200,000 tokens
Please start a new conversation or reduce your prompt.
The Fix
- Use the /compact command to summarize and free context space
# Inside Claude Code, type:
/compact
# Or with a focus hint:
/compact Focus on the current task: fixing the auth module
- Start a sub-session for the next task
# Exit and start fresh, referencing only what you need
claude -p "Read src/auth/login.ts and fix the null pointer on line 42" --trust --yes
# Or use --continue to resume with compacted context
claude --continue
- Verify the fix:
# Check context usage after compacting
# Inside Claude Code, the status bar shows token usage
# Expected: Context usage drops to 30-50% after /compact
Why This Happens
Claude Code accumulates context with every message exchange: your prompts, Claude’s responses, tool calls, tool results (file contents, command output), and internal system prompts. Reading large files, running commands with verbose output, and iterating on code changes all consume tokens rapidly. A single cat of a 5,000-line file can use 15,000+ tokens. After extended sessions with many file reads and edits, the 200K token window fills up, and Claude Code can no longer process new requests without dropping older context.
If That Doesn’t Work
- Alternative 1: Start a fresh session with a precise prompt that includes only the necessary context: files, error messages, and the exact task
- Alternative 2: Split large tasks into smaller, independent sessions — each with a narrow focus
- Check: Use
/costor check the status bar to see current token usage before starting expensive operations
Prevention
Add to your CLAUDE.md:
Use /compact proactively when context exceeds 60%. Avoid reading entire large files — use line ranges instead. Prefer focused sub-tasks over long sprawling sessions. Keep CLAUDE.md under 2K tokens to preserve context for actual work.
Related articles: Context Window Management Guide, Claude Code Slow Response Fix, Errors Atlas
See Also
- Claude API Billing Quota Exceeded — Fix (2026)
- Context Window Exceeded Mid-Conversation Fix
- Conversation History OOM Crash Fix
- Claude Code Context Compression Data Loss — Fix (2026)
- Fix Claude Code Losing Context in Sessions (2026)
Frequently Asked Questions
Does this error affect all operating systems?
This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.
Will this error come back after updating Claude Code?
Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.
Can this error cause data loss?
No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.
How do I report this error to Anthropic if the fix does not work?
Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.
Related Error Messages
This fix also applies if you see variations of this error:
- Connection or process errors with similar root causes in the same subsystem
- Timeout variants where the operation starts but does not complete
- Permission variants where access is denied to the same resource
- Configuration variants where the same setting is missing or malformed
If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.
Estimate usage → Calculate your token consumption with our Token Estimator.
Related Guides
Try it: Paste your error into our Error Diagnostic for an instant fix.