Skip to content

discover undercounts RTK adoption when commands are rewritten via PreToolUse hook #1643

Closed

Description

@kitsuya0720-debug

Problem

The PreToolUse rtk-rewrite.sh hook (used in Claude Code setups per the project's RTK.md) transparently rewrites raw commands before execution — e.g. grep -n → rtk grep -n, ls -la → rtk ls -la.

However, rtk discover still counts the pre-rewrite form as "missed savings", which inflates the missed-savings figure even when the hook is actively rewriting every invocation.

Repro

  1. Enable the rewrite hook (PreToolUse → rtk-rewrite.sh)
  2. Run a normal session — every grep -n, ls -la, tail -n etc. is rewritten transparently
  3. rtk discover -a -s 1

Observed: report shows ~40K tokens of "missed savings" attributed to commands like grep -n, ls -la, tail -n, despite the hook handling them.

Suggested fix

Detect hook-rewritten invocations so adoption rate reflects actual RTK usage, not the user's typed form. Possible markers:

  • Env var set by the rewrite hook (e.g. RTK_REWRITTEN=1)
  • Parent process / argv inspection in the rewrite path
  • Sentinel comment/argument injected by the hook

Without this, rtk discover over-reports opportunity and under-reports adoption — making the metric unusable for tracking real RTK uptake.

Activity

  1. added
    bug
    effort-medium
    filter-quality
    on Apr 30, 2026
  2. pszymkowiak commented on Apr 30, 2026

    @pszymkowiak
    Collaborator

    Closing as duplicate of #2036. See the original issue for updates.

  3. added
    duplicate
    on May 27, 2026
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:clibugduplicateeffort-mediumfilter-qualitypriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions