Overview
Thertk discover command scans your Claude Code session history (stored as JSONL files) to find commands where RTK would have saved tokens but wasn’t used. It helps you:
- Measure what you’re missing — see exactly how many tokens you could save
- Identify habits — find which commands you keep running without rtk
- Spot new opportunities — see unhandled commands that could become rtk features
rtk discover is read-only and never modifies your Claude Code session files. It only analyzes JSONL logs to identify potential savings.Quick Start
Command Options
flag
Scan all Claude Code projects instead of just the current working directory
integer
default:"30"
Number of days to look back in session history (default: 30 days)
string
Filter sessions by project name (substring match on directory name)
string
default:"text"
Output format:
text (human-readable) or json (machine-readable)flag
Show verbose output including session file paths and parse errors
How It Works
Session Discovery
-
Project Directory Resolution
- Default: Current working directory →
~/.claude/projects/-path-to-current-dir/ --all: All directories in~/.claude/projects/-p <name>: Substring match on project directory names
- Default: Current working directory →
-
JSONL File Scanning
- Recursively walks project directories (includes
subagents/subdirectories) - Filters by modification time (last N days via
--since) - Parses JSONL session logs for
Bashtool use events
- Recursively walks project directories (includes
-
Command Classification
- Extracts
Bashcommands fromtool_useblocks - Matches against RTK’s internal command registry
- Estimates token savings based on
tool_resultoutput lengths
- Extracts
Classification Categories
- Supported
- Unsupported
- Ignored
Commands RTK already handles with dedicated filters:
- Git:
git status,git diff,git log, etc. - Cargo:
cargo test,cargo build,cargo clippy - JavaScript:
tsc,eslint,prettier,vitest,playwright - Files:
cat,grep,rg,ls,find - Infra:
docker ps,kubectl get
rtk <cmd>.Output Examples
Text Format (Default)
- Header: Sessions scanned, total Bash commands found, RTK usage rate
- Missed Savings: Commands RTK handles but you didn’t use (sorted by estimated savings)
- Top Unhandled: Commands RTK doesn’t support yet (sorted by frequency)
Status Column
JSON Format
Token Estimation
How Savings Are Calculated
Savings Percentages by Command
Use Cases
Weekly Habit Check
Project-Specific Analysis
Feature Request Prioritization
Team Adoption Metrics
Advanced Usage
Filter by Project Substring
Verbose Output
Combine with rtk gain
Troubleshooting
No sessions found
Low command counts
Parse errors
Zero savings shown
Privacy & Security
Command Registry
rtk discover uses the same command classification engine as the RTK hook. The registry includes:
- Git
- Cargo
- JavaScript/TypeScript
- Python
- Go
- Files
- Infra
- Network
- GitHub
- Package Managers
git status,log,diff,show,add,commit,push,pull,branch,fetch,stash,worktree- Savings: 59-80% depending on subcommand
Best Practices
- Run Weekly:
rtk discover --since 7to catch habit changes - Install Hook: If you see high missed savings, install the RTK hook with
rtk init -g - Track Adoption: Use
--format jsonto track adoption rate over time - Feature Requests: Export unsupported commands and open GitHub issues for top candidates
- Project-Specific: Use
-pto analyze individual projects before rolling out RTK team-wide
See Also
rtk gain Command
View actual token savings over time with temporal breakdowns
RTK Hook
Automatic command rewriting for 100% RTK adoption
