Claude Code users are bleeding tokens on verbose shell output, and a new tool called run-tool is here to stop the hemorrhage. Developed by IB Group for their LeanCart project, this zero-dependency Node.js command runner acts as a PreToolUse hook, MCP server, and CLI to aggressively filter what enters the LLM's context window. The premise is simple: coding agents re-read their entire context on every API call, meaning a single 8,000-token lint report paid for once is actually paid for dozens of times as the session progresses.

The 27% Problem

The source material cites a stark statistic from 14 days of real agent sessions on a large TypeScript monorepo: Bash output consumed approximately 27% of all input tokens. This is pure waste for executor commands like tests, builds, and installs, where the agent primarily needs to know pass/fail status. Run-tool targets these executors specifically, leaving read operations like cat or grep untouched, on the theory that the agent's actual work requires those raw data streams, but the noise around them does not.

Deterministic Extraction, Not LLM Summarization

Unlike other context-compaction strategies that rely on an additional LLM call to summarize logs, run-tool uses deterministic error extraction. When a command fails, it returns the specific failing tests, compiler errors, and stack frames, accompanied by line references to the full log stored on disk. This avoids the cost and latency of a secondary model call and prevents the hallucination of error text. For long failures, the reduction is significant: in one test, eslint output dropped from 8,571 tokens to 361, and jest output fell from 7,075 to 1,600.

Mixed Results in A/B Testing

However, the tool's impact on total session cost is more nuanced than the raw token savings suggest. In an A/B test with real Claude Code sessions using Sonnet 5.5, the mean input tokens dropped from 468k without the hook to 384k with itβ€”a 14% reduction in Bash output characters. But the report admits the test is noisy; a control arm with a non-functional hook also showed a 12% reduction, suggesting the session-level difference might be within statistical noise. The direct effect on output size is real, but total cost savings depend heavily on how often the agent needs to re-read the hidden context.

Key Takeaways

  • Run-tool reduces token usage for executor commands (tests, builds) by up to 81% in specific failure scenarios.
  • It operates as a zero-dependency Node.js tool that integrates via PreToolUse hooks or MCP servers.
  • The tool distinguishes between 'executors' (which can be compacted) and 'reads' (which must remain raw), preserving agent accuracy.
  • A 14-day analysis showed Bash output accounted for ~27% of input tokens in a large TypeScript monorepo.
  • Successes return a single line; failures return deterministic extracts with log references, avoiding LLM-based summarization.

The Bottom Line

Run-tool is a pragmatic engineering fix for a real cost problem in agentic coding. While the total session savings may be modest for agents that already filter output, the deterministic extraction approach is a superior alternative to LLM-summarized logs, offering precision without the added latency and cost of secondary model calls.