What Happens When Claude Runs Out of Tokens? (2026)
You are coding in Claude Code. The chat has been long. Files are piling up. Then Claude stops responding. "Context limit exceeded." Panic. But what exactly happened? Did Claude delete your work? Did it error? What is /clear and when do you use it? This guide explains the exact behavior, and how Token Limits prevents you from ever hitting it.
What Claude does when context fills
Claude does not crash. Claude does not error. Claude stops accepting new messages. Here is the exact sequence:
- You send a message or tool call result
- Claude checks: "Does this fit in my 1M token window plus my safety margin?"
- If no: Claude rejects the message with "Context limit exceeded" or "Content too long"
- Your message was not sent. Claude did not process it.
- You can still read old messages. You can export your chat. Your work is safe.
What context limit exceeded really means
It means: "The next message you are trying to send, plus the entire conversation history so far, plus my system instructions and safety tokens, exceed 1M tokens total."
Claude has a safety margin built in (about 50k tokens reserved). So your effective limit is closer to 950k. After that, new messages are rejected.
Claude Code vs Claude.ai: Different behavior
Claude Code handles context limits differently than Claude.ai web chat:
- ✓Claude Code: Rejects new messages with "context limit exceeded"; your editor still works; you can /clear
- ✓Claude.ai: May auto-summarize old messages or silently truncate; behavior varies
The /clear command: When and how to use it
/clear is a Claude Code command that compresses your entire chat history. It removes redundancy, summarizes long threads, and condenses repeated content. Think of it as running Token Limits on your chat history.
- In Claude Code chat, type: /clear
- Claude processes your entire history and compresses it
- Result: Your chat history shrinks 40-50%, freeing up tokens
- You can now send new messages again
When to use /clear
- ✓You hit "context limit exceeded": /clear immediately
- ✓You see you are at 80%+ of context (if display shown): /clear proactively
- ✓Before starting a new big task: /clear to free space
- ✓You do not need to clear between small conversations: context is usually fine
What /clear loses (and what it keeps)
After /clear, your chat history is compressed. Details are lost but context is preserved:
- ✓Loses: Exact wording of old messages, verbose explanations, repeated details
- ✓Keeps: Core facts, decisions made, code written, files edited, key results
You can still scroll and read old messages, but Claude's internal model of the conversation is compressed.
Better solution: Install Token Limits proxy
Instead of waiting to hit limits and using /clear, install Token Limits proxy. It compresses tool outputs 60-80% before they enter your context. You almost never hit limits.
- npm install -g token-limits
- token-limits start
- Claude Code: Tools → API URL → http://localhost:4800
- All future tool calls (grep, file reads, etc.) are compressed
With Token Limits, a session that would normally hit limits at 800k tokens now gets to 1M+ tokens freely because tool outputs are 60-80% smaller.
Stop hitting context limits: Install Token Limits
Automatic 60-80% compression on every tool call. Keep working instead of using /clear. Setup takes 2 minutes.
FAQ
If Claude hits context limit, is my code saved?
Yes. Code is saved in your editor. Claude just stopped accepting new messages. You can export the chat, copy your code, and start a new session.
Does /clear delete my chat history?
No. Your history is still there and readable. /clear compresses Claude's internal model of it, freeing tokens for new messages.
What is the 5-hour rolling window I keep hearing about?
Claude has a 5-hour usage window (separate from context limits). If you use 2M tokens in an hour, you hit the 5-hour limit even if context is not full. Token Limits reduces both context usage and 5-hour window usage.
Can I increase my context limit?
No. 1M is the hard limit for Claude Sonnet 4. You can only make more efficient use of it with Token Limits.
Is context limit the same as the rolling window limit?
No. Context limit is per-session (1M tokens max in one chat). Rolling window limit is per-5-hours (2M tokens max across all sessions). Token Limits helps with both.