Skip to content

Hook rewrites npm run <script> -w <workspace>, breaking npm's --workspace flag #2098

Open

Description

@woltsu

The Claude Code hook collapses npm run <script> -w <ws> into rtk <script> -w <ws>, dropping npm run and passing npm's --workspace (-w) flag to the tool. For tsc/vitest, -w is --watch, so the command starts a watcher that never exits.

Repro:

$ rtk hook check 'npm run tsc -w backend'
rtk tsc -w backend          # -w is now tsc --watch → hangs forever

Expected: -w <name> after npm run <script> is npm's workspace selector and must be preserved (run npm run <script> --workspace <ns> or leave the command untouched), not handed to the tool.

Affected (all collapse and mis-handle -w): tsc, vitest, jest, lint, next, prisma.

Workaround that does NOT work: transparent_prefixes = ["npm run"] produces the broken npm run rtk tsc -w backend (strips the prefix, rewrites the remainder, re-prepends). Only exclude_commands = ["npm"] avoids it, at the cost of skipping all npm.

rtk version: 0.40.0, macOS.

Activity

  1. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    Hook incorrectly strips npm run and passes npm's -w <workspace> flag directly to the underlying tool (e.g. tsc, vitest), where -w means --watch, causing the command to hang indefinitely; fix requires the hook to detect and preserve npm workspace flags.

    📁 Relevant files
    • src/hook/rewrite.rs
    • src/hook/npm.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. itsManeka commented on Nov 26, 2026

    @itsManeka

    Reproduced on develop (97e68d53, Windows 11) with lint. npm run lint -w web (also -ws, --workspace web, --workspace=web, --workspaces) rewrites to rtk lint <same flags>. rtk lint then runs eslint -f json -w web . instead of the workspace's lint script, so in a two-workspace npm fixture the script never runs and the output is ESLint output (JSON parse failed: EOF while parsing a value at line 1 column 0).

    #5276 fixes this: with its head, none of these forms is rewritten, and plain npm run lint still rewrites to rtk lint. The validation details are in #5276.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions