Repository navigation
Description
Observed with: rtk 0.42.3, Claude Code 2.1.169 (PreToolUse hook with updatedInput).
Summary
The rtk hook claude PreToolUse hook auto-rewrites recognized commands to their rtk handler (git status → rtk git status, vitest run → rtk vitest, pnpm exec vitest → rtk vitest). But it does not route package-manager script runs such as:
pnpm verify:fast/pnpm verify:fullpnpm --filter <pkg> test/pnpm test-allpnpm typecheck-all/pnpm lint-all/pnpm build-all
…because the underlying tool (vitest / biome / tsc) is hidden behind the npm-script name, so rtk can't detect it from the command string. In a monorepo these script commands are the single largest source of uncompressed output (full vitest/biome/tsc logs).
What I tried (and why it doesn't solve it)
| Mechanism | Result |
|---|---|
Custom filters.toml [filters.*] with match_command = "^pnpm…" |
rtk verify passes, but the hook never routes pnpm verify:fast through rtk, so the filter only applies on the explicit rtk pnpm … path — not automatically. |
[hooks].transparent_prefixes = ["pnpm verify:fast", …] |
No effect on routing. |
[hooks].exclude_commands |
Only subtracts from routing; can't add. |
Reproduction (hook returns empty = not routed):
```bash
printf '%s' '{"tool_name":"Bash","tool_input":{"command":"pnpm verify:fast"}}' | rtk hook claude
(no output)
printf '%s' '{"tool_name":"Bash","tool_input":{"command":"vitest run"}}' | rtk hook claude
{"hookSpecificOutput":{"...","updatedInput":{"command":"rtk vitest"}}}
```
Proposed feature
A config-driven route table mapping a command regex to an rtk handler (or a named custom filter), so the hook rewrites matching commands accordingly. For example:
```toml
[[hooks.route]]
match = "^pnpm\b.*\b(test|test-all)\b"
handler = "vitest" # route output through rtk's vitest failure-extractor
[[hooks.route]]
match = "^pnpm\b.\bverify:(fast|full)\b"
handler = "pnpm-checks" # a named [filters.] entry
```
Behavior: when the hook matches match, it rewrites the command to route through the named handler/filter (e.g. wraps as rtk pnpm … or pipes output through the filter via rtk pipe), exactly as the built-in routes do today.
Why config (not behavioral)
The whole value of the hook is that the agent doesn't have to remember to prefix rtk — it works deterministically, including inside subagents (the hook fires for subagent tool calls). Telling agents to manually run rtk pnpm test reintroduces the exact unreliability the hook exists to remove (subagents especially won't honor it). A config route keeps enforcement deterministic.
Activity
pszymkowiak commentedon Jun 10, 2026
🔍 Automated Triage
featuremediumSummary
Feature request: add a config-driven [[hooks.route]] table so pnpm/npm script commands can be regex-matched and routed through rtk handlers in the PreToolUse hook, closing the gap where script-wrapped tools (vitest, tsc, biome) are invisible to the existing auto-rewrite logic.
Triaged automatically by wshm · This is an automated analysis, not a human review.
triggerhive-gijs commentedon Aug 10, 2026
Confirming this is still the case on rtk
0.45.0, independently reproduced while chasing a related problem.A user-global
~/.config/rtk/filters.tomland a project-local.rtk/filters.toml(the latter trusted viartk trust -y) both have no effect on routing:So
match_commandselects which filter applies once a command is already on thertk …path; it cannot put it there. That matches your table exactly, and it means the two mechanisms that look like they should work (filters.toml,[hooks].transparent_prefixes) are both dead ends for this.One data point on why the impact is larger than it looks: on a Nuxt project,
pnpm typecheckemits 2673 bytes of duplicated-import warnings on a fully green run, while the equivalent filtered path emits 28. That is 99% of a command an agent runs many times per session, and it is pure noise on success.I worked around it with a small PreToolUse hook ordered ahead of
rtk-rewrite.shthat maps the bare command onto the existing handler. That works, but it is exactly the route table you are proposing, hand-rolled per script name, which does not scale past a handful of commands. A config-driven[[hooks.route]]as you sketched would remove the need for it.KuSh commentedon Sep 13, 2026
Closing as a duplicate of #1684, which asks for the same thing in a more general form: user-defined rewrite rules in config.toml that are merged into the rewrite registry, so a pattern such as
pnpm verify:fastcan be routed onto an rtk handler instead of running unfiltered. Your reproduction and the measured impact on a Nuxt typecheck are the strongest case for it, so please repost them on #1684 and follow up there.