RTK Token Optimizer

•
1
•

Reduces Claude Code token consumption by 60-90% through intelligent command output compression and filtering.

RTK is a performance-focused proxy for Claude Code that transparently intercepts Bash commands to minimize token usage. By filtering redundant data from Git status, Docker logs, test runners, and file operations via a PreToolUse hook, it allows developers to stay within rate limits and reduce costs without changing their workflow. The skill operates automatically in the background while providing detailed analytics via command-line tools to track token savings, project discovery, and monthly quota usage.

Key Features

01Transparently intercepts Bash commands via PreToolUse hooks
02Reduces token consumption by up to 90% for test outputs and file reads
03Ultra-compact mode for aggressive output reduction
041 GitHub stars
05Supports intelligent filtering for Git, Docker, Kubernetes, and test runners
06Provides detailed savings analytics and monthly quota tracking

Use Cases

01Extending daily AI rate limits by minimizing the payload of every command execution
02Managing large monorepos where standard Git commands consume excessive tokens
03Optimizing long test runner outputs to focus Claude's attention only on failures
name rtk
description RTK token optimization proxy. Transparent via PreToolUse hook. Use this skill to check token savings, troubleshoot hook issues, or manually optimize specific commands.
metadata
context auto-trigger
rtk, token, optimization, proxy
false

RTK - Token Optimization Proxy

Overview

RTK transparently intercepts Bash commands via a PreToolUse hook, filtering and compressing output to reduce LLM token consumption by 60-90%. No manual intervention needed for daily use.

How It Works

Claude Code: git status
  -> Hook rewrites to: rtk git status
  -> RTK executes git status, filters output
  -> Claude receives compact output (~75% fewer tokens)

Token Savings Check

rtk gain                    # Summary stats
rtk gain --graph            # ASCII graph (last 30 days)
rtk gain --history          # With recent command history
rtk gain --quota --tier 20x # Monthly quota analysis (pro/5x/20x)
rtk gain --daily            # Daily breakdown
rtk gain --all              # All breakdowns combined
rtk gain --all --format json # JSON export

Project Discovery

rtk discover                # Current project stats
rtk discover --all          # All Claude Code projects
rtk discover --all --since 7 # Last 7 days

Manual Usage (when needed)

# File operations
rtk ls .                    # Compact directory tree (-80%)
rtk read file.rs            # Smart file reading (-70%)
rtk read file.rs -l aggressive # Signatures only (strips bodies)
rtk grep "pattern" .        # Grouped search results (-80%)
rtk json config.json        # Structure without values

# Git operations
rtk git status              # Compact status (-75%)
rtk git log -n 10           # One-line commits
rtk git diff                # Condensed diff

# Test output
rtk cargo test              # Failures only (-90%)
rtk vitest run              # Failures only (-99%)
rtk pytest                  # Failures only (-90%)
rtk go test ./...           # NDJSON format (-90%)

# Error filtering
rtk err npm run build       # Errors/warnings only
rtk tsc                     # Grouped by file
rtk lint                    # Grouped by rule

# Docker/K8s
rtk docker ps               # Compact (-80%)
rtk kubectl get pods         # Compact (-80%)

Troubleshooting

Problem Solution
Hook not working Restart Claude Code
Wrong rtk package rtk gain should work; if not, brew reinstall rtk
Check hook status rtk init --show
Full uninstall rtk init -g --uninstall
Full output needed Check ~/.local/share/rtk/tee/ for unfiltered logs

Configuration

# Config file location
~/.config/rtk/config.toml

# Hook files
~/.claude/hooks/rtk-rewrite.sh   # Hook script
~/.claude/RTK.md                 # Slim reference
~/.local/share/rtk/history.db    # Tracking DB

Global Flags

rtk -u <cmd>    # Ultra-compact mode (extra savings)
rtk -v <cmd>    # Verbose output