Original Reddit post

I noticed most of Claude Code’s context bloat doesn’t come from my code — it comes from command output. git push dumps 8-15 lines of progress bars. cargo test spits out 60+ lines of compile chatter. docker build is even worse. All of it goes into the context window, most of it is noise. So I built tokf — a config-driven CLI that intercepts command output and compresses it before it reaches the model. Big hat tip to the RTK team for pioneering the idea and proving that 60-90% context reduction is achievable. tokf takes a different approach — TOML-driven filters you can check into your repo, a Lua escape hatch for complex logic, and everything stays local — but the core insight is theirs. How it works with Claude Code: tokf hook install --global That’s it. Installs a PreToolUse hook — every Bash command Claude runs gets filtered transparently. No workflow changes. What the filtering looks like: git push → ok ✓ main cargo test (61 lines) → ✓ 47 passed (2.31s) docker build (1.8 KB) → ~320 B summary Real numbers after 3,000+ runs: 985K tokens in → 98K tokens out. 90% reduction. Some things I learned from watching Claude Code use the terminal: The model runs commands differently than you — full paths ( /usr/bin/git push ), interleaved flags ( git --no-pager -C /path log ). tokf handles both with basename matching and transparent flag interception. npm test can mean Vitest, Jest, or Mocha. tokf now detects which runner you’re using and delegates to a specialized filter. The model loves piping to grep. Simple pipes ( | grep, | tail ) get stripped and replaced by tokf’s filter (with proper gain accounting). Complex chains are left alone. Sometimes the filtered summary isn’t enough. tokf can append a history hint so the model knows it can run tokf history show <id> to get the full raw output. Filters are plain TOML files — you can write your own, check them into your repo, or eject a built-in one and customize it ( tokf eject cargo/test ). There’s also a Lua escape hatch for complex logic. Written in Rust, MIT-licensed, zero cloud dependencies. Everything stays local. Site: https://tokf.net/ GitHub: https://github.com/mpecan/tokf Install: brew install mpecan/tokf/tokf Happy to answer questions or take feature requests. submitted by /u/risethagain

Originally posted by u/risethagain on r/ClaudeCode