Skip to main content

Overview

Analyzes Claude Code session files (JSONL format) to identify commands that could have used RTK but didn’t. Shows estimated token savings and suggests RTK alternatives.

Syntax

Options

string
Filter by project path (substring match). If not specified and --all is not used, defaults to current working directory.
flag
Scan all projects (no filtering by path)
number
default:"30"
Limit scan to sessions from last N days
number
default:"15"
Max commands per section in text output
string
default:"text"
Output format:
  • text - Human-readable report
  • json - Machine-readable JSON

Session Discovery

RTK scans Claude Code session files:
  • Location: ~/.claude/sessions/*.jsonl (or OS-specific path)
  • Format: Newline-delimited JSON (JSONL)
  • Filtering: By project path (encoded in session filename)

Command Classification

Supported Commands

Commands RTK can optimize, grouped by category: Git (59-80% savings)
  • git status, git log, git diff, git show
  • git add, git commit, git push, git pull
  • git branch, git fetch, git stash, git worktree
Build (80-90% savings)
  • cargo build, cargo check, cargo clippy
  • tsc, next build, pnpm build
Test (90-99% savings)
  • cargo test, cargo nextest
  • vitest run, playwright test
  • pytest, go test
Lint (80-85% savings)
  • eslint, ruff check, pylint, mypy
  • prettier --check, cargo clippy
Package Managers (70-90% savings)
  • pnpm list, pnpm outdated, pnpm install
  • npm run, pip list
Files & Search (60-75% savings)
  • ls, grep, find, cat/read
Infrastructure (85% savings)
  • docker ps, docker images, docker logs
  • kubectl get, kubectl logs
Network (65-70% savings)
  • curl, wget

Unsupported Commands

Commands not yet supported by RTK (feature requests welcome):
  • Custom scripts
  • Uncommon build tools
  • Database CLIs (non-psql)
  • Vendor-specific tools

Ignored Commands

Automatically excluded from analysis:
  • Commands already using RTK (rtk ...)
  • Text editors (vim, nano, code)
  • Interactive shells (bash, zsh)
  • CD operations (cd ...)

Output Format

Text Report

JSON Format

RTK Status Indicators

✅ Existing - RTK already supports this command with optimized filter 🔄 Passthrough - RTK supports the base command but no specialized filter (0% savings, usage tracked) ❌ Not Supported - Command not recognized by RTK (feature request needed)

Token Estimation

For each command, RTK estimates savings using:
  1. Real output length (from session tool_result.content if available)
  2. Category averages (fallback based on command type)
  3. Historical savings % (from category benchmarks)
Estimates are heuristic-based and may vary from actual savings.

Use Cases

Audit Current Workflow

Analyze All Projects

Recent Sessions Only

Specific Project

Export for Analysis

Privacy & Data

RTK discover only analyzes:
  • Command names and arguments (from Bash tool calls)
  • Output lengths (for token estimation)
  • Session timestamps and project paths
Not analyzed:
  • Message content (user/assistant text)
  • File contents
  • API responses
  • Personal data
All analysis is local - no data sent to external services.

Exit Codes

  • 0 - Success
  • 1 - Session directory not found or no sessions
  • rtk gain - View actual token savings from RTK usage
  • rtk init - Install RTK hook for automatic command rewriting
  • rtk learn - Analyze error corrections in Claude Code history