Prevents context window bloat from large tool outputs and oversized conversation history entries.
Large tool outputs (>10kB) and oversized JSONL conversation entries cause:
- Context window exhaustion leading to session crashes (#20470)
- Inability to compact conversations properly
- Degraded performance as context fills up
- Particularly severe with agent teams (multiple agents, each accumulating context)
After tools like Bash, Read, Grep, Glob, WebFetch, and WebSearch execute, checks if the output exceeds 10kB. If so:
- Saves the full output to
.claude/tmp/large-output-{tool}-{timestamp}.txt - Injects a systemMessage warning Claude to use the file reference instead
After Write/Edit operations on .jsonl files, checks the last 5 lines for entries exceeding 10kB. Warns Claude to keep JSONL entries compact.
PostToolUse hooks cannot modify or replace built-in tool output (#18594). The large output is already in the conversation context by the time the hook fires. This plugin mitigates the problem by:
- Saving the output to a file for future reference (so Claude doesn't need to keep it in working memory)
- Warning Claude to redirect future large outputs to files proactively
True output interception would require upstream changes to Claude Code's hook architecture.
Set the size threshold via environment variable (default: 10240 bytes / 10kB):
export CONTEXT_BLOAT_THRESHOLD=10240Install via the nsheaps-claude-plugins marketplace:
context-bloat-prevention@nsheaps-claude-plugins