# Lowfat--一款可插拔的CLI过滤器，帮我节省了91.8%的LLM token

- 来源：Hacker News 热门（buzzing.cc 中文翻译）
- 作者：zdkaster
- 发布时间：2026-06-06 07:07
- AIHOT 分数：66
- AIHOT 链接：https://aihot.virxact.com/items/cmq1jto3r0ggtsltr3dpken2n
- 原文链接：https://github.com/zdk/lowfat

## AI 摘要

Lowfat是一款可插拔的命令行界面（CLI）过滤器，可在LLM使用场景中节省约91.8%的模型token消耗。项目已开源并托管在GitHub上。

## 正文

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

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-owned — lowfat history shows what you run most; allow you to customize for your usecase.

lowfat history

Before / after

git status at the full level — same signal, less noise.

git status

full

Before — raw git status:

git status

On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: crates/lowfat-cli/src/commands/plugin.rs modified: crates/lowfat-cli/src/main.rs Untracked files: (use "git add ..." to include in what will be committed) plugins/git/git-compact/samples/ no changes added to commit (use "git add" and/or "git commit -a")

On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: crates/lowfat-cli/src/commands/plugin.rs modified: crates/lowfat-cli/src/main.rs Untracked files: (use "git add ..." to include in what will be committed) plugins/git/git-compact/samples/ no changes added to commit (use "git add" and/or "git commit -a")

After — lowfat git status:

lowfat git status

On branch main Changes not staged for commit: modified: crates/lowfat-cli/src/commands/plugin.rs modified: crates/lowfat-cli/src/main.rs Untracked files: plugins/git/git-compact/samples/

On branch main Changes not staged for commit: modified: crates/lowfat-cli/src/commands/plugin.rs modified: crates/lowfat-cli/src/main.rs Untracked files: plugins/git/git-compact/samples/

Reduction of raw command output, measured on the bundled samples (crates/lowfat-plugin/embedded/*/samples/). Reproduce with cat | lowfat filter /filter.lf --sub= --level=:

crates/lowfat-plugin/embedded/*/samples/

cat | lowfat filter /filter.lf --sub= --level=

command lite full ultra git diff -16% -38% -96% git log -53% -80% -91% git status -62% -62% -74% docker ps -38% -38% -85% docker images -48% -58% -86% ls -la -2% -75% -87%

lite

full

ultra

git diff

git log

git status

docker ps

docker images

ls -la

These percentages are the reduction of a single command's output, not your end-to-end agent token usage. savings depend on how much of your context is command output and how lossy a level you pick — higher levels drop more, so verify your agent still has what it needs. treat the table as a ceiling on the output slice, not a promise on the total.

These percentages are the reduction of a single command's output, not your end-to-end agent token usage. savings depend on how much of your context is command output and how lossy a level you pick — higher levels drop more, so verify your agent still has what it needs. treat the table as a ceiling on the output slice, not a promise on the total.

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:

.claude/settings.json

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

The filtering pattern Anthropic recommends, but via lowfat.

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

CLAUDECODE=1

CODEX_ENV

LOWFAT_ENABLE=1

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. Uninstall with lowfat opencode uninstall.

lowfat opencode uninstall

Direct usage — prefix any command:

lowfat git status lowfat docker ps lowfat ls -la

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

~/.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

.lowfat

history

docs/PLUGINS.md — lf-filter (the .lf plugin DSL), shell escape hatches, PEP 723 + uv, AI agent prompt

.lf

Alternatives

rtk

context-mode

lean-ctx

tokf

tamp

ecotokens

token-enhancer

vs rtk

rtk is the closest tool but differ in philosophy: rtk is batteries-included; lowfat is a minimal core you extend yourself.

lowfat rtk Built-in commands 6 curated (git, docker, grep, find, ls, tree) 100+ across many ecosystems Custom filters .lf DSL + shell + Python (PEP 723/uv) TOML DSL Levels lite / full / ultra -l aggressive, --ultra-compact File-content filtering grep / find plugins rtk read / smart (signatures, summaries) Agent integrations Claude Code, OpenCode, shell, Pi 14 tools (Claude Code, Copilot, Gemini, Codex, …) Telemetry None — local-only Opt-in, off by default (anonymous aggregate) Savings analytics lowfat stats / history (local) rtk gain / discover (local)

git

docker

grep

find

ls

tree

.lf

lite

full

ultra

-l aggressive

--ultra-compact

grep

find

rtk read

smart

lowfat stats

history

rtk gain

discover

Token savings, head-to-head

Same commands, same repo, same cwd, run through both tools. Output tokens counted with tiktoken (cl100k_base); savings are vs the raw command output:

cwd

tiktoken

cl100k_base

command raw tokens lowfat full lowfat ultra rtk git status 81 -91% -91% -79% git diff 1241 -15% -97% -9% git log 3350 -93% -97% -56% ls -la 153 -77% -89% -86% find 535 -0% -58% -66%

full

ultra

git status

git diff

git log

ls -la

find

Honest read: lowfat compresses git harder; rtk edges out find; ls is close. find only engages at lowfat's ultra level. rtk's --ultra-compact gave near-identical numbers to its default here, so the default is shown. This is a single small run on one repo — directional, not a benchmark; measure on your own workload before trusting any of it.

find

ls

find

ultra

--ultra-compact

License

Apache-2.0

AI notice

Multiple AI tools were used for this project

Star History
