rtk-ai/rtk

Add statistics and sorting options to the `rtk gain` 'By Command' table

Open

#1,700 opened on May 4, 2026

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (2,914 forks)batch import
area:clienhancementhelp wantedpriority:low

Repository metrics

Stars
 (48,085 stars)
PR merge metrics
 (Avg merge 11d 1h) (45 merged PRs in 30d)

Description

Example:

$ rtk gain
RTK Token Savings (Global Scope)
════════════════════════════════════════════════════════════

Total commands:    11969
Input tokens:      8.3M
Output tokens:     2.6M
Tokens saved:      5.7M (68.7%)
Total exec time:   1408m12s (avg 7.1s)
Efficiency meter: ████████████████░░░░░░░░ 68.7%

By Command
────────────────────────────────────────────────────────────────────────
  #  Command                   Count   Saved    Avg%    Time  Impact
────────────────────────────────────────────────────────────────────────
 1.  rtk:toml xcodebuild t...      1  560.3K   99.8%   4m54s  ██████████
 2.  rtk:toml xcodebuild t...      1  518.7K   99.8%   5m41s  █████████░
 3.  rtk:toml ps -ef               8  451.5K   98.9%   166ms  ████████░░
 4.  rtk:toml ps -axo pid,...      7  347.8K   99.2%    79ms  ██████░░░░
 5.  rtk:toml ps -ax               5  283.4K   99.1%    98ms  █████░░░░░
 6.  rtk:toml ps -axo pid,...      5  237.3K   99.2%   172ms  ████░░░░░░
 7.  rtk:toml ps -axo pid,...      4  212.4K   99.1%    65ms  ████░░░░░░
 8.  rtk:toml ps -Ao pid,p...      4  197.9K   99.0%    50ms  ████░░░░░░
 9.  rtk git diff main...H...      2  183.6K   92.3%   287ms  ███░░░░░░░
10.  rtk:toml ps aux               2  163.8K   98.9%   162ms  ███░░░░░░░
────────────────────────────────────────────────────────────────────────

Note the 11.9K Total commands statistic above the table, the Count column in the table (few invocations), the 5.7M tokens saved statistic above the table and note the Saved column sums to over 3M tokens saved. This is a significant statistic for some rarely used commands that my LLM agents happened to invoke. However, my usage of RTK is much greater: 11.9K total commands. Most will have much less impact, but I'd like to see those so I can tune these commands to output less, or improve RTK's filters and command support to improve the impact further.

The feature request is to sort by different statistics, or even combined ones. E.g. the Impact column is nice, but what is impact in the first place? If I run a few command 10k times and it only saves a few tokens every time, wouldn't those be great candidates to somehow surface in a table? E.g. multiply 'tokens saved on average per invocation' (or some inverse) by invocation count, which could be called the 'potential' statistic. Or just sort by count to surface the volume commands.

By extension, this would go well with a filtering option to include or exclude certain command. E.g. I suspect there would be a lot of git status calls in the top N, but e.g. I personally run a lot of Gradle builds that I'd like to filter on, because I know they can be verbose (shoutout to https://github.com/rtk-ai/rtk/issues/1178 and https://github.com/rtk-ai/rtk/issues/1177).

Also, the table could be much longer. Why not let the user show all commands (ideally in a paging table)? Or a top N?

Contributor guide