[FEATURE] Context flood protection

Resolved 💬 5 comments Opened Nov 25, 2025 by danielrosehill Closed Jan 27, 2026

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 using Claude Code for system diagnostics, sometimes Claude will decide to read an exceptionally long file, for example, a JSON with hundreds of thousands of rows or the entire journal log in a file system.

I am always surprised to see that sometimes the CLI doesn't appear to have any "defense mechanism" so to speak against the immediate flood of context data which will immediately overwhelm the context window and crash the CLI.

Proposed Solution

I'm not sure how this could be architected (I leave this to the experts!).

But it would seem super useful if the CLI could have some kind of mechanism that goes something like:

  • This (text) exceeds what I can tokenise
  • I will stop attempting to process it any further
  • I will inform the user of this and then try a workaround (in the case of JSON this might be something like: let's read the first X rows to infer structure; let's script a data extraction that will extract the desired info to under the context window or - far reach solution - let's vectorise this on the fly for non-direct in-repo retrieval)

Alternative Solutions

Thanks @JuanCS-Dev for the clever hook idea!

Priority

High - Significant impact on productivity

Feature Category

API and model interactions

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗