Overview
Thertk gain command provides comprehensive analytics for tracking your token savings across time periods. View summary statistics, analyze trends with daily/weekly/monthly breakdowns, and export data for external dashboards.
Database Location: ~/.local/share/rtk/history.dbRetention Policy: 90 days automatic cleanup
Scope: Global across all projects, worktrees, and Claude sessions
For programmatic access to tracking data (Rust API, CI/CD integration, custom dashboards), see Tracking Architecture.
Quick Reference
Command Options
Temporal Flags
flag
Day-by-day breakdown showing all recorded days with full metrics
flag
Week-by-week breakdown aggregated by Sunday-Saturday weeks
flag
Month-by-month breakdown aggregated by calendar month
flag
Show all time breakdowns (daily + weekly + monthly) combined
Classic Flags
flag
ASCII graph of last 30 days of savings
flag
Recent 10 commands with timestamps and savings percentages
flag
Monthly quota analysis comparing savings to subscription tier limits
string
default:"20x"
Quota tier:
pro, 5x, or 20x (default: 20x)Export Formats
string
default:"text"
Output format:
text (terminal display), json (APIs), or csv (Excel/analysis)Output Examples
Default Summary View
- Commands: Number of rtk commands executed
- Input: Estimated tokens from raw command output
- Output: Actual tokens after rtk filtering
- Saved: Input - Output (tokens prevented from reaching LLM)
- Save%: Percentage reduction
(Saved / Input) × 100 - Time: Total execution time across all runs
- Impact: Visual bar showing relative token savings
Daily Breakdown
Weekly Breakdown
Monthly Breakdown
YYYY-MM (calendar month)
JSON Export
- API integration
- Custom dashboards
- Automated reporting
- Data pipeline ingestion
CSV Export
- Excel analysis
- Python/R data science
- Google Sheets dashboards
- Matplotlib/seaborn plotting
Understanding Token Savings
Token Estimation
RTK estimates tokens usingtext.len() / 4 (4 characters per token average).
Accuracy: ±10% compared to actual LLM tokenization (sufficient for trends).
Savings Calculation
Typical Savings by Command
| Command | Typical Savings | Mechanism | |---------|----------------|-----------|| |rtk git status | 77-93% | Compact stat format |
| rtk vitest run | 94-99% | Show failures only |
| rtk lint | 84% | Group by rule |
| rtk tsc | 83% | Group by file/error code |
| rtk pnpm list | 70-90% | Compact dependencies |
| rtk grep | 70% | Truncate + group |
Analysis Workflows
Weekly Progress Tracking
Monthly Cost Analysis
Data Science Analysis
Excel Analysis
- Export CSV:
rtk gain --all --format csv > rtk-data.csv - Open in Excel
- Create pivot tables:
- Daily trends (line chart)
- Weekly totals (bar chart)
- Savings % distribution (histogram)
Dashboard Creation
Database Management
Inspect Raw Data
Backup & Restore
Cleanup
Integration Examples
GitHub Actions CI/CD
Slack Bot
Troubleshooting
No data showing
Export fails
Incorrect statistics
Token estimation is a heuristic. For precise measurements:Best Practices
- Regular Exports:
rtk gain --all --format json > monthly-$(date +%Y%m).json - Trend Analysis: Compare week-over-week savings to identify optimization opportunities
- Command Profiling: Use
--historyto see which commands save the most - Backup Before Cleanup: Always backup before manual database operations
- CI Integration: Track savings across team in shared dashboards
See Also
Discover Command
Find missed savings opportunities by scanning Claude Code session history
Tracking Architecture
SQLite-based tracking system and programmatic access API
