trs — Token-Reducing Shell, terminal compression for AI agents

Token-Reducing Shell · v0.5.12 · Rust · MIT
Terminal compression for AI agents. 68–99% smaller output, same signal.
● Also built-in: trs ingest — LLM-ready project digest →
6 MB single binary ~12 ms startup 9 AI tool hooks 30+ parsers zero Node overhead

Install

Pick whatever fits your stack. All five methods ship the same native binary — the install script is fastest.

curl -fsSL https://usetrs.dev/install.sh | sh

Downloads the right binary into ~/.trs/bin/trs. Zero runtime deps, no Node overhead, ~12ms startup.

irm https://usetrs.dev/install.ps1 | iex

PowerShell installer. Drops the binary into %USERPROFILE%\.trs\bin\trs.exe.

npm install -g @dpeluche/trs

Cross-platform. optionalDependencies installs only the matching platform binary. Shell launcher at runtime — no Node overhead.

cargo install trs-cli

From source via crates.io. Good if you already have the Rust toolchain.

Prebuilt binaries for Linux x64/arm64, macOS x64/arm64, Windows x64.

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.

your command git status cargo test · ls -la · ... 1.4 KB raw · ~350 tok trs spawn · parse · reshape ~12 ms · native binary zero runtime deps compact output compact · JSON · agent CSV · TSV · raw 336 B · ~84 tok (-76%) every command logged ~/.trs/history.jsonl fuels  trs stats · savings dashboard

Raw command runs unchanged. Parsers only reshape what the user sees. No modification of the underlying tool, no custom wrappers to maintain, no context lost.

Supported AI agents

Ten agents, three install mechanisms. trs init --all --global wires every detected agent in one shot.

Agent Install method Input hook Output-saver Attribution
Claude Code · Gemini · Cursorprogrammatic hookclaude / gemini / cursor
OpenCode · Kilo Codeplugin templateopencode / kilo
Factory Droidprogrammatic hookclaude (shared envelope)
Antigravity IDE · Antigravity CLI (agy)rules file (why)(untagged)
Codex CLI · Windsurfrules file only(untagged)

Full matrix + caveats + per-agent config paths: docs/support/agents.md.

Supported commands

Thirty-plus dedicated parsers. Anything else falls to generic compression (~30–40% free) 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, plus python3 -m <mod> routing for pytest / mypy / ruff / pylint / flake8.
Go
go — test, build, mod.
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. Plus cat, head, sed -n X,Yp intercepted with comment stripping.
Containers & GitHub
docker (ps, logs, build) and gh (pr list, pr view, issue list, run list + gh api).
System & network
ps, env, wc, brew, curl, wget.
Chain-aware
cd X && cargo test wraps each rewritable segment. Pipes and semicolons pass through untouched.
Env-prefix preservation
RUSTFLAGS=x cargo build keeps the leading assignment — 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, 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 — more options in this space means a better fit for more workflows. trs kept iterating and expanding as we learned more about where tokens actually burn.

The more we used it, the more we saw the opportunity was bigger than input hooks. 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 — the story just got bigger than hooks.

Before / with trs

Raw output vs what trs emits. Token counts are rough (bytes / 4) but directionally accurate. Click any row to see the actual before/after.

git status
−76%
1.4 KB
~350 tokens raw
vs
336 B
~84 tokens trs
On branch main Your branch is ahead of 'origin/main' by 1 commit. Changes not staged for commit: (use "git add <file>..." to update) (use "git restore <file>..." to discard) modified: src/main.rs modified: src/lib.rs new file: src/new.rs no changes added to commit
main [ahead 1] unstaged (3): M src/main.rs M src/lib.rs A src/new.rs
cargo test
−99%
55 KB
~14k tokens raw
vs
58 B
~15 tokens trs
Compiling trs-cli v0.5.12 Finished test profile in 4.21s Running unittests src/main.rs running 2186 tests test config::tests::test_defaults ... ok test config::tests::test_parse ... ok ... (2175 more lines) ... test result: ok. 2186 passed; 0 failed Running tests/cli_flags.rs ... (70 more suites) ...
cargo test: 2186 passed (71 suites, 4.9s)
cargo clippy
−90%
55 KB
~14k tokens raw
vs
5.5 KB
~1.4k tokens trs
warning: unused import: `std::io::Read` --> src/main.rs:8:23 | 8 | use std::io::Read; | ^^^^ = note: `#[warn(unused_imports)]` ... (hundreds more lines) ...
lint: 102 issues in 39 files src/main.rs (3): W unused_import 8:23 W redundant_closure 44:30 W dead_code 112:8 ... grouped by file + rule
git log -10
−91%
7.6 KB
~1.9k tokens raw
vs
689 B
~172 tokens trs
commit 9c2231b... (HEAD -> main) Author: Antonio Martinez Quintero Date: Thu Apr 16 ... Merge pull request #9 commit 35b5f4f... ... full messages + headers ...
9c2231b Merge PR #9 init polish 35b5f4f feat(init): Antigravity/Windsurf rules ad55480 feat(init): smart JSON merge ... date + author collapsed

Numbers are representative; 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

A separate superpower. Turns any codebase into an LLM-ready markdown digest: structure, key files, dependency graph, and compressed signatures.

codebase src/ · docs/ · Cargo.toml ~400 files · 600+ KB .gitignore respected raw source · too big for LLM trs ingest walk · parse · compress build dep graph budget + git aware --budget · --deps · --since-last digest.md structure · key deps signatures · changed files ready to Read by the agent 16 KB · fits in context sidecar metadata .trs/ingest · <repo>.json head_sha · tokens · file_count · timestamp fuels --fresh cache & stale detection
One command, digest in hand ingest
Budget-aware, git-aware, with stale detection. Spark, agents, CI pipelines — anyone can call it and get a cacheable artifact.
$ trs ingest --budget 128k # fit to token budget $ trs ingest --deps # dependency graph only (no file content) $ trs ingest --since-last # diff-mode from last ingest $ trs ingest --fresh # reuse cached digest if HEAD unchanged $ trs ingest --list # show stored digests with stale markers $ trs ingest -o ~/ctx.md # path on stdout, no shadow save
Budget-aware
Auto-fit to a token budget (32k, 128k, 1M). Signatures first, bodies second.
Git-aware
Only files changed since last ingest or since any ref. HEAD tracked per project.
Dependency graph
Who imports what, most-imported files, cross-language (Rust / TS / Python / Go).
Stale detection
Compares stored HEAD vs current. Says "3 commits behind" in --list.
Unix-style output
Writes to disk, prints the path on stdout. Agents Read on demand.
Ollama post-process
--ollama <model> runs the digest through a local LLM for an executive summary.
Live example
trs ingests itself at docs/development/codebase-digest.md — ~26k tokens covering the whole repo, refreshed on every release.
Curious about the numbers? Install trs in 10 seconds and see the compression on your own repo.
curl -fsSL https://usetrs.dev/install.sh | sh

Compression reference

Typical reductions on commands run dozens of times a day. Use these as rough expectations — not as a leaderboard.

CommandRawtrsReduction
cargo test8.1 KB58 B99%
cargo clippy55 KB5.5 KB90%
git log -107.6 KB689 B91%
git status1.4 KB336 B76%
git diff14.6 KB8.0 KB45%
gh pr list560 B348 B38%
env2.9 KB728 B75%
trs ingest (this repo)600+ KB raw source16 KB digest97%
~12ms
startup on macOS / Linux
0ms
Node overhead (shell launcher)
68–99%
output compression range
30+
dedicated parsers

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 that compresses what agents emit: no preambles, no narration, result-first, no hallucinated paths.

All ten agents covered
Claude Code, Gemini, Cursor, OpenCode, Kilo, Droid, Codex, Windsurf, Antigravity IDE, Antigravity CLI. The Antigravity pair (IDE + agy) is rules-only as of v0.6.6 — agy v1.0.1 doesn't yet expose user-configurable PreTool hooks (research).
Check-first by default
Dry-run scan shows exactly what would change. --install to write, trs uninstall --output-saver to remove cleanly across every agent.
Idempotent merge
Sentinel-wrapped block. Re-running --install updates in place; your other rules stay untouched.

Full reference: docs/features/output-saver.md.

More features

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.
Intelligent file reader
trs read -l aggressive extracts only function signatures. Minimal mode strips comments.
Docs auditor
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.
Token savings dashboard
trs stats shows cumulative compression, tokens saved per day, top commands. trs stats --by-agent breaks totals down by agent. -n N adjusts row counts. JSON output for dashboards.
Agent attribution
trs rewrite and plugin templates inject TRS_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 upgrade detects 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-info packages 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 init scans target configs for hooks from other token-compression tools (following @imports too) and aborts by default. --replace migrates cleanly; --force stacks at your own risk.
Symmetric uninstall
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 --all / --tool / --output-saver / --dry-run for scripts.
Transparent wrappers
Built-ins like time, nohup, noglob, command are recognized automatically. Project-specific wrappers (docker exec myapp, poetry run, direnv exec .) plug in via [hooks].transparent_prefixes in ~/.trs/config.toml.

Install

All options ship the same Rust binary. The install script is fastest — no Node overhead, single curl.

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, ~12ms startup. Pin a version with TRS_VERSION=v0.5.12.

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 — npm only downloads the binary for your platform. A shell launcher execs the binary directly (no Node at runtime).

cargo install trs-cli

Builds from source. Good if you have the Rust toolchain and want the absolute latest commit (via --git).

Download from the GitHub Releases page.

Prebuilt binaries for Linux x64/arm64, macOS x64/arm64, and Windows x64. Drop into your $PATH, chmod +x, done.