Skip to content

Add wrappers for top unhandled commands: node, ssh, bun run, python, cat heredoc #1802

Open

Description

@qrisr

Context

Running rtk discover on a real-world Claude Code session history (1277 sessions, 5255 Bash commands, last 30 days) reveals significant token-savings potential in commands RTK does not yet handle.

Top unhandled commands (by frequency)

Command Count (30d) Example
node 132 node dev-server.mjs
open 117 open "/path/to/file"
ssh 79 ssh -o StrictHostKeyChecking=no host 'cmd'
pkill 34 pkill -f "swift /tmp/find_videos"
ln 32 ln -s /src /dst
bun run 29 bun run dev
cat <<EOF 29 heredoc-style file creation
python / python3 39 python -m playwright install chromium
vercel 21 vercel --version

Estimated savings

rtk discover estimates ~50K additional tokens/month if these commands had RTK-equivalents (filtering output, suppressing progress bars, compacting JSON, etc.).

Suggested wrappers

  • rtk node <script> — strip experimental warnings, dotenv noise, deprecation notices
  • rtk ssh <host> <cmd> — same output filtering as rtk would apply locally to the remote command
  • rtk bun run <task> — strip bundler progress + bun-internal noise
  • rtk python / rtk python3 — filter pip install progress, virtualenv warnings
  • rtk pkill / rtk ln / rtk open — even minimal compacting helps when called frequently

Why this matters

Even at the current ~1-2% adoption rate of RTK in mixed sessions, these top-9 unhandled commands account for roughly 5x the savings of all currently-handled commands combined for this user's profile. Users who do a lot of dev-server / SSH-driven workflows would benefit disproportionately.

Reproducing the data

Anyone with active RTK + Claude Code can reproduce:

rtk discover

The "TOP UNHANDLED COMMANDS" section is the input for prioritisation.

Activity

  1. LuisEduardo100 commented on May 14, 2026

    @LuisEduardo100

    +1 — data from another real-world session (2486 sessions, 21759 Bash commands, last 30 days, RTK 0.39.0):

    Top unhandled commands (this user)

    Command Count (30d) Example
    ssh 965 ssh -o BatchMode=yes -o StrictHostKeyChecking=no host …
    node 890 node diag_today_leads.js
    ssh kvm2 339 ssh kvm2 'docker ps --format "{{.Names}}…"'
    sshpass 202 sshpass -p '***' ssh user@host …
    python3 114 python3 /home/.../script.py
    pnpm (passthrough) 114 pnpm --filter @scope/pkg test
    git checkout 78 git checkout --theirs pnpm-lock.yaml
    git merge 77 git merge --no-ff -X theirs branch
    git rev-parse 56 git rev-parse HEAD
    docker compose 56 docker compose version

    Notes specific to this profile

    • SSH dominates (~1500 calls/month including sshpass + ssh kvm2). A heavy infra/ops workflow — the existing Add wrappers for top unhandled commands: node, ssh, bun run, python, cat heredoc #1802 proposal for rtk ssh <host> <cmd> would land hard here, especially if it can apply RTK rewrites to the remote command (e.g. ssh host 'rtk docker ps').
    • git rev-parse / git merge / git checkout show up because rtk git currently only covers a subset of subcommands — passthrough-with-filtering for the rest would help (feat(discover): track passthrough git/cargo/pnpm subcommands #888 territory).
    • docker compose (vs docker-compose) is the modern form — rtk docker apparently doesn't match the two-word subcommand yet.
    • Heredoc / multi-line continuations (\<newline>echo, \<newline>git clone, for f; do node…) showed up 200+ times — these slip past the hook entirely because they aren't recognised as single rewritable commands. Probably out of scope for this issue but worth flagging.

    Hook adoption note

    Re #1643: same artefact here. rtk discover reports 0.1% adoption because the hook was installed mid-window (2 days before running discover). Post-hook rtk gain shows 46% efficiency on 23 281 commands. The "1.5M tokens saveable" number is mostly pre-hook traffic.

    Happy to share more raw breakdowns if useful.

  2. Jochiej commented on May 27, 2026

    @Jochiej

    Additional data — heavier-user sample (4x larger)

    Reproduced rtk discover on a larger sample (rtk 0.39.0, last 30d):

    Scanned: 605 sessions, 20471 Bash commands
    Already using RTK: 5468 commands (26.7%)
    Total saveable on existing filters: ~647K tokens
    

    The "TOP UNHANDLED" list shows two high-frequency commands not in the original wishlist:

    Command Count (30d) Example
    timeout 213 (95+69+49 across 60/30/120) timeout 60 node --test scripts/__tests/...
    dig +short 82 dig +short webmail.example.com A

    Suggested wrappers

    • rtk timeout <secs> <cmd> — pass-through to inner command but route its output through whatever rtk filter matches (e.g. timeout 60 node script.js → effectively timeout 60 rtk node script.js). Today the outer timeout blocks any rewrite of the inner command.
    • rtk dig <args> — strip the verbose default output (HEADER, QUESTION, ANSWER sections, stats) when +short isn't used; pass through cleanly when +short is present. Heavily used in DNS / hosting workflows.

    Why timeout matters disproportionately

    It's effectively a rewrite-blocker for many tests/dev-server invocations. In this dataset, ~213 timeout-wrapped commands wrap node, npx jest, npx playwright — none of which currently benefit from RTK filtering because the outer command isn't detected as a known wrapper.

    Other observations from this sample

    • docker compose (161×) — rewrites correctly to rtk docker compose via the hook, but the resulting rtk docker compose <subcmd> sometimes errors with no configuration file provided when run outside a project dir. Probably benign, but worth a sanity check that rtk docker compose is a real first-class subcommand and not just an unintended pass-through.
  3. Jochiej commented on May 27, 2026

    @Jochiej

    Follow-up: transparent_prefixes (0.40) doesn't help with the biggest offender

    Configured [hooks].transparent_prefixes on 0.42.0 and tested each candidate:

    Prefix Rewrite working?
    env, env VAR=val ✅
    nice (no args) ✅
    nice -n 10 ❌
    time ✅
    nohup ✅
    stdbuf -i0 ❌
    timeout 60 / gtimeout 30 ❌

    The parser appears to stop at the first prefix-arg that is numeric or flag-style (-n 10, -i0). The biggest real-world offender — timeout <secs> <cmd> — therefore can't benefit from transparent_prefixes. Same for nice -n N and stdbuf -iN.

    Reproduction:

    $ rtk rewrite "timeout 60 grep -n foo /tmp/x"
    # exit 1, no output (no rewrite)
    
    $ rtk rewrite "env DEBUG=1 grep -n foo /tmp/x"
    # exit 3: env DEBUG=1 rtk grep -n foo /tmp/x  ✓

    Suggested fix: the transparent-prefix parser should consume known numeric/flag arguments per prefix (e.g. timeout <DURATION>, gtimeout <DURATION>, nice [-n <N>], stdbuf [-iN] [-oN] [-eN]) before looking for the inner command. Could be a static per-prefix arg-grammar or a more permissive "skip until a token that looks like a known command" heuristic.

    Until then, timeout-wrapped commands stay invisible to RTK — and timeout is by far the highest-frequency wrapper in dev-server / test workflows.

  4. added
    enhancement
    help wanted
    on May 27, 2026
  5. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟡 Priority medium
    🎯 Confidence 87%

    Summary

    Feature request to add RTK wrappers for high-frequency unhandled commands (node, ssh, bun run, python, etc.) backed by real usage data showing ~50K token/month savings potential; partially overlaps with #2073.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  6. guillaumejay commented on Jul 4, 2026

    @guillaumejay

    Same pattern here: cat > /tmp/pr-body.md <<'EOF' ... EOF — 14 occurrences/30d in a separate rtk discover scan, mainly building PR/commit message bodies before gh pr create / git commit -F.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clienhancementhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions