Blog
3 min read

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 install logs, git log without 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 handleWebhook function in payments.ts" beats "read the payments folder".
  • Trim command output. Ask Claude to run tests with --reporter=dot or pipe logs through tail -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.
  • /compact to summarise, /clear to start fresh, /context to 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