How to fix “Prompt is too long” in Claude Code
Fix Claude Code's “Prompt is too long” error: separate the current request from saved conversation context, then compact or start a clean session safely.
“Prompt is too long” means the request Claude Code built is bigger than the model's input limit. If one paste or file caused it, press Esc twice or run /rewind to go back before it. If long history caused it, run /compact. If even the first exchange is too big, cut attachments, tools, or CLAUDE.md.
What the message means
This is an input-size failure, not a usage limit. Every request carries the system prompt, your CLAUDE.md files, the definitions of every connected tool and MCP server, any images or files you attached, and the conversation so far. Any one of them can push the total past the model's limit: a huge paste can break a short session, and a short message can break a session whose history is already full. Run /context to see which part is taking the space.
Which version of the message you see
| Message | What it tells you | What to do |
|---|---|---|
| prompt is too long: N tokens > L maximum | The raw API error. N is what Claude Code tried to send and L is the model's limit, so N minus L is how much has to go. | Remove at least that much: rewind past the paste that caused it, or compact the history. |
| Prompt is too long · the request is ~N tokens (limit L) and this conversation's own content is most of it. | The first message of a fresh conversation is already too big, almost all of it text or files you supplied. A single exchange cannot be compacted. | Press Esc twice to edit the message, then send smaller files or point Claude at file paths instead of pasting them. |
| but this conversation is only ~S tokens — the rest is system prompt, tool definitions, and attachment content. | Your message is small; the fixed overhead around it is what overflows. | Disable MCP servers you are not using with /mcp disable, trim a very large CLAUDE.md, and drop attachments. |
| Prompt is too long · this conversation is a single exchange and cannot be compacted | The same overhead problem, reported when Claude Code could not read the token counts. | Same fixes as above: fewer tools, a smaller CLAUDE.md, fewer attachments. |
| Prompt is too long · automatic compaction failed: | Claude Code tried to summarize the conversation to make room, and that summary request failed too. The text after the colon is the cause. | Press Esc twice to go up a few messages, then run /compact. Update Claude Code if you are on an older version. |
| Accumulated images and attachments in the conversation pushed the request over the limit. | Screenshots, PDFs, and other attachments, not text, filled the context. | Run /compact, or press Esc twice to go back and remove the attachments. |
| Input is too long for requested model | The same limit in another provider's wording, for example when Claude Code runs through Amazon Bedrock. | Treat it exactly like “Prompt is too long”. |
Fix it in this order
1. See what is filling the context
Run /context in the affected session. It draws the current context as a grid, split into system prompt, tools, memory files, and messages, so you know whether to cut your own message, the history, or the overhead before you change anything.
/context2. Go back before the oversized message
If the error appeared right after you pasted a log, a lockfile, a minified bundle, or a large screenshot, press Esc twice or run /rewind and pick the point before it. The conversation returns to its last good state, and you can resend a shorter version or ask Claude to read the file from disk.
/rewind3. Compact a long-running conversation
When accumulated history is the problem, /compact replaces it with a summary. Tell it what must survive, so the summary keeps the details you still need. Compaction cannot rescue a single exchange that is already too big.
/compact keep the failing test, the files changed, and the next step4. Shrink the overhead around every request
If the diagnostic says the conversation itself is small, the space is going to tool definitions, attachments, or memory files. Disable MCP servers this task does not need, move rarely used detail out of a very large CLAUDE.md, and remove attachments you no longer need.
/mcp disable <server>5. Update Claude Code
Two releases fixed versions of this error that came back right after compaction: 2.1.310, for conversations dense with base64 or SVG, and 2.1.317, for sessions whose very large CLAUDE.md had changed. If the error repeats after every compact, update first.
claude update6. Carry only durable state into a fresh session
If nothing above recovers enough room, write down the goal, changed files, commands already run, current failure, and next step. Then run /clear, which starts an empty session and keeps the old one on disk where /resume can still open it, and hand the new session that note instead of the transcript.
/clearImportant distinctions
- Deleting files from the repository does not shrink text that is already recorded in the conversation.
- Changing plans or waiting for a usage reset does not solve an oversized request.
- If Auto-compact is turned off in /config, Claude Code will not summarize the history on its own, so a long session runs into the limit instead of compacting.
- Keep the old session until the new one is oriented; it remains useful as an audit trail even if you stop adding turns to it.
Questions
Does /compact fix “Prompt is too long”?
Only when the conversation history is what overflows. A single exchange cannot be compacted, so if the first message, your attachments, or the tool definitions are too big on their own, /compact cannot help. Rewind and send less instead.
Why do I still get “Prompt is too long” right after compacting?
Either the overhead that compaction does not touch (system prompt, CLAUDE.md, tools, attachments) is too big, or you are on a version with a known bug. Claude Code 2.1.310 and 2.1.317 fixed two such cases, so run claude update, then check /context.
Is “Prompt is too long” a usage limit?
No. It is about the size of one request, not how much you have used. Upgrading your plan or waiting for a reset does not change it; making the request smaller does.
How do I see what is filling Claude Code's context?
Run /context. It shows the current context usage as a colored grid, broken down by system prompt, tools, memory files, and messages.
Will /clear delete my conversation?
No. /clear starts a new session with an empty context; the previous session stays on disk, and /resume can reopen it.
Where Crowsnest fits
Crowsnest can search the local transcript and reopen the exact Claude Code session, which is useful when you need to recover decisions before writing a smaller handoff. It does not enlarge Claude's context window or bypass the input limit.
Source and version
The exact text and flags on this page were checked against the installed Claude Code 2.1.322 binary on November 19, 2026. Version-specific behavior can change, so compare your own --help output before scripting around it. Official status or documentation →
Reviewed from first-party CLI output and the released Crowsnest product source. No command on this page bypasses provider limits, billing, authentication, or native history rules.