Back to browse
GitHub Repository

Config-driven CLI tool that compresses command output before it reaches an LLM context

181 starsRust

Tokf – Stop wasting LLM context on verbose build output

by risethagain·Mar 9, 2026·1 point·0 comments

AI Analysis

●●●BangerBig BrainSolve My ProblemDark Horse

Cuts cargo test output from 61 lines to 1 — saves 60-90% of wasted LLM tokens.

Strengths
  • Three interception methods handle make, just, git hooks, and PATH-based tools
  • TOML config means filters are shareable and editable without recompiling
  • Published on crates.io and Homebrew with 113 stars and active development
Weaknesses
  • Niche audience — only matters if you're already using AI coding assistants heavily
  • Filter authoring requires understanding regex and output patterns
Target Audience

Developers using Claude Code or similar AI coding assistants

Post Description

If you use Claude Code (or similar AI coding tools), you've probably noticed that a single `cargo test` or `npm run build` can dump thousands of tokens of noise into your context window. Passing tests, repetitive warnings, full stack traces — stuff that's useful for humans scrolling through a terminal, but wasteful for an LLM that just needs to know what failed and why.

tokf is a Rust CLI that intercepts command output and compresses it using TOML-defined filters. You can strip passing tests, collapse repetitive errors, trim stack traces, etc.

The tricky part was making it work with build orchestrators. Hooking `just test` doesn't help if the noisy output comes from the `cargo test` that just runs internally. I ended up solving this three different ways depending on the tool:

- make/just: use their --shell flag to route execution through tokf - git hooks / other tools: prepend a shim directory to PATH

Wrote up the full rabbit hole: https://pecan.si/posts/getting-into-make-just-and-hooks/

Built in Rust, ~1,800 daily executions in my workflow. Filters are TOML with a Lua escape hatch. Open source: https://tokf.net

Similar Projects

AI/ML●●Solid

Entroly – Compress codebase context for LLMs by 78% using Rust

Entropy-based context compression beats naive token stuffing, but the category is crowded.

Big BrainNiche Gem
savetokens
102mo ago
AI/ML●●Solid

Contexa – Git-inspired context management for LLM agents

Git metaphor for agent memory is clever; execution and adoption remain unproven.

Big BrainWizardry
0x0003r
103mo ago
AI/ML●●Solid

Clark-agent, a Rust library for LLM tool loops

Typed, hookable agent loop in Rust when LangChain dominates Python.

Ship ItNiche Gem
stan_kirdey
1021d ago