[FEATURE] Claude Code CLI: Suggest writing large text to a file instead of pasting in prompt for token efficiency
Summary
When users paste large blocks of text (logs, diffs, curl output, code snippets, etc.) directly into the Claude Code CLI prompt, Claude should suggest — or proactively offer — writing that content to a temporary file and referencing it instead.
Motivation
This is specific to the Claude Code CLI where users type or paste content directly into the terminal prompt. Pasting large text inline is token-inefficient for two reasons:
- Context window consumption: Pasted content occupies context tokens for the entire conversation, not just the turn it was introduced. Every subsequent message carries that cost.
- Redundant loading: Claude reads the full pasted content even when only a targeted portion is needed. With a file, Claude can use range reads (
offset/limit) to fetch only the relevant section.
By contrast, when content lives in a file:
- Claude can read only the lines it needs
- The raw text does not sit in the conversation context burning tokens across turns
- Large inputs (logs, API responses, curl payloads) can be analyzed without bloating the session
Proposed Behavior
In the Claude Code CLI, when a user pastes a large block of text (above some threshold, e.g. 500 tokens), Claude Code could:
- Suggest: "Consider writing this to a file — I can analyze it more efficiently by reading only the relevant sections"
- Or automatically write it to a temp file and reference it, letting the user know
- Alternatively, expose a CLI affordance (e.g.
! cat output.logpiped input) that writes content to a temp file before submission
Example
A user pasting 4 curl commands with large cookie headers and JSON payloads into the CLI prompt to ask "what changed across these calls" — the payload is ~3KB of repeated headers that sit in context for the rest of the session, even though Claude only needed to diff the --data-raw fields.
Writing to a file and asking Claude to analyze it would have been significantly more efficient.
Impact
- Reduces token consumption per CLI session
- Keeps context window available for actual conversation
- Improves cost efficiency for users on metered plans
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗