Show HN: Lowfat – pluggable CLI filter that saved 91.8% of my LLM tokens

Hacker News Top Tools

Summary

Lowfat is a lightweight CLI filter that reduces AI token costs by stripping unnecessary output before it reaches your agent, claiming up to 91.8% token savings. It provides shell integration, plugin support, and transparent rewriting for tools like Claude Code and OpenCode.

Hi HN,<p>Not sure if anyone would be interested.<p>But, just wanted to share that I&#x27;ve been maintaining my small tool called &#x27;lowfat&#x27; that helps me filters some of my verbose CLI output.<p>It&#x27;s a single binary, works as an agent hook or a shell wrapper. It has a plugin system to customize filters per command.<p>The idea is pretty simple: agents don&#x27;t need the full kubectl get -o yaml or any 10k-line dump to make decisions. So that lowfat sits in between, strips the noise, and passes through what matters.<p>Here&#x27;s my real report after 2 months of personal use:<p>lowfat history --all<p><pre><code> lowfat plugin candidates ───────────────────────────────────────────────────────── # command runs avg raw cost savings source status 1 kubectl get 101x 14.4K 1.5M 93.9% plugin good 2 grep 103x 13.5K 1.4M 96.2% plugin good 3 git diff 81x 995 80.6K 57.9% built-in good 4 kubectl 90x 485 43.6K 33.6% plugin good 5 docker 127x 5.5K 693.6K 96.1% built-in good 6 ls 489x 117 57.3K 56.2% built-in good 7 find 30x 16.5K 495.0K 95.5% plugin good 8 git show 63x 490 30.9K 38.0% built-in good 9 git 177x 368 65.2K 76.1% built-in good 10 git log 86x 556 47.8K 78.5% built-in good 11 kubectl logs 5x 3.6K 17.8K 43.0% plugin good 12 git status 86x 152 13.1K 58.0% built-in good 13 docker ps 20x 467 9.3K 52.8% plugin good 14 kubectl describe 6x 656 3.9K 1.2% plugin weak 15 docker images 9x 940 8.5K 61.8% built-in good 16 k get 2x 2.1K 4.2K 35.9% plugin good 17 terraform 10x 395 3.9K 32.1% plugin good 18 git commit 32x 77 2.5K 0.0% built-in weak 19 docker build 8x 487 3.9K 37.6% built-in good 20 docker compose 22x 979 21.5K 89.4% built-in good total: 4.4M raw → 4.1M saved (91.8%) </code></pre> My toolset above is kind limited, but it works pretty well for my usecase without any interruption Kinda help me not reaching the token limit for my company Bedrock limit usage and keep optimizing the saving on the go for later usage.<p>But, why not alternatives (<a href="https:&#x2F;&#x2F;github.com&#x2F;zdk&#x2F;lowfat#alternatives" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zdk&#x2F;lowfat#alternatives</a>) ? The answers are: - My goal is to make the core lightweight but extensible via plugins i.e. not trying to bundle every command in the installed binary so that people own their output filters. - Customizable per usecase via plugin or filter pipelines as I am using my own toolset. - Customizable for non-public CLI tools, for example, some enterprise might have their interal CLI tools that public won&#x27;t have access. - People should own their data. So the design is local-first, No telemetry forever. - I kinda love UNIX-style composible pipes, so lowfat-filter has implemented this style. - Be able to adjust aggressiveness of the filter, so we can control that we won&#x27;t strip something the agent needed.<p>GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;zdk&#x2F;lowfat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zdk&#x2F;lowfat</a><p>Anyway, if anyone is interested, feedbacks and questions are welcome!<p>Thanks!
Original Article
View Cached Full Text

Cached at: 06/05/26, 02:08 PM

zdk/lowfat

Source: https://github.com/zdk/lowfat

lowfat logo

lowfat is a lightweight CLI tool that reduces AI token costs by filtering unnecessary CLI output before it reaches your agent.

lowfat demo: git diff before and after

Core focus

  • Lightweight — Small single binary, small core; but extensible.
  • Local-first — No telemetry; you own your data.
  • Composable — UNIX-style pipes, mix built-ins and your own filters; not magic.
  • User-ownedlowfat history shows what you run most; allow you to customize for your usecase.

Install

cargo install lowfat
# or
brew install zdk/tools/lowfat

Pre-built binaries on GitHub Releases.

Setup

Pick one of:

Claude Code hook — add to .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "lowfat hook" }]
      }
    ]
  }
}

Shell integration — auto-activates inside agent environments (CLAUDECODE=1, CODEX_ENV), or set LOWFAT_ENABLE=1 to force it on any shell:

echo 'eval "$(lowfat shell-init zsh)"' >> ~/.zshrc   # or ~/.bashrc

OpenCode plugin — one command, no config editing:

lowfat opencode install   # writes ~/.config/opencode/plugins/lowfat.ts

Restart OpenCode; commands are rewritten transparently before they run. Remove it anytime with lowfat opencode uninstall.

Direct usage — prefix any command:

lowfat git status
lowfat docker ps
lowfat ls -la

Pi agent — in ~/.pi/agent/settings.json:

{ "shellCommandPrefix": "eval \"$(lowfat shell-init zsh)\"; " }

Usage highlights

# See what's configured and how loud each filter is being
lowfat info                       # status badge + active filters
lowfat info git                   # pipeline for `git`
lowfat info --config              # full resolved config

# See what lowfat has saved you
lowfat stats                      # lifetime token savings
lowfat stats --audit              # recent plugin executions
lowfat history                    # rank commands by potential savings

# Dial the aggressiveness
lowfat level ultra                # max compression
LOWFAT_LEVEL=lite lowfat git log  # one-off override

# Write a plugin
lowfat plugin new terraform       # scaffold ~/.lowfat/plugins/terraform/
lowfat plugin doctor              # check plugins (and pre-install any Python deps)

# Test a plugin against a sample without installing it
cat samples/git-diff-full.txt | lowfat filter --explain ./filter.lf --sub=diff --level=ultra

Learn more

  • docs/ARCHITECTURE.md — high-level diagram: CLI, Runner, Plugins, Builtins
  • docs/CONFIG.md.lowfat file, env vars, pipeline DSL, built-in processors, the history ranking
  • docs/PLUGINS.md — lf-filter (the .lf plugin DSL), shell escape hatches, PEP 723 + uv, AI agent prompt

Alternatives

License

Apache-2.0

AI notice

Multiple AI tools were used for this project

Similar Articles

Designing the hf CLI as an agent-optimized way to work with the Hub

Hugging Face Blog

Hugging Face redesigned its `hf` CLI to be optimized for both human users and AI coding agents like Claude Code and Codex, with agent-aware output rendering and benchmarking showing up to 6× token savings versus no-CLI baselines on complex tasks.

How I easily cut my input token burn ~90% on long agent runs

Reddit r/AI_Agents

The author shares a practical tip to reduce input token costs by ~90% on long agent runs using prompt caching: placing unchanged text (system prompt, tool definitions, context) at the start of every prompt to leverage cached prefixes from LLM providers.