Context window limit warning: warn users before "Prompt is too long" error mid-task
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When a conversation session runs long (e.g. during multi-step Xero reconciliation, browser automation, or any heavy tool-use workflow), Claude Code hits the context window limit and abruptly fails with a "Prompt is too long" error — with zero warning.
This is deeply disruptive because:
- The error fires mid-task, cutting off work without any chance to save state or wrap up gracefully.
- There is no indication that the limit is approaching — no progress bar, no percentage, no message.
- The user loses all in-progress work and has no way to know how much context they have left before starting a task.
This is a critical UX flaw for users who rely on Claude Code for long agentic workflows. The session simply dies without warning.
Proposed Solution
Add a context usage indicator and proactive warning system:
- Context usage indicator — Show a persistent, visible indicator (e.g. in the status bar or UI) showing approximate context usage as a percentage or progress bar. Similar to how token usage is shown in the API.
- Early warning at ~75% — Display a clear warning: "You are approaching the context limit. Consider using /compact or starting a new session soon."
- Graceful degradation at ~90% — Prompt the user to either: (a) start a new session, or (b) use /compact to compress history. Do not allow the session to silently die.
- Never fail mid-tool-call — If the limit is genuinely about to be hit, pause before the next tool call and warn the user, rather than failing partway through an action.
Alternative Solutions
Currently the only workaround is to manually use /compact mid-session — but this requires the user to proactively know they are approaching the limit, which is impossible without a usage indicator. Starting new sessions frequently is disruptive to long workflows.
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
User is running a Xero reconciliation session in Claude Code (VSCode extension). The workflow involves repeated browser automation tool calls — reading invoices, filling form fields, uploading PDFs, verifying saves. After ~40-60 tool calls the session fails mid-reconciliation with "Prompt is too long". The user has no warning, loses their place in the workflow, and must start a new session from scratch with no way to resume where they left off.
With a context usage indicator, the user could see at 75% that they're running low, use /compact to compress history, and continue the same session without interruption.
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗