{"slug": "cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands", "title": "CLI proxy that reduces LLM token consumption by 60-90% on dev commands", "summary": "RTK, an open-source Rust-based CLI proxy from the rtk-ai project, intercepts shell commands and compresses their output before it reaches an AI coding agent's context, cutting bash output size by up to 90% across 100+ supported commands with under 10ms of overhead. The project states the reduction applies to bash output only — one contributor to input tokens alongside the prompt, system prompt and conversation history — and that its token counts are estimated as bytes divided by 4, so percentages are reliable but absolute token figures are approximate. RTK ships as three downloads: the full `rtk` edition (Apache-2.0 plus BUSL-1.1, with hooks, filters and engine), an Apache-2.0-only `rtk-oss` edition, and `rtk-proxy` (BUSL-1.1) for compressing API traffic; the two `rtk` editions install a binary of the same name and cannot be installed together.", "body_md": "**Agent-agnostic token optimization: compress, route, filter, and more.**\n\n  One composable pipeline across everything your AI agent reads and sends — built on RTK's battle-tested bash-output compression (up to 90% smaller).\n\n[Website](https://www.rtk-ai.app) •\n  [Install](#installation) •\n  [Troubleshooting](https://www.rtk-ai.app/guide/resources/troubleshooting) •\n  [Architecture](https://github.com/rtk-ai/rtk/blob/develop/docs/contributing/ARCHITECTURE.md) •\n  [Discord](https://discord.gg/RySmvNF5kF)\n\n[English](https://github.com/rtk-ai/rtk/blob/develop/README.md) •\n  [Francais](https://github.com/rtk-ai/rtk/blob/develop/README_fr.md) •\n  [中文](https://github.com/rtk-ai/rtk/blob/develop/README_zh.md) •\n  [日本語](https://github.com/rtk-ai/rtk/blob/develop/README_ja.md) •\n  [한국어](https://github.com/rtk-ai/rtk/blob/develop/README_ko.md) •\n  [Espanol](https://github.com/rtk-ai/rtk/blob/develop/README_es.md) •\n  [Português](https://github.com/rtk-ai/rtk/blob/develop/README_pt.md)\n\nrtk filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.\n\nAngular builds are supported with `rtk ng build`: compact build tables with every bundle and diagnostic retained.\n\nRTK intercepts shell commands and compresses their output before your agent reads it.\n\n| Operation | What RTK does to the output | \n|---|---|\n| `ls` /`tree` | Tree format with file counts instead of one line per entry | \n| `cat` /`read` | Smart file reading: signatures and structure over full bodies | \n| `grep` /`rg` | Truncates long lines, groups matches by file | \n| `ast-grep` | Groups structural matches by file, caps overflow | \n| `git status` | Compact stat format, grouped by state | \n| `git diff` | Reduced context, headers stripped | \n| `git log` | Hash, author and subject only | \n| `git add/commit/push` | Confirmation line instead of full progress output | \n| `cargo test` /`npm test` | Failures only, passing tests collapsed to a count | \n| `ruff check` | Grouped by rule and file | \n| `sqlfluff lint` | Grouped by rule and file | \n| `pytest` | Failures only, traceback trimmed | \n| `go test` | NDJSON parsed, failures only | \n| `docker ps` | Essential fields only | \n\nRTK reduces the **bash output** your agent reads. That is what RTK measures, and it is not the same as cutting your bill by the same amount.\n\nBash output is **one contributor to input tokens**, alongside your prompt, the system prompt and conversation history. Input tokens are in turn **only part of the bill**, which also counts output tokens. The reduction dilutes at every step.\n\nThe token counts RTK reports are estimated as `bytes / 4` — RTK ships no tokenizer, so the **percentages are reliable but the absolute token numbers are approximate**.\n\nFull explanation: [How RTK Savings Work](https://github.com/rtk-ai/rtk/blob/develop/docs/guide/resources/savings-explained.md)\n\n```\nbrew install rtk                                              # macOS / Linux\nwinget install rtk-ai.rtk                                     # Windows\ncurl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh\n```\n\nThen check you have the right package — another project named \"rtk\" exists on crates.io:\n\n```\nrtk --version   # any current version\nrtk gain        # must show the savings dashboard, not \"command not found\"\n```\n\nCargo, pre-built binaries, native Windows, WSL, and uninstall: [Installation guide](https://www.rtk-ai.app/guide/getting-started/installation)\n\nRTK ships as three downloads. The two `rtk` editions install a binary with the **same name** — hooks, scripts and agent config work unchanged across both — so they cannot be installed together. Uninstall one before installing the other.\n\n```\nflowchart TD\n    agent[\"Your coding agent\"]\n\n    subgraph editions[\"Pick one · both install a binary named rtk\"]\n        direction LR\n        full[\"<b>rtk</b><br/>Apache-2.0 + BUSL-1.1<br/>hooks · filters · engine\"]\n        oss[\"<b>rtk-oss</b><br/>Apache-2.0 only<br/>hooks · filters\"]\n    end\n\n    proxy[\"<b>rtk-proxy</b><br/>BUSL-1.1<br/>compresses API traffic\"]\n\n    agent -->|\"command output\"| full\n    agent -->|\"command output\"| oss\n    agent -.->|\"API traffic\"| proxy\n\n    classDef apache stroke:#2da44e,stroke-width:2px,fill:none\n    classDef busl stroke:#0969da,stroke-width:2px,fill:none\n    classDef mixed stroke:#8250df,stroke-width:2px,fill:none\n    classDef plain stroke:#8c959f,stroke-width:1px,fill:none\n    class full mixed\n    class oss apache\n    class proxy busl\n    class agent plain\n    style editions fill:none,stroke:#d0d7de,stroke-dasharray:4 4\n```\n\n| Download | Licence | Contains | \n|---|---|---|\n| `rtk-<target>` | Apache-2.0 + BUSL-1.1 | Hook core, every command filter, **and** the compression engine | \n| `rtk-oss-<target>` | Apache-2.0 only | Hook core and every command filter. No engine. | \n| `rtk-proxy-<target>` | BUSL-1.1 | The RTK Proxy daemon. Never bundled with either `rtk` . | \n\n**Production use is free**, engine and daemon included. What the BUSL grant does not cover is offering RTK or a derivative to third parties as a commercial product or service — for that, contact **[contact@rtk-ai.app](mailto:contact@rtk-ai.app)**.\n\n```\ncurl -fsSL .../install.sh | RTK_EDITION=oss sh    # Apache-2.0 edition\nbrew install rtk-ai/tap/rtk-oss\n```\n\nWhat the Apache-2.0 edition omits and where the licence boundary falls: [Editions and Licensing](https://www.rtk-ai.app/guide/resources/editions)\n\n```\n# 1. Install for your AI tool\nrtk init -g                     # Claude Code / Copilot (default)\nrtk init -g --gemini            # Gemini CLI\nrtk init -g --codex             # Codex (OpenAI)\nrtk init -g --agent cursor      # Cursor\nrtk init -g --agent windsurf    # Windsurf\nrtk init --agent cline          # Cline / Roo Code\nrtk init --agent kilocode       # Kilo Code\nrtk init --agent antigravity    # Google Antigravity\nrtk init --agent kimi           # Kimi AI\nrtk init -g --agent pi          # Pi\nrtk init --agent omp            # Oh My Pi (OMP)\nrtk init --agent hermes         # Hermes\nrtk init -g --agent droid       # Factory Droid\nrtk init --agent trae           # Trae (project: .trae/hooks.json)\nrtk init -g --agent trae        # Trae global: ~/.trae and existing ~/.trae-cn\n\n# 2. Restart your AI tool, then test\ngit status  # Automatically rewritten to rtk git status\n```\n\nThe agent receives compact output without ever calling `rtk` explicitly.\n\n**The hook only fires on Bash tool calls.** Built-in tools like `Read`, `Grep` and `Glob` do not pass through it. Use shell commands (`cat`, `rg`, `find`) or call `rtk read`, `rtk grep`, `rtk find` directly.\n\nPer-agent setup, `--dry-run`, and uninstall: **[Quick Start](https://www.rtk-ai.app/guide/getting-started/quick-start)** · [Supported Agents](https://www.rtk-ai.app/guide/getting-started/supported-agents)\n\n```\n  Without rtk:                                    With rtk:\n\n  Claude  --git status-->  shell  -->  git         Claude  --git status-->  RTK  -->  git\n    ^                                   |            ^                      |          |\n    |         full raw output           |            |  compact output      | filter   |\n    +-----------------------------------+            +------- (filtered) ---+----------+\n```\n\nFour strategies applied per command type:\n\n1. **Smart Filtering** - Removes noise (comments, whitespace, boilerplate)\n2. **Grouping** - Aggregates similar items (files by directory, errors by type)\n3. **Truncation** - Keeps relevant context, cuts redundancy\n4. **Deduplication** - Collapses repeated log lines with counts\n\n**Does RTK break Claude's prompt cache?** No. RTK filters output once per command. The result is stored in history and cached normally on subsequent API calls, so the cache keeps working as expected. Smaller outputs also mean cheaper cache writes and reads. See [Troubleshooting](https://github.com/rtk-ai/rtk/blob/develop/docs/guide/resources/troubleshooting.md#does-rtk-break-claudes-prompt-cache) for details.\n\nRTK supports 18 AI coding tools. Each integration rewrites shell commands to `rtk` equivalents, reducing the bash output the agent reads where the agent supports command interception.\n\n| Tool | Install | Method | \n|---|---|---|\n| **Claude Code** | `rtk init -g` | PreToolUse hook (native binary) | \n| **GitHub Copilot (VS Code)** | `rtk init -g --copilot` | PreToolUse hook — transparent rewrite | \n| **GitHub Copilot CLI** | `rtk init -g --copilot` | PreToolUse deny-with-suggestion (CLI limitation) | \n| **Cursor** | `rtk init -g --agent cursor` | preToolUse hook (hooks.json) | \n| **Gemini CLI** | `rtk init -g --gemini` | BeforeTool hook | \n| **Codex** | `rtk init -g --codex` | PreToolUse hook ( `updatedInput` ) + AGENTS.md | \n| **Windsurf** | `rtk init -g --agent windsurf` | .windsurfrules (project-scoped) | \n| **Cline / Roo Code** | `rtk init --agent cline` | .clinerules (project-scoped) | \n| **OpenCode** | `rtk init -g --opencode` | Plugin TS (execute.before / tool.execute.before), needs 1.18.29 or newer | \n| **OpenClaw** | `openclaw plugins install ./openclaw` | Plugin TS (before_tool_call) | \n| **Pi** | `rtk init -g --agent pi` (global) | TypeScript extension (tool_call) | \n| **Oh My Pi (OMP)** | `rtk init -g --agent omp` (global) /`rtk init --agent omp` (project) | TypeScript extension (tool_call, shared with Pi) | \n| **Hermes** | `rtk init --agent hermes` | Python plugin adapter (terminal command mutation via `rtk rewrite` ) | \n| **Mistral Vibe** | `rtk init -g --agent vibe` | `pre_tool` hook (hooks.toml) | \n| **Kilo Code** | `rtk init --agent kilocode` | .kilocode/rules/rtk-rules.md (project-scoped) | \n| **Google Antigravity** | `rtk init --agent antigravity` /`rtk init -g --agent antigravity` | .agents/plugins/rtk/ (project) or ~/.gemini/config/plugins/rtk/ (global): plugin.json, hooks.json, rules/AGENTS.md | \n| **Kimi AI** | `rtk init --agent kimi` | AGENTS.md (project-scoped) | \n| **Factory Droid** | `rtk init -g --agent droid` (or per-project) | PreToolUse hook in `~/.factory/hooks.json` (matcher`Execute` ) | \n| **Trae** | `rtk init --agent trae` | Native `PreToolUse` hook in`.trae/hooks.json` (`RunCommand` ) | \n| **Trae (global)** | `rtk init -g --agent trae` | `~/.trae/hooks.json` , plus`~/.trae-cn/hooks.json` when that directory exists | \n\nFor per-agent setup details, override controls, and graceful degradation, see the [Supported Agents guide](https://www.rtk-ai.app/guide/getting-started/supported-agents). The Hermes plugin source and tests live in `hooks/hermes/`; installed Hermes runtime files still live under `~/.hermes/plugins/rtk-rewrite/`.\n\n100+ commands across Git, GitHub CLI, Cargo/Rust, JavaScript (npm, pnpm, vitest, jest, tsc, Next.js, Playwright, Prisma), Python (ruff, pytest, mypy, pip), Go (go test, golangci-lint), Ruby, .NET, JVM (Gradle, Maven), PHP, Docker, Kubernetes, AWS, Terraform, and the file/search builtins.\n\n```\n-v, --verbose          # increase verbosity (-v, -vv, -vvv)\nrtk bypass <cmd>       # run one command unfiltered, still tracked\n```\n\nEvery command and its filter: [What RTK Optimizes](https://www.rtk-ai.app/guide/resources/what-rtk-covers)\n\n`rtk` filters command output by default. When a result looks wrong, bypass the filter for one command to see the raw output and tell a filter bug apart from the real thing:\n\n```\nrtk bypass git log --oneline -20        # full git log, no truncation\nrtk bypass npm install express          # raw npm output, no filtering\nrtk bypass curl https://api.example.com/data\n```\n\n- **What it does** : runs one command unfiltered and still tracks it — bypassed commands appear in`rtk gain --history` with 0% bash output reduction.\n- **When to use it** : an output looks off and you need to know whether the filter or the command produced it, when debugging a filter, or for an edge case a filter mishandles.\n- `rtk proxy <cmd>` is a deprecated alias of`rtk bypass <cmd>` .\n\n**Not the same thing as `rtk llm-proxy`.** `rtk bypass` runs one local command unfiltered. `rtk llm-proxy` manages the `rtk-proxy` daemon, which compresses your agent's provider-API traffic — see [RTK Proxy](#rtk-proxy-optional).\n\n```\nrtk gain                        # Summary stats\nrtk gain --graph                # ASCII graph (last 30 days)\nrtk gain --history              # Recent command history\nrtk gain --daily                # Day-by-day breakdown\nrtk gain --all --format json    # JSON export for dashboards\n\nrtk discover                    # Find missed savings opportunities\nrtk discover --all --since 7    # All projects, last 7 days\n\nrtk session                     # Show RTK adoption across recent sessions\n```\n\nAttribution, the live dashboard and export formats: [Token Savings Analytics](https://www.rtk-ai.app/guide/analytics/gain)\n\n`rtk` optimizes **command output** before your agent reads it. The `rtk-proxy` daemon extends the same engine to your agent's **provider-API traffic** — a local background process that sits between your agent and the provider and runs the pipeline on the traffic itself: it **compresses** payloads, strips bytes no model ever needed before forwarding, and carries the calls your pipeline routes to cheaper models, so they borrow the credential your agent already sends and show up in `rtk gain`. It can also align prompt-cache breakpoints where the agent leaves them open (opt-in).\n\n```\nrtk claude              # start the daemon if needed, then launch Claude through it\nrtk llm-proxy status    # is it up\nrtk gain                # savings, command-filtering and proxy side by side\n```\n\n**Two independent ways in**, because not every harness has a session hook:\n\n|  | What it does | \n|---|---|\n| `rtk init -g` | Offers to set it up once: writes the base URL and the `rtk:proxy` pipeline, then asks how the daemon should come back after a reboot — SessionStart hook, background service, or neither. | \n| `rtk <harness>` | No configuration at all. Starts the daemon, points the harness at it, then execs it. Needs no hook system, which is why it covers harnesses that have none. | \n\n`rtk <harness>` resolving is itself the signal that traffic really goes through the daemon — the subcommand exists only where redirection is verified. Today that is `rtk claude`. A harness without one is never silently unproxied: it falls through to plain passthrough, and `rtk llm-proxy setup` lists what can be launched.\n\nIt is a separate binary under a separate licence (BUSL-1.1), shipped as its own `rtk-proxy-<target>` archive — `rtk` never links it.\n\nSetup and subcommands: **[RTK Proxy](https://www.rtk-ai.app/guide/proxy/overview)** · what it compresses: **[What the Proxy Compresses](https://www.rtk-ai.app/guide/proxy/compression)** · settings and endpoints: [Proxy Configuration](https://www.rtk-ai.app/guide/proxy/configuration)\n\nEverything RTK does — which commands get rewritten, what happens to a tool's output, what the proxy compresses — is expressed in one composable file. The engine (`engine/`, crate `rtk-engine`, BUSL-1.1) reads it, so the levers are configurable instead of hard-coded.\n\n**Upgrading changes nothing.** With no pipeline file you are on `rtk:default`: the same PreToolUse rewrite, the same awareness file, your `filters.toml`, your `config.toml`. Everything beyond that is opt-in, one line at a time:\n\n```\n# ~/.config/rtk/pipeline.toml\n[pipeline]\nextends = [\"rtk:posthook\", \"rtk:proxy\"]\n```\n\nThe tour: **[Pipelines](https://www.rtk-ai.app/guide/pipelines/overview)** · the reference: **[Writing a Pipeline](https://www.rtk-ai.app/guide/pipelines/writing-pipelines)**, **[Conditions and Judges](https://www.rtk-ai.app/guide/pipelines/conditions)**, **[Methods](https://www.rtk-ai.app/guide/pipelines/methods)**, **[Tasks and Upstreams](https://www.rtk-ai.app/guide/pipelines/tasks)** · the commands: **[Pipeline Commands](https://www.rtk-ai.app/guide/pipelines/commands)** · write your own method: [Plugins](https://www.rtk-ai.app/guide/pipelines/plugins)\n\n**[rtk-ai.app/guide](https://www.rtk-ai.app/guide)** is the full user guide.\n\n| [Installation](https://www.rtk-ai.app/guide/getting-started/installation) | every install method, Windows, WSL, uninstall | \n| [Quick Start](https://www.rtk-ai.app/guide/getting-started/quick-start) | per-agent init, `--dry-run` , first savings | \n| [Supported Agents](https://www.rtk-ai.app/guide/getting-started/supported-agents) | setup detail, override controls, degradation | \n| [Agent Coverage](https://www.rtk-ai.app/guide/resources/agent-coverage) | what each agent's hook API lets RTK do | \n| [What RTK Optimizes](https://www.rtk-ai.app/guide/resources/what-rtk-covers) | every command and its filter | \n| [Configuration](https://www.rtk-ai.app/guide/getting-started/configuration) | `config.toml` , env vars, recall recovery | \n| [Token Savings Analytics](https://www.rtk-ai.app/guide/analytics/gain) | `rtk gain` in full | \n| [Pipelines](https://www.rtk-ai.app/guide/pipelines/overview) | the engine: `pipeline.toml` , rules, judges, tasks, sharing | \n| [RTK Proxy](https://www.rtk-ai.app/guide/proxy/overview) | the daemon: setup, what it compresses, settings | \n| [Editions and Licensing](https://www.rtk-ai.app/guide/resources/editions) | what each download contains | \n| [Telemetry & Privacy](https://www.rtk-ai.app/guide/resources/telemetry) | what is collected, how to opt in, your GDPR rights | \n| [Troubleshooting](https://www.rtk-ai.app/guide/resources/troubleshooting) | common issues, prompt-cache questions | \n\nRepository references: [engine/README.md](https://github.com/rtk-ai/rtk/blob/develop/engine/README.md) · [proxy/README.md](https://github.com/rtk-ai/rtk/blob/develop/proxy/README.md) · [ARCHITECTURE.md](https://github.com/rtk-ai/rtk/blob/develop/docs/contributing/ARCHITECTURE.md) · [CONTRIBUTING.md](https://github.com/rtk-ai/rtk/blob/develop/CONTRIBUTING.md) · [SECURITY.md](https://github.com/rtk-ai/rtk/blob/develop/SECURITY.md)\n\nRTK collects **no command content and no file contents**. Telemetry is anonymous and **off by default** — it sends nothing until you opt in with explicit consent (GDPR Art. 6 & 7) via `rtk telemetry enable`, and documented in [Telemetry & Privacy](https://www.rtk-ai.app/guide/resources/telemetry).\n\n- **Patrick Szymkowiak** — Founder[GitHub](https://github.com/pszymkowiak) ·[LinkedIn](https://www.linkedin.com/in/patrick-szymkowiak/)\n- **Florian Bruniaux** — Core contributor[GitHub](https://github.com/FlorianBruniaux) ·[LinkedIn](https://www.linkedin.com/in/florian-bruniaux-43408b83/)\n- **Adrien Eppling** — Core contributor[GitHub](https://github.com/aeppling) ·[LinkedIn](https://www.linkedin.com/in/adrien-eppling/)\n- **Nicolas Le Cam** — Core contributor[Github](https://github.com/kush) ·[LinkedIn](https://www.linkedin.com/in/nicolas-le-cam-386387160/)\n- **Takayuki Maeda** — Core contributor[GitHub](https://github.com/TaKO8Ki) ·[LinkedIn](https://www.linkedin.com/in/tako8ki/)\n\nContributions welcome! Please open an issue or PR on [GitHub](https://github.com/rtk-ai/rtk).\n\nJoin the community on [Discord](https://discord.gg/RySmvNF5kF).\n\nThe `rtk` CLI is **Apache-2.0** — see [LICENSE](https://github.com/rtk-ai/rtk/blob/develop/LICENSE).\n\nIt links one component under a different licence. `rtk-engine` (`engine/`) is\n**BUSL-1.1**, source-available: see [engine/LICENSE](https://github.com/rtk-ai/rtk/blob/develop/engine/LICENSE). Its\nAdditional Use Grant permits production use as part of the `rtk` binary, so\nrunning `rtk` is covered; using the engine on its own, or inside another\nproduct, is not until the Change Date.\n\nThe `rtk-proxy` daemon (`proxy/`) is **BUSL-1.1** on the same terms and ships as\nits own archive with its licence alongside — `rtk` never links it.\n\nYour company is looking to take control back on your AI fleet ? RTK Pro provides the control layer for costs, security and governances for all agents.\n\nCheck it out : [RTK Pro](https://pro.rtk-ai.app).\n\nSee [DISCLAIMER.md](https://github.com/rtk-ai/rtk/blob/develop/DISCLAIMER.md).", "url": "https://wpnews.pro/news/cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands", "canonical_source": "https://github.com/rtk-ai/rtk", "published_at": "2026-11-06 19:00:44+00:00", "updated_at": "2026-11-06 19:20:42.545318+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "ai-infrastructure"], "entities": ["RTK", "rtk-ai", "rtk-oss", "rtk-proxy", "Rust", "crates.io", "Angular"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands", "markdown": "https://wpnews.pro/news/cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands.md", "text": "https://wpnews.pro/news/cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands.txt", "jsonld": "https://wpnews.pro/news/cli-proxy-that-reduces-llm-token-consumption-by-60-90-on-dev-commands.jsonld"}}