A JOURNAL OF ARTIFICIAL INTELLIGENCE
my ai daily

Claude Code "Prompt Is Too Long" Fix: /compact & /context

When Claude Code halts with "Prompt is too long", your request exceeded the active model context window (1M default on Opus/Sonnet 5.5, or 200K with CLAUDE_CODE_DISABLE_1M_CONTEXT=1)—not your usage quota. Here is how /context, /mcp disable, /compact, and claude update fix it.

AI-generated editorial illustration showing an overflowing stack of glowing amber translucent data slabs and nested blocks inside a smoked-glass and dark brushed-steel chamber passing through a satin brass funnel into a compact cyan capsule on the right.
AI-generated illustration / my ai dailyIllustrative image.

THE STORY IN THREE POINTS

  • Immediate fix: run /context to see whether MCP schemas, CLAUDE.md memory files, or tool output bloated the request; detach unused servers with /mcp disable <name>; and run /compact (or /clear when switching tasks) to unlock the session.
  • Context limits are not account quota: "Prompt is too long" means a single request payload exceeded the active model ceiling—1M tokens on default Claude Opus 5.5 and Sonnet 5.5 sessions, or 200K tokens when CLAUDE_CODE_DISABLE_1M_CONTEXT=1 or an older checkpoint is active.
  • Update past client compaction state bugs: run claude update to install v2.1.304 or newer (current releases run v2.1.323+), which patches stuck post-compaction errors, zero-usage reply loops, and compaction-interrupt crashes.

Immediate fix: run /context, unload MCPs, and choose /compact or /clear

If Claude Code halts mid-session with Prompt is too long or Context limit reached · /compact or /clear to continue, your request payload has exceeded the active model context ceiling—not your rolling Claude Pro or Max subscription quota. Before wiping repository context, inspect what filled the window by running /context inside the terminal, detach unused Model Context Protocol integrations with /mcp disable &lt;name&gt;, and run /compact to condense earlier turns while preserving architecture decisions.

Match the recovery command to the failure symptom rather than guessing blindly. When a session sits at 75% to 95% capacity mid-refactor, /compact preserves active file relationships and can even accept focus hints such as /compact keep the API schema changes and failing test output. When a single payload or bloated first turn locks out /compact altogether, or when you pivot to an unrelated ticket, run /clear to reset the window cleanly and prevent context rot. If your startup ceiling feels tighter than expected, verify whether CLAUDE_CODE_DISABLE_1M_CONTEXT=1 or a legacy 200K model pinned your session below the 1M default documented in our Claude Code 1M-context and v2.1.323 report.

Why "Prompt is too long" triggers on turn one or mid-debugging

Every API turn in Claude Code bundles far more than the single message you typed. As detailed in TeamoRouter’s troubleshooting breakdown and AI Arte’s error reference, each request transmits the full system prompt, complete JSON tool schemas for every active MCP server, loaded CLAUDE.md and rules files, prior conversation turns, and every file snippet or shell output captured during the loop.

Three silent token consumers routinely burn tens of thousands of tokens before your second prompt even leaves the terminal: multi-server MCP tool definitions, oversized repository CLAUDE.md handbooks, and unpaginated shell outputs such as full monorepo npm test stack traces or lockfile reads. Even on 1M-token Claude Opus 5.5 and Sonnet 5.5 sessions—and much faster inside 200K windows—a single unguarded command dump or stalled auto-compaction step can push the combined payload over the API ceiling and reject every retry until you shrink the prompt.

Audit token breakdown with /context and trim MCP overhead

Typing /context prints an itemized token breakdown across system instructions, MCP tool schemas, loaded memory files, and message history. If connected MCP servers alone consume 30,000 or more tokens on a ticket that only requires local file edits and test runs, pruning tools delivers larger immediate headroom than deleting chat messages.

Every enabled MCP server injects its complete schema into every single model call, regardless of whether you invoke it during that turn. Use /mcp disable &lt;name&gt; to detach heavy browser-automation, analytics, or design integrations during backend work, and keep definitions modular using the scoping patterns in our Claude MCP CLI and .mcp.json guide. As Developers Digest’s Claude Code error reference notes, splitting bloated root CLAUDE.md instructions into path-scoped rules also cuts baseline token load on every request.

Choosing /compact vs. /clear—and why quota limits are separate

Developers often confuse Prompt is too long with hitting their Claude Pro, Max, or Ultra usage limit, delaying the right fix. As Usagebar’s context-limit guide explains, usage limits govern cumulative token throughput over rolling five-hour and weekly windows—tracked separately in our Claude Code rolling-window limits breakdown—whereas Prompt is too long strictly rejects a single oversized request payload.

That distinction also explains why /clear and /compact should be used aggressively. Running /compact mid-feature compresses prior turns into an architectural summary so you avoid re-explaining modified interfaces, though it trades verbatim file lines for summary prose—so ask Claude Code to re-read exact files before editing subtle type errors afterward. Whenever you finish a pull request or pivot bugs, run /clear immediately: retaining dead turns degrades reasoning accuracy and spikes per-turn cached input volume, whereas clearing starts fresh without wasting extra rolling quota.

Enable auto-compact and update past v2.1.304 compaction bugs

If you ever disabled automatic summarization through /config or exported DISABLE_AUTO_COMPACT, re-enable it immediately so Claude Code compacts older turns before slamming into a hard API rejection. When manual compaction fails right on turn one with Not enough messages to compact, your root prompt, attached files, CLAUDE.md, and MCP schemas already overflowed the window on arrival; run /clear, disable unnecessary MCPs, and reference targeted line ranges instead of pasting whole files.

Client bugs can also trap sessions in repeated overflow errors even after compacting. Developers Digest documents three targeted fixes shipped through recent CLI updates: v2.1.284 resolved errors persisting immediately after compaction, v2.1.288 fixed failures when the previous reply reported zero token usage, and v2.1.304 eliminated crashes triggered when interrupting a turn mid-compaction. Run claude --version followed by claude update to move past v2.1.304 onto current v2.1.323+ builds.

Preventing context overflow in large repositories

Sustainable context hygiene in large monorepos relies on structural budgeting covered in our context engineering guide. Keep root CLAUDE.md files concise—ideally under 150 lines housing universal build, lint, and test commands—and push framework-specific guidance into directory-scoped rule files loaded on demand, following the conventions compared in our AGENTS.md vs. CLAUDE.md guide.

Two operational habits prevent sudden mid-loop overflows during long debugging sessions. First, instruct Claude Code to run narrow test invocations (such as pytest tests/auth_test.py -q) or pipe verbose logs through head/tail filters rather than flooding stdout with entire monorepo suites. Second, delegate exploratory codebase searches to subagents so dozens of read-only file scans happen inside isolated subagent windows, returning only a crisp file-and-symbol summary to your main engineering thread.

Sources: Claude Code "Prompt Is Too Long" Troubleshooting|TeamoRouter ↗ Claude Code Prompt Is Too Long Error Breakdown|AI Arte ↗ Claude Code Error Reference: Prompt Is Too Long & v2.1.304 Fixes|Developers Digest ↗ Claude Context Window Exceeded Fix (/compact vs /clear)|Usagebar ↗ Claude Code Setup & CLI Documentation|Anthropic ↗

THE BROADER CONTEXT · CLAUDE DOSSIER

Explore full product specifications, pricing analysis, and continuous coverage in the Claude Desk Hub. Independent benchmarks available on the AI Intelligence Index and Coding Agents Leaderboard.

02The next story

News

How to Install Claude Code on Windows (Native & WSL2)

Anthropic has deprecated npm install for Claude Code in favor of standalone native installers—yet native Windows lacks OS command sandboxing. Here is when to choose PowerShell vs. WSL2, exact setup commands, and fixes for PATH and Git Bash errors.

Aider vs Claude Code: Git-First CLI vs Subagent Runtime

Both Aider and Claude Code live inside the terminal—yet one treats Git commits as its core contract with any cloud or local model, while the other ships hooks, MCP, and parallel subagents tuned strictly for Anthropic’s top-ranked Claude checkpoints.

Claude vs ChatGPT: Speed, Coding, Writing & Context Limits

As US search interest in Claude surged +347% YoY, Claude 5.5/Fable 5.2 and ChatGPT (GPT-6.2 Astra/Sol) have diverged cleanly: pick ChatGPT for sub-2-second everyday speed, Intelligent UI canvases, and Space collaboration; pick Claude for 1M-token coding and prose discipline.

Follow your curiosity.

EXPLORE THE ARCHIVESOURCES & CONTEXT INCLUDED