rtk-ai / rtk-ai/rtk

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

Open
#1,950 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/discover/rules.rs and src/cmds/js/npm_cmd.rs to trace how npm commands reach the existing handler, then inspect src/cmds/js/vitest_cmd.rs as the model for node output handling. Add coverage for the npm rewrite behavior and the proposed node commands; done means npm commands trigger the existing handler and node test/check output is summarized without changing pass-through cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, rust
Domain
cli, testing, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.