trs

Supported commands

Every command supported by trs falls into one of four levels.

  1. Dedicated parser. trs spawns the tool, parses its native output, and emits a structured compact form. See the measured numbers per command in the benchmarks.
  2. Dispatched alias. A different binary with the same semantics (e.g. rg for grep, eza for ls) gets routed to the same parser. No configuration, the dispatcher recognizes the binary name.
  3. Generic compression. Commands without a parser still get ANSI stripping and whitespace collapse. Consecutive repeats fold to line (x3), or (last 2 lines x3) for a repeated block; each fold is undone and compared before it is used, and non-consecutive repeats are left alone because their order is information. Log lines equal but for their timestamps keep the first line plus (x3, until 19:56:31); spacing, symbols and numbers still have to match, because in code they are content. A 300+ char line with almost no spaces (minified code, base64, a data URI) keeps its head and tail around …[minified, 4184 chars]…, and the full output is saved with its path printed. It saves little on its own: 2-16% measured on real traffic.
  4. Passthrough. Commands where trs detects a flag that already produces structured output (--json, --porcelain) are passed through untouched, the agent gets the raw structured form.

Commands with dedicated parsers

VCS: git

Command Subcommands parsed
git status, diff, log, branch, push, pull, fetch, show, stash show -p, stash pop, stash apply, grep

Notes: --no-verify is blocked on git commit / git push to protect pre-commit hooks from AI agents that default to bypassing them. git status --porcelain passes through untouched. git show and git stash show -p are routed to the diff parser (~90% reduction on commits with modifications). git push / pull / fetch strips remote: progress lines (Counting, Compressing, Total), ~85% reduction vs ~35% without this filter.

Build: Rust

Command Subcommands parsed
cargo build, check, clippy, test, fmt, install, add

Notes: env-var prefix preserved, RUSTFLAGS=xyz cargo build is rewritten to RUSTFLAGS=xyz trs cargo build so the flag still reaches cargo.

Build: JavaScript / TypeScript

Command Subcommands parsed
npm install (+i, ci), test, ls / list, audit, outdated, run
pnpm install (+i), test, ls, audit, outdated, why, add, update, up, run, dlx, exec
yarn install, test
bun install, test, run
npx / bunx / pnpm dlx routed to whichever inner command is invoked

run subcommand routing: build* → Build parser, test* → Test parser, lint / type-check / typecheck / check / format / format:check → Lint parser. Other script names fall through to generic compression.

Build: Go

Command Subcommands parsed
go test, build, mod

Build: native (C, C++, Swift, Java)

Command What gets parsed
cmake warnings and errors kept, compile-command echoes dropped
make generic path: a target prints anything, so its output stays
gcc / g++ / clang / javac error: / warning: lines, grouped
swift build; run and test stay generic, their output is the answer
xcodebuild among the chattiest output there is: compile echoes, “Write auxiliary files” and dependency checks go, error: / warning: and the BUILD SUCCEEDED/FAILED sentinel stay

Build: Java (Maven, Gradle)

Command What gets parsed
mvn / ./mvnw any goal. Kept: compiler errors (once, with symbol: / location:), each failed test with its message and up to 5 frames from your own code, [WARNING] lines, the failed module and the -rf :module resume hint, summed test counts, BUILD SUCCESS/FAILURE. Dropped: download progress (counted), plugin banners, per-class passing test lines, Maven’s help boilerplate. While tests run, app logs at INFO/DEBUG and the Spring banner are counted, not shown; WARN/ERROR logs stay. Lines it does not recognize, such as dependency:tree, are kept.
gradle / ./gradlew any task. Kept: failed tasks, compiler errors with their source line (once), warnings by location, failed tests, test counts, BUILD SUCCESSFUL/FAILED. Gradle prints a failed test as just AssertionFailedError at CartTest.java:7; trs adds the message (expected: <5> but was: <4>) from the JUnit XML report that run wrote. Dropped: tasks with nothing new (counted), * Try: hints, the echoed source under warnings.

Build: Python

Command Subcommands parsed
pip / pip3 install, list, freeze, show
uv pip, sync, add, remove, run, tree
poetry install, add, update, remove, lock; poetry run <tool> routes to the inner tool’s parser
python3 -m <module> routed: pytest → test, mypy / ruff / pylint / flake8 → lint, unittest → test

Tests

Command What gets parsed
pytest full runner output, pass/fail counts, failure locations, tracebacks
jest full runner output, suite summary, failed assertions
vitest full runner output
cargo test see “Build, Rust”
go test see “Build, Go”
npm test / pnpm test / bun test / yarn test dispatched to the inner runner

Linters

Command What gets parsed
cargo clippy grouped by file + rule
eslint issues grouped by file
biome issues grouped by file
ruff issues grouped by file
pylint issues grouped by file
golangci-lint issues grouped by file
tsc file(line,col): error TS6133: …, grouped by file, ~80% reduction

tsc is also reached via npx tsc, bunx tsc, pnpm dlx tsc, and uv run tsc. biome is also reached via npx @biomejs/biome (full package-name form). Dispatched the same as any other linter (compact by default, --json for structured output).

Command Aliases routed Notes
ls lsd, exa, eza long format parsed; --json passthrough
find fd result list compacted
grep rg, ag, ack line/match format; also git grep
tree — directory tree compressed
tail journalctl log-tail with error filter

File reading

cat, head and sed run verbatim: agents act on what they read, and a comment stripped from an edit target breaks the next edit.

Containers & GitHub CLI

Command Subcommands parsed
docker ps, logs, build
gh pr list, pr view, pr diff, pr checks, issue list, issue view, run list, run view, api

gh api responses arrive minified, so there is no whitespace left to squeeze. What trs drops instead is GitHub’s link boilerplate: every *_url key except html_url, the API self-link url, node_id, gravatar_id, the _links block that restates the URLs, and a commit’s verification.payload / verification.signature (a PGP blob plus a raw copy of fields already present as structured keys; verified and reason stay). Measured 62 to 67% smaller on pulls, repos, commits and issues, and the output is still valid JSON.

Two cases pass through untouched: a body that is not JSON, and gh api --jq / --template, where the caller already selected their fields. trs diff gh api <endpoint> shows exactly which keys went.

The list commands keep every column an agent acts on, in one line per row: gh pr list the number, title, full branch name and state; gh issue list the number, state, title and labels; gh run list the run id (what gh run view <id> and gh run rerun <id> take), title, workflow, branch and duration. A state every row shares (gh pr list defaults to OPEN) is said once in the header. Dates and the triggering event are dropped (--json has them).

gh pr view and gh issue view keep the title, state, author, url, the header fields that have a value (labels, reviewers, assignees, comment count, parent and blocking issues) and the whole body, minus template <!-- --> comments; the empty fields gh prints on every view are dropped. With --comments they keep each comment’s author, role, review state and body, one @author (role, state) line per comment. gh pr diff routes to the git-diff parser (~90% reduction). gh pr checks summarises pass/fail/pending counts and lists only non-passing checks with duration. gh run view extracts title, conclusion, job counts, up to 3 annotations, and the run URL.

Cloud CLIs

Command Subcommands parsed
aws s3 recursive operations (rm, rb, cp, sync, mv); describe-* / get-* / list-* JSON bodies

Recursive s3 calls print one receipt line per object (delete: s3://bucket/key), which is the most repetitive output trs sees, a real 3.3 MB deletion compressed to 275 bytes (99.99%). The summary keeps the verb, the object count and the busiest key prefixes:

delete: 50000 objects, s3://bucket/logs/2026/01/ (596), … +81 more prefixes
problems (1):
  An error occurred (AccessDenied) when calling the DeleteObject operation

Failures are pulled out and never truncated: AWS’s canonical An error occurred (…) line carries no colon after “error”, so the generic error markers miss it and it is matched explicitly. JSON bodies are forwarded to the same compressor gh api uses; output that matches neither shape passes through untouched rather than being guessed at.

Database clients

Command What gets parsed
psql / mysql / mariadb / sqlite3 the result grid: column headers, rows and the (N rows) footer, with the box-drawing borders dropped

Reached through the generic catch-all rather than the explicit rewrite set, which is why trs stats --coverage lists them under handled traffic but trs init does not name them.

System & network

Command What gets parsed
ps column-aware (robust against right-aligned columns)
du sorted by size descending, largest 15 kept, tail summarized
lsof one row per process instead of one per descriptor, address kept
pgrep identical command lines merged, argv[0] shortened to basename
env / printenv sorted, secrets masked
wc line/word/byte totals
ping per-packet lines collapsed into one summary
brew list, outdated, services
curl headers + body compression; curl -I parses headers only
wget progress output stripped

Built-in trs tools (not wrappers)

These are native trs commands: no external binary behind them. They ship inside the single-binary install.

Command Purpose
trs json jq-lite query engine (-q '.users[].name')
trs read file reader with -l minimal (strip comments) / -l aggressive (signatures only)
trs search ripgrep-powered content search
trs replace ripgrep-powered replace with --dry-run
trs err error filter, only errors/warnings from a wrapped command
trs tail log tail with --errors filter
trs clean --no-ansi, --collapse-blanks, --dedup-lines
trs html2md HTML → Markdown
trs find gitignore-aware walker
trs is-clean repo clean check (exit 0 if clean, 1 otherwise)
trs raw passthrough that still tracks stats
trs stats token-savings dashboard
trs ingest whole-repo digest for agent context

Partial runs

When search, replace or find --gitignore cannot read part of the tree, it keeps what it did, prints a failed: <path> line per miss (20 at most, then a count; --json: failed, failed_total) and exits 2. A missing root exits 2 as well. ingest does the same on stderr; see ingest.

search leaves out only .git and what .gitignore excludes. replace also skips node_modules, vendor, build, dist, target and similar directories below the root; name one as the root to edit it.

search and replace match one line at a time, so [^\n] and \s stop at the line end. A pattern that needs a newline (a\nb, \x0A) matches across lines instead; a CRLF file needs \r\n there. replace keeps each file’s line endings and final newline as written.

Dispatch mechanisms

Runners

uv run, poetry run, pdm run, pipenv run, npx, bunx, pnpm exec|dlx, yarn exec|dlx, nix develop|shell -c, mise exec|x -- and direnv exec reach the parser of the command they run, and take its stderr policy. just, task, mise run and make stay generic: a recipe name does not say what runs.

Chain-aware rewrite

When a command chain uses && or ;, each rewritable segment gets wrapped independently.

cd src && cargo test              → cd src && trs cargo test
cargo fmt && cargo clippy         → trs cargo fmt && trs cargo clippy

Pipes pass through untouched: trs never splits a pipeline because the compressed form would lose the byte-stream contract.

Pipe syntax (stdin)

Any parser is also reachable over stdin:

git status | trs parse git-status
cargo build 2>&1 | trs parse cargo-build

Env-var prefix

Leading VAR=value assignments are preserved on the rewrite:

RUSTFLAGS='-C target-cpu=native' cargo build
→ RUSTFLAGS='-C target-cpu=native' trs cargo build

Bypass: TRS_SKIP=1

To run a single command without any trs wrapping (for debugging or when you specifically need raw output):

TRS_SKIP=1 git status             # runs raw git, no parser, no tracking

Redirections

2>&1 and other stdout/stderr redirections are stripped at the rewrite layer and reapplied to the wrapped command, so trs sees the same combined stream the shell would have produced.

Generic compression (the fallback)

Any command not listed above still flows through trs’s generic reducer: ANSI strips, whitespace collapsed, repeated lines deduped. On its own it saves little (2-16% measured on real traffic): the win comes from a parser.

ollama list / ls / ps lose the ID column and the alignment padding (agents address models by name; the digest is only useful to ollama rm), and ollama pull folds its redrawn per-layer progress into the layer list plus the final verdict. run, show and serve pass through: their output is model text.

kubectl is routed and tracked in stats but has no dedicated parser yet, so it gets the generic reducer and trs stats --coverage lists it as a gap.

One class is exempt. Commands whose output is a re-layout of their input carry meaning in exactly the runs of spaces and blank lines the reducer collapses, so trs hands their output back untouched: awk, base64, basenc, column, comm, cut, expand, fold, hexdump, iconv, join, jq, nl, od, paste, printf, rev, sort, strings, tac, tr, unexpand, uniq, xxd, yq. See docs/support/safety.md.

If a dedicated parser exists but errors out mid-parse, trs falls back to truncated passthrough rather than silent failure, the full raw output is also saved to ~/.trs/tee/ so you can recover it.

See also: