Add configurable output limit for ! shell commands
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 running shell commands via ! in a conversation, the full output is consumed as tokens in the context window. If a command accidentally produces large output (e.g., verbose build logs, large data dumps), it wastes context and can push out useful conversation history.
Proposed Solution
A configurable setting (e.g., in settings.json or .claude/settings.json) to cap the number of lines or bytes included from ! command output:
{
"shell_output_max_lines": 200,
"shell_output_max_bytes": 10000
}
When output exceeds the limit, it would be truncated with a message like:
[Output truncated: 1,432 lines total, showing first 200. Full output saved to /tmp/claude-cmd-output-<hash>.log]
This way the full output is still accessible (via Read on the temp file) without bloating the conversation context.
Alternative Solutions
Current workarounds:
- Piping through head/tail (requires anticipating large output)
- Redirecting to a file and reading selectively
These work but require users to predict which commands will be noisy.
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
- Running a test suite where a single failure produces a long stack trace or diff, flooding the context with output you didn't need
- Accidentally running a command without filters (e.g., !mix deps.tree or !git log) that dumps hundreds of lines
- Build commands where the user doesn't anticipate them to emit verbose compilation or bundling output where only the final status or errors matter
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗