trs : Token-Reducing Shell, terminal compression for AI agents
Install
Pick whatever fits your stack. All four methods ship the same native binary. The install script is fastest.
curl -fsSL https://usetrs.dev/install.sh | sh
Downloads the right binary for your platform into
~/.trs/bin/trs. Zero runtime dependencies,
no Node overhead, ~4 ms startup. Pin a version with
TRS_VERSION=v0.10.6.
irm https://usetrs.dev/install.ps1 | iex
PowerShell installer. Drops the binary into
%USERPROFILE%\.trs\bin\trs.exe
and prints PATH instructions if needed.
npm install -g @dpeluche/trs
Uses optionalDependencies, so npm only
downloads the binary for your platform. A shell launcher execs the
binary directly (no Node at runtime).
Download from github.com/dPeluChe/trs/releases
Prebuilt binaries for Linux x64/arm64, macOS x64/arm64, and Windows x64.
Drop into your $PATH, chmod +x, done.
What it does
Prefix any command with trs (or let
trs init wire it into your AI tool for you).
The binary spawns your command, parses the output, and emits a
compact version built for both humans and LLMs.
The command runs unchanged; trs only reshapes its output. When it cuts something, it says where the full output is saved.
Supported AI agents
trs init --all --global wires every detected agent in one shot: eighteen agents through three install mechanisms. Grok Build and Kiro get the output-saver only.
| Agent | Install method | Input hook | Output-saver | Attribution |
|---|---|---|---|---|
| Claude Code · Gemini · Cursor | programmatic hook | ✓ | ✓ | claude / gemini / cursor |
| OpenCode · Kilo Code | plugin template | ✓ | ✓ | opencode / kilo |
| Pi Coding Agent | programmatic hook (extension) | ✓ | — | pi |
| Factory Droid | programmatic hook | ✓ | ✓ | droid |
Antigravity IDE · Antigravity CLI (agy) | rules file (why) | — | ✓ | antigravity (env fallback) |
| Codex CLI | programmatic hook (codex-cli ≥ 0.134) · rules fallback | ✓ | ✓ | codex (fallback (untagged)) |
| Devin Desktop (ex-Windsurf) | rules file only | — | ✓ | (untagged) |
| Devin CLI | programmatic hook | ✓ | — | devin-cli |
| VS Code Copilot / Copilot CLI | programmatic hook | ✓ | ✓ | vscode / copilot-cli |
| OpenClaw · Hermes | plugin template | ✓ | — | openclaw / hermes |
| Trae · Mistral Vibe | programmatic hook (unverified) | ✓ | — | trae / vibe |
| Grok Build · Kiro | output-saver only | — | ✓ | — |
| Zed (Agent Panel) | rules file only (AGENTS.md) | — | — | (untagged); ACP external agents show their own label |
Full matrix + caveats + per-agent config paths: docs/support/agents.md.
Supported commands
Thirty-plus dedicated parsers. Anything else falls to generic compression (which saves little on its own, 2–16% measured) and still tracks in stats.
- VCS
git: status, diff, log, branch, push, pull, fetch, show, stash.- Rust
cargo: build, check, test, clippy, fmt, install.- JavaScript / TypeScript
npm,pnpm,yarn,bun,npx,pnpm dlx: install, test, ls, audit, run.- Python
pytest,pip,uv, pluspython3 -m <mod>routing for pytest / mypy / ruff / pylint / flake8.- Go
go: test, build, mod.- Java
mvn,gradle: failed tests with their message, compile errors once, modules and tasks counted.- Cloud & databases
aws(recursives3, JSON bodies),psql,mysql,sqlite3result grids.- Test runners
pytest,jest,vitest: full parse of suite summary, failures, tracebacks.- Linters
eslint,biome,ruff,pylint,golangci-lint,cargo clippy,tsc: issues grouped by file + rule.- Files & search
ls(+eza,lsd,exa),find(+fd),grep(+rg,ag,ack),tree,tail. Pluscat,head,sed -n X,Ypintercepted with comment stripping.- Containers & GitHub
docker(ps, logs, build) andgh(pr list, pr view, issue list, run list +gh api).- System & network
ps,du,lsof,pgrep,ping,env,wc,brew,curl,wget.- Chain-aware
cd X && cargo testwraps each rewritable segment. Pipes and semicolons pass through untouched.- Env-prefix preservation
RUSTFLAGS=x cargo buildkeeps the leading assignment, so it still reaches cargo after the rewrite.
Full command reference with subcommands and examples: docs/support/commands.md.
Why we built trs
Short origin note, for the curious. Click to expand.
Read the backstory →
Token pricing kept climbing. AI coding sessions were burning tens
of thousands of tokens just rendering
git status, cargo test,
and ls -la into the agent's context,
and the signal-to-noise ratio was painfully low. We started writing
small tools, first for ourselves and then for the team,
to reduce what the agent actually had to read.
Along the way we came across rtk (Rust Token Killer). By then our tools had been evolving on their own, so we faced the honest choice: migrate to rtk and drop what we'd built, or continue and publish our own take. We chose to continue, and trs kept iterating and expanding as we learned more about where tokens actually burn.
Input hooks turned out to be only part of the job.
trs output-saver
installs rules into each agent's global config so replies come
back shorter. trs audit-docs inspects
CLAUDE.md / AGENTS.md for the bloat that loads on every session.
trs ingest compresses whole projects
into an LLM-ready context index. Still a single static binary,
zero runtime deps.
Before / with trs
Raw output vs what trs emits, from real runs; token counts estimated as
bytes / 4. The measured numbers are in the
table below. Click any row to see the before/after.
Sample outputs are real runs (clippy on a six-file demo crate with 156 warnings, the others on this repo); your repo and commands will vary. Want to reproduce or compare with other tools? See the internal calibration lab in docs/development/benchmarks/.
Project digest · trs ingest
Turns any codebase into an LLM-ready markdown digest: structure, key files, dependency graph, and compressed signatures.
--list.Read on demand.--ollama <model> runs the digest through a local LLM for an executive summary.Compression reference
The 60% is a ceiling from real use: 58% over 84,325 commands since April,
24% to 48% in recent windows. It counts the output trs handles, not your
whole bill, and it varies with what you run. The table
is a fixed benchmark of 38 command shapes taken
from real agent sessions (trs v0.10.0, tokens counted with
o200k_base).
“Anchors kept” is the share of
paths, file:line refs, hashes and error lines
from the raw output that survive. Some rows cut little on purpose.
Methodology and how to reproduce →
| Command | Raw tokens | trs tokens | Cut | Anchors kept | What stays |
|---|---|---|---|---|---|
git log -20 | 5,390 | 1,363 | 75% | 63% | subject, why, squash index; rest via git show |
git diff HEAD~5 | 12,687 | 7,928 | 38% | 54% | hunks from every file, code first; cuts are marked and the full diff saved |
find src -name '*.rs' | 2,195 | 338 | 85% | 44% | grouped by directory; full list saved |
ls -la src | 3,001 | 1,051 | 65% | 100% | |
cargo test (2 failing) | 829 | 197 | 76% | 56% | each failure: location, message, left/right |
pytest (2 failing) | 372 | 122 | 67% | 58% | names, E lines, file.py:N |
bun test (2 failing) | 548 | 249 | 55% | 70% | expected vs received, location |
gh run list | 450 | 298 | 34% | 0% | run id, title, workflow, branch, duration |
grep -rn -C2 | 1,945 | 1,508 | 22% | 100% | every match and every context line |
gh pr view | 922 | 881 | 4% | 100% | the whole PR body |
ps aux | 123,367 | 886 | 99% | 0% | top processes; full list saved, path printed |
git show rev:file | 1,692 | 1,692 | 0% | 100% | verbatim: it is a file |
Output saver · trs output-saver
trs rewrite compresses what agents
see. trs output-saver closes
the other side of the loop by installing a compact rules block
for what agents emit: answer concisely, never invent paths or
API fields, keep code comments short. It is small on purpose: in
pre-registered tests no longer block beat one line.
## Output saver: keep replies cheap Answer concisely. Never invent file paths, function names, or API fields. If unknown, say "UNKNOWN" or return null. ## Code authoring These apply when you write code, not just when you reply in chat. - Comments: none by default. If one is truly needed, write a terse WHY-only note (not a walkthrough), at most 3 lines, ~200 characters. Never paragraph docstrings or restate the code. A longer logic explanation goes to docs/ with a one-line pointer in the comment. - BAD: 8 lines narrating the algorithm step by step. - GOOD: `// OCC retry: Convex aborts concurrent writes; 3 attempts fit real load` User instructions always override these rules.
trs output-saver --print shows it.- 14 agents
- Claude Code, Gemini, Cursor, OpenCode, Kilo, Droid, Codex, VS Code Copilot / Copilot CLI, Devin Desktop, Antigravity IDE and CLI, Grok Build, Kiro and OpenClaw. Not wired yet: Pi, Devin CLI, Hermes, Trae, Mistral Vibe and Zed.
- Check-first by default
- A dry-run scan shows exactly what would change.
--installwrites it;trs uninstall --output-saverremoves it from every agent. - Idempotent merge
- The block sits between sentinels. Re-running
--installupdates it in place; your other rules stay untouched.
Full reference: docs/features/output-saver.md.
More features
$ trs stats # totals, saved per day, top commands $ trs stats --by-agent # the same, split by agent $ trs stats --by-command # grouped by command family $ trs stats --json # for your own dashboard
trs audit-docs inspects CLAUDE.md / AGENTS.md / rules files for cross-file duplicates, embedded code/SQL/JSON blocks, dead @imports, and code fences whose symbols already live in src/. Paired with trs doctor warnings when agent docs exceed their token budget.trs uninstall walks every surface trs init wrote: JSON hooks (preserves user-added entries), plugin files, Codex sentinel blocks, output-saver sidecars. Interactive by default, or <tool> / --all / --output-saver / --dry-run for scripts.- 6 output formats
- Compact, JSON, CSV, TSV, Agent, Raw. Every command supports all formats via
--json,--csv, etc. - JSON query engine
- Built-in jq-lite with
trs json -q '.users[].name'. No dependency on jq. - File reader
trs read -l aggressiveextracts only function signatures. Minimal mode strips comments.- Agent attribution
trs rewriteand plugin templates injectTRS_AGENT=<label>into the rewritten command so history logs who fired the run: Claude, Gemini, Cursor, OpenCode, Kilo. Rules-only agents show as (untagged); we don't invent labels we can't verify.- Self-upgrade
trs upgradedetects your install channel (npm / curl|sh) and re-runs it. After a successful binary upgrade it also refreshes hook templates and re-installs the output-saver block where present.- Bug-report bundle
trs debug-infopackages version, platform, doctor checks, recent history, and tee logs into one paste-ready report. Use it when filing an issue or sharing a repro.- Collision check
trs initscans target configs for hooks from other token-compression tools (following@importstoo) and aborts by default.--replacemigrates cleanly;--forcestacks at your own risk.- Transparent wrappers
- Built-ins like
time,nohup,noglob,commandare recognized automatically. Project-specific wrappers (docker exec myapp,poetry run,direnv exec .) plug in via[hooks].transparent_prefixesin~/.trs/config.toml.