by samuelfaj
Distill large CLI outputs into small answers for LLMs and save tokens!
# Add to your Claude Code skills
git clone https://github.com/samuelfaj/distillAgent command outputs are one of the biggest sources of token waste.
Logs, test results, stack traces… thousands of tokens sent to an LLM just to answer a simple question.
🔥 distill compresses command outputs into only what the LLM actually needs.
Save up to 99% of tokens without losing the signal.
ollama pull qwen3.5:2b
npm i -g @samuelfaj/distill
Add in your global agent instructions file:
CRITICAL: Always when you invoke a any shell command pipe it through `distill` and tell exactly what you want to know.
`distill` will summarize the response to save tokens, which is critical for us.
Examples:
- `bun test 2>&1 | distill "did the tests pass?"`
- `git diff 2>&1 | distill "what changed?"`
- `terraform plan 2>&1 | distill "is this safe?"`
- `npm audit 2>&1 | distill "extract vulnerabilities as JSON"`
THERE ARE ONLY TWO SCENARIOS WHEN YOU ARE ALLOWED TO NOT USE `distill`:
- Do not use `distill` if exact uncompressed output is required.
- Do not use `distill` if it would break an interactive/TUI workflow.
logs | distill "summarize errors"
git diff | distill "what changed?"
terraform plan 2>&1 | distill "is this safe?"
You can persist defaults locally:
distill config model "qwen3.5:2b"
distill config timeout-ms 90000
distill config thinking false
For pipeline exit mirroring, use pipefail in your shell:
set -o pipefail
Interactive prompts are passed through when distill detects simple prompt patterns like or .
No comments yet. Be the first to share your thoughts!
[y/N]password:If you want Codex, Claude Code, or OpenCode to prefer distill whenever they run a command whose output will be sent to a paid LLM, add a global instruction telling the agent to pipe command output through distill.
~/.codex/AGENTS.md.~/.claude/settings.json, and its official mechanism for custom behavior is global instructions via CLAUDE.md.~/.config/opencode/opencode.json. Point its instructions field at a markdown file with the same rule.rg -n "terminal|PERMISSION|permission|Permissions|Plan|full access|default" desktop --glob '!**/node_modules/**' | distill "find where terminal and permission UI are implemented in chat screen"
🔥 Saved ~98.7% tokens