Hook doesn't auto-route `mvn` / `mvnw` despite handler existing
#1537 opened on Apr 26, 2026
Description
Summary
In RTK 0.37.2, the mvn handler exists and works (rtk discover confirms it as existing for mvn compile), but rtk hook check returns "No rewrite for: ..." for every mvn/mvnw/./mvnw invocation. Net result: typing mvn test in Claude Code's Bash tool runs unfiltered, even though the maven TOML filter shipped via #338 / #147 / PRs #349/#351/#386.
Reproduction
Environment: rtk 0.37.2 (Linux WSL2), Claude Code session with hook installed via rtk init -g.
$ rtk --version
rtk 0.37.2
$ rtk hook check "mvn test"
No rewrite for: mvn test
$ rtk hook check "mvnw test"
No rewrite for: mvnw test
$ rtk hook check "./mvnw test"
No rewrite for: ./mvnw test
# But the handler itself works:
$ rtk mvn --help
usage: mvn [options] [<goal(s)>] [<phase(s)>]
...
$ rtk discover | grep -i mvn
mvn compile 21 rtk mvn existing ~2.6K tokens
Impact
In a Spring Boot / Maven project running 30 days of rtk discover analysis:
mvnw 109 ./mvnw -q -pl . -Dtest=DocumentGenerat..
mvn 59 mvn -B -q -ntp test -Dtest='TrialToPai..
mvn test 50 mvn test -Dtest=DocumentBrandingAssemb..
mvnw test 27 ./mvnw test -Dtest=CacheStampedeFanOut..
mvnw checkstyle:check 25 MAVEN_OPTS="-Xmx1g" ./mvnw checkstyle:..
≈ 270 invocations × significant verbose output per mvn test (Surefire stack traces, [INFO] noise) = large token bleed despite the TOML filter being a fix-away from working.
Proposed approach (not prescribing)
Add mvn and mvnw (and the common ./mvnw invocation) to the hook routing whitelist (per the hook_lookup() design described in #361 / PR #156). Conservative subcommand inclusion:
mvn test,mvn compile,mvn package,mvn clean,mvn install,mvn verify,mvn checkstyle:check- Same for
mvnwand./mvnwinvocations - Skip non-maven
mvn-prefixed binaries if any exist (none common)
For mvn test Surefire output specifically, PR #288 (mentioned in #338 follow-up) covers the state-machine parser — independent of this routing fix.
Related
- #338 (Maven feature request — closed completed by TOML filter)
- #147 (Java/Kotlin/Spring Boot/Maven — closed completed by v0.30.0)
- #361 / PR #156 (hook engine v2 with
hook_lookup()whitelist — this issue may be subsumed if #156 lands and includes mvn) - #1526 (similar hook routing gap for
git ls-files/git rm/git tag— same shape of issue, different command family)
Environment
- rtk: 0.37.2 (binary from
~/.local/bin/rtk, build-idc7c6664f) - Hook:
~/.claude/settings.jsonPreToolUse Bash matcher →rtk hook claude - Claude Code with autorun-style usage; Maven project (Spring Boot 3.x, kitehub-subscription / kitehub-branding modules)