rtk-ai / rtk-ai/rtk

Claude Code native tools bypass RTK hook — majority of token-heavy ops never reach Bash

Open
#538 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli bug effort-large enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

Problem

RTK's Claude Code hook intercepts only the Bash tool, but Claude Code has built-in native tools (Read, Grep, Glob, Edit, Write) that handle the majority of file and search operations without ever touching Bash.

Claude Code's system prompt explicitly instructs:

"Do NOT use the Bash to run commands when a relevant dedicated tool is provided."

  • Read files → Read tool (not cat/head/tail)
  • Search content → Grep tool (not grep/rg)
  • Find files → Glob tool (not find/ls)
  • Edit files → Edit tool (not sed/awk)

This means ~60% of the commands RTK is designed to compress (cat, grep, find, ls) never reach the Bash tool and are invisible to the RTK hook.

Evidence

On a real system with RTK 0.28.2 properly installed (hook v2, settings.json configured, RTK.md referenced):

  • rtk discover reports 6,302 Bash commands in 7 days and claims 248K tokens saveable
  • But rtk gain shows only 4 commands ever processed by RTK
  • The hook was installed and working correctly — the gap is because rtk discover scans Claude's JSONL logs and cannot distinguish between Bash tool calls and native tool calls, so it overestimates saveable tokens
Architecture mismatch
Claude Code Tool Routing:
┌─────────────┐
│  Read tool   │──→ direct file read (no Bash, no hook, no RTK)
│  Grep tool   │──→ direct ripgrep  (no Bash, no hook, no RTK)
│  Glob tool   │──→ direct glob     (no Bash, no hook, no RTK)
│  Edit tool   │──→ direct edit     (no Bash, no hook, no RTK)
│  Bash tool   │──→ hook fires ──→ RTK rewrites ✅
└─────────────┘

Impact

  • RTK's headline claim of "80% savings across ~118K tokens per session" is significantly overstated for Claude Code users
  • rtk discover gives misleading savings estimates because it counts native tool usage as "missed Bash commands"
  • Users install RTK expecting large savings but see minimal impact, leading to confusion

What RTK still helps with (Bash-only commands)

  • git operations (status, diff, log, add, commit, push)
  • gh CLI (pr, issue, run)
  • npm run build/test, cargo test/build
  • docker commands
  • curl, ssh

These are real savings, but a fraction of the advertised total.

Suggestions

  1. rtk discover accuracy: Filter out or flag commands that likely used native tools (Read/Grep/Glob) rather than Bash, so savings estimates are realistic
  2. Hook non-Bash tools: Investigate intercepting Read, Grep, Glob tool calls via the PreToolUse hook to compress their outputs (different matcher + updatedInput schema)
  3. Documentation: Clarify that Claude Code's native tools bypass RTK, and set realistic expectations for savings (git/gh/build/test commands only)
  4. rtk gain context: Show estimated "reachable" vs "unreachable" commands so users understand why savings are lower than rtk discover suggests

Environment

  • RTK 0.28.2 (Homebrew, macOS)
  • Claude Code with Opus model
  • Hook v2 (thin delegator), correctly installed and verified working

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy between rtk discover and rtk gain using the reported Claude Code hook setup, then inspect the PreToolUse routing for Bash and native tools. Done means the reachable and unreachable command estimates are accurately distinguished, with the relevant Claude Code limitations documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.