Claude Code "Prompt Is Too Long": Why It Happens and How to Fix It
"Prompt is too long" and "Context limit reached" mean the conversation no longer fits in the model's context window. What fills it up, how to see what's using space with /context, and the fixes: /compact, /clear, smaller reads, fewer MCP tools and better session habits.
Claude Code shows one of these:
Prompt is too long
Context limit reached · /compact or /clear to continue
Prompt is too long · automatic compaction failed
They all mean the same thing: everything Claude needs to read for the next turn no longer fits in the model's context window. The context window is the model's working memory, and every message, file it read, command output and tool definition takes up space in it. (What Is a Context Window?)
The quick fixes
1. Compact the conversation.
/compact
This replaces the history with a summary and frees most of the space. You can steer what to keep:
/compact keep the database schema decisions and the list of failing tests
2. Or start fresh.
/clear
Use this when you're moving to a different task. A new task rarely needs the old one's history. (/compact vs /clear)
See what's taking up space
/context
This shows how much of the window each part uses: system prompt, tool definitions, memory files, and the messages themselves. Common culprits:
- Huge files read whole. A 10,000-line log or a minified bundle can fill a window by itself.
- Long command output. Test runs with verbose output,
npm installlogs,git logwithout limits. - Lots of MCP servers. Every connected server's tool descriptions take space. (Connecting MCP Servers)
- Big images and screenshots. Several full-resolution screenshots add up.
- A long CLAUDE.md that loads on every turn. (How to Write a CLAUDE.md)
Prevent it next time
- One task per session. Finish, commit,
/clear, start the next thing. - Ask for targeted reads. "Look at the
handleWebhookfunction inpayments.ts" beats "read the payments folder". - Trim command output. Ask Claude to run tests with
--reporter=dotor pipe logs throughtail -n 50. - Disable MCP servers you aren't using in this project.
- Use subagents for exploration. A subagent can read twenty files in its own context and report back a summary, keeping your main conversation small.
"Automatic compaction failed"
Claude Code compacts automatically as you approach the limit. If even that fails, the single thing left in context is usually too big — often one enormous tool result. Run /clear, then redo the step that produced the large output in a smaller way (read part of the file, filter the log).
Does a bigger context window help?
Current models — Opus 5.5, Sonnet 5.5 and Haiku 5.5 — have a 1M-token window by default in Claude Code, which makes the error rarer. But a fuller window is also slower, costs more usage per turn, and can make the model less focused. Keeping context lean is good practice even when you have room.
The summary
- The conversation outgrew the context window.
/compactto summarise,/clearto start fresh,/contextto see what's using space.- Prevent it with one task per session, targeted reads, trimmed output and fewer idle MCP servers.
EasySpawn keeps your Claude Code sessions on a persistent server, so /clear costs you nothing — the files, branches and database state from the last task are all still there. See how it works or join the waitlist.
Related: Why Your AI Agent Keeps Forgetting · Context Engineering for Coding Agents · Claude Code Troubleshooting · Using Claude Code on a Large Codebase
Keep reading
Claude Code "529 Overloaded" Error: What It Means and What to Do
"API Error: Repeated 529 Overloaded errors" means Anthropic's API is at capacity for the model you're using — not that you did anything wrong or used up your plan. What a 529 is, how it differs from a 429, and the fixes: wait, switch model, and the retry settings for unattended runs.
Playwright MCP: Let Claude Code Use a Real Browser
The Playwright MCP server lets AI tools open pages, click, type and read a live browser through accessibility snapshots instead of screenshots. How to add it to Claude Code, useful prompts for testing and debugging, key options like headless and isolated, and its limits.