r/ClaudeCode • • 1h ago

Built with Claude I stopped my Claude Code agent from re-reading 8,000 tokens of passing lint output

My agent kept running tests and builds, and every green run dumped hundreds of lines into the context. The whole context is re-read on every call, so I was paying for the same passing output again and again.

So I built a small hook with Claude Code. A passing command now returns one line. A failing one returns only the failing tests and stack frames, with line numbers into the full log on disk. No LLM summary, so no extra model call.

Two things I learned:

  • My first version returned a bare "0" on success. The agent got confused and re-ran installs looking for the "missing" output. One short explanatory line fixed it.
  • My A/B test (3 runs per arm) was too noisy to prove a gain per session, so I only claim what I measured directly: Bash output -14%, and -81% on long failures. Agents that already pipe through tail gain less.

Free, MIT, zero dependencies. It also runs as an MCP server and a CLI. https://github.com/ibrahim-bayer/claude-code-token-optimization-by-tool-call

Which commands would you never want hidden from your agent?

1 Upvotes

1 comment sorted by

•

u/AutoModerator 1h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.