Back to Explore

rtk-ai/rtk

Rust8,617464231 issues36 contributorsMIT
View on GitHub

Summary

rtk (Rust Token Killer) is a CLI proxy that intercepts shell commands run by LLM coding agents (primarily Claude Code) and compresses their output before it reaches the LLM context window. It does this via a bash hook injected into Claude Code's PreToolUse settings, transparently rewriting commands like 'git status' to 'rtk git status' which filters, truncates, and deduplicates output. It also has a TOML-driven filter system for arbitrary commands and tracks actual token savings in a local SQLite database.

Great for

Great for people interested in LLM context optimization, building tools that sit between shell environments and AI coding agents, or Rust systems programming involving process spawning, output parsing, and structured filtering pipelines.

Easy wins

  • +Add a new TOML filter for an unsupported tool (e.g. any of the 40+ .toml files in src/filters/ are self-contained templates — adding 'make', 'ansible-playbook', etc. requires only TOML, no Rust)
  • +The discover/registry.rs command rewriter has edge cases with environment variable prefixes and compound commands — writing targeted tests for split_command_chain() and rewrite_compound() would be immediately useful given the 231 open issues
  • +src/cargo_cmd.rs filter_cargo_nextest() hardcodes a 15-failure cap with no config override — making this configurable via config.toml would be a clean, bounded Rust contribution
  • +Several *_cmd.rs files duplicate the same 'run command, capture stdout+stderr, filter, track' pattern — a contribution extracting this into a shared runner abstraction would reduce ~2000 lines of boilerplate

Red flags

  • !commit_count: 1 and contributor_count: 1 in the metadata strongly suggests this is a single-author project despite showing 36 contributors in the static profile — the actual development bus factor appears to be 1, which matters for long-term maintenance of 8600-star project
  • !The README token savings table is labeled 'Estimates based on medium-sized TypeScript/Rust projects' but the numbers (e.g. 'git add/commit/push -92%') are suspiciously round and appear to be manually written targets rather than measured benchmarks — scripts/benchmark.sh exists but it's unclear if the README numbers come from it
  • !telemetry.rs exists and Cargo.toml includes ureq (HTTP client) and hostname crates — the tracking.md in docs/ should be reviewed; opt-out behavior and what's actually transmitted is not prominently disclosed in README
  • !The install script uses 'curl | sh' pattern without checksum verification by default, though the integrity.rs module does SHA-256 verification of the hook file post-install

Code quality

decent

The code is functional and idiomatic Rust with consistent use of anyhow for error propagation and OnceLock for lazy regex compilation. However, there's significant duplication — every *_cmd.rs file independently reimplements the same execute-filter-track-exit pattern that run_cargo_filtered() in cargo_cmd.rs hints at solving but only applies to cargo. The git.rs compact_diff() function has a logic issue: context lines are only added when hunk_lines > 0, which means the first context line of every hunk is silently dropped. The tee.rs failure-recovery feature (saving raw output on failure) is well-designed with good separation. No obviously insecure patterns — SQLite is local only, no network calls except optional telemetry via ureq.

What makes it unique

The core idea — a transparent CLI proxy that compresses tool output for LLM context windows — is genuinely novel and practically useful, distinct from prompt compression or summarization approaches. The TOML filter registry makes it extensible without recompilation. The closest analogs would be custom Claude Code hooks people write themselves, but rtk productizes this with 50+ command-specific filters. The 'discover' subsystem that analyzes past Claude Code sessions to identify missed rtk usage opportunities is a particularly clever differentiator.

Scores

Collab
10
Activity
8

Barrier to entry

low

New filters can be added as TOML files in src/filters/ with no Rust required, there are 3 tagged 'good first issue' issues, the architecture is straightforward (each command gets its own *_cmd.rs module), and CLAUDE.md gives explicit dev commands.

Skills needed

Rust (intermediate — pattern matching, error handling with anyhow, process::Command, OnceLock/lazy_static)Understanding of CLI tool output formats (git, cargo, pytest, docker, etc.)Regex pattern writing for command classification (src/discover/rules.rs pattern)TOML for adding new filter definitions (src/filters/*.toml)Shell scripting (bash hook in hooks/rtk-rewrite.sh)