rtk-ai/rtk

Add handlers for `node` and `npm test` — top unhandled commands in Claude Code workflows

Open

#1,950 opened on May 18, 2026

View on GitHub
 (3 comments) (1 reaction) (0 assignees)Rust (2,914 forks)batch import
area:clienhancementhelp wantedpriority:medium

Repository metrics

Stars
 (48,085 stars)
PR merge metrics
 (Avg merge 11d 1h) (45 merged PRs in 30d)

Description

Context

Using RTK with Claude Code, I noticed npm test and node --test show up as top "unhandled" commands in my workflow. After looking at the source I realised the situation is more nuanced than I first thought — see Update below.

rtk discover --all --since 1 output:

TOP UNHANDLED COMMANDS -- open an issue?
----------------------------------------------------
Command                  Count    Example
node                         9    node --check "$f" 2>&1
npm test                     2    npm test 2>&1

What's actually missing

1. The npm rewriter pattern is too restrictive

src/cmds/js/npm_cmd.rs already supports test, start, install, ci, run <script>, audit, etc. — its NPM_SUBCOMMANDS list is comprehensive. But the rewriter rule in src/discover/rules.rs only matches:

pattern: r"^npm\s+(exec|run|run-script|rum|urn|x)(\s|$)"

Result: npm test, npm install, npm ci, npm i, npm audit etc. don't trigger the hook rewrite — they reach the agent's context as raw npm output, even though the handler downstream would happily process them.

Suggested fix: broaden the pattern to r"^npm(\s+|$)" (or enumerate all NPM_SUBCOMMANDS). npm_cmd::run already does the right dispatch internally — it doesn't need help from the regex.

2. No node handler exists

Neither a src/cmds/js/node_cmd.rs nor a rewriter rule. The main targets:

  • node --check <file> — usually silent on success; on failure, group similar stack traces.
  • node --test <files...> — the built-in test runner output is long with all ▶/✔ markers and timing. A summary similar to rtk jest / rtk vitest (group passes, surface failures with context) would map perfectly.
  • node -e '<inline>', node <script.js> — pass through.

Why this matters

node --check and node --test are dominant in agent-driven JS/TS workflows (syntax-check before commit, run native Node test runner). Combined with the npm pattern fix, this would close a sizeable gap in the hook's coverage for modern JS projects without much code surface change.

Environment

  • OS: Windows 11
  • Shell: bash (Git for Windows) launched by Claude Code
  • Node: 24.x

Happy to send PRs:

  • one for the npm rewriter pattern (one-line change in rules.rs + tests),
  • a separate one adding rtk node modelled on vitest_cmd.rs.

Let me know which approach the maintainers prefer.


Update (initial framing was inaccurate)

The first version of this issue claimed RTK doesn't handle npm test at all. That was wrong — rtk npm exists in src/cmds/js/npm_cmd.rs. The actual issue is the rewriter pattern, not a missing handler. Body has been corrected.

Contributor guide