[FEATURE] Cheaper auto-mode re-check for Bash commands rewritten by a PreToolUse hook

Status Open
Reported on v2.1.287
Maintainer reply None cached
Activity 0 comments · opened Oct 15, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Since 2.1.287, when a PreToolUse hook rewrites a Bash command with updatedInput, auto mode re-checks that call with Claude Code's local classifier instead of the server-side one. Each request is about 149K characters (sys=149300, user=121 in the 2.1.300 debug log), and the first classifier stage took 2.2 to 2.6 seconds in my minimal repro.

Hooks that rewrite most Bash calls pay this on nearly every command. rtk (https://github.com/rtk-ai/rtk) is one. It rewrites git status into rtk git status to shrink tool output. I removed it because I couldn't see what the re-checks cost (bug: https://github.com/anthropics/claude-code/issues/102469).

I understand why a rewrite needs a check. A hook can turn a harmless command into a harmful one, and the 2.1.290 changelog records that fix.

Proposed Solution

I don't know the classifier's internals, so this is a question more than a design: could a rewrite be checked with a smaller classifier request? For example, one that includes the original command, the rewritten one and the hook's declared purpose, rather than the full ~149K-character prompt. It would still be a real check, since a prefix like rtk runs a different binary than the original command.

Alternative Solutions

  • A user-settings hook could declare a narrow, fixed rewrite, for example "prefix the command with rtk ". Claude Code could confirm the rewritten command matches that pattern and then use the smaller check above.
  • Today's workaround is to remove the hook and have the model type rtk prefixes itself. In my sessions the model rarely types the prefix, so most of rtk's benefit is lost.

Priority

Medium - Would be very helpful

Feature Category

Performance and speed

Use Case Example

  1. A user installs rtk's PreToolUse hook to cut Bash output tokens.
  2. In auto mode, the model runs git status. The hook rewrites it to rtk git status.
  3. Today, that call goes to the local classifier with a ~149K-character request.
  4. With a smaller check for a declared prefix rewrite, Claude Code confirms that the new command is rtk plus the original and judges that pair without the full ~149K-character prompt.

Additional Context

Bisect: 2.1.286 sent no local classifier requests for rewritten calls. 2.1.287 through 2.1.300 send one per rewritten call in my probes.

View original on GitHub ↗