Skip to content

rtk hook claude rewrites Biome commands to ESLint and can mask execution failures #3117

Open

Description

@brunoreinstein-cloud

Environment

  • RTK: rtk 0.38.0 (Windows binary, C:\Users\<user>\AppData\Local\rtk\rtk)
  • OS: Windows 11 Home Single Language, build 10.0.26200
  • Shell used for repro: Git Bash (MSYS2), GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)
  • Package manager: pnpm 11.0.8
  • Node: v22.21.0
  • Project: Next.js repo using Biome (via Ultracite) exclusively — no ESLint installed
    (node_modules/.bin/eslint absent, no eslint config file), triggered via the
    Claude Code PreToolUse hook (rtk hook claude, configured in
    ~/.claude/settings.json as {"matcher": "Bash", "hooks": [{"type": "command", "command": "rtk hook claude"}]}).

This report covers two distinct, separable bugs found while investigating the same
symptom. Both were reproduced directly against the rtk binary (not just through the
Claude Code hook), using the JSON stdin format the hook itself sends.


Bug 1 — the auto-rewrite matcher substitutes an ESLint-only filter for Biome invocations

rtk hook claude decides to rewrite a Bash command by scanning it for known keywords.
For every pattern actually tested below, a command containing biome (as its own
token, or embedded in pnpm exec biome ... / npx biome ...), or the package-script
name lint in pnpm run lint, gets rewritten to rtk lint — a subcommand documented
as "ESLint with grouped rule violations". There is no Biome-specific subcommand
(rtk biome --help reports Failed to resolve 'biome' via PATH, falling back to direct exec: Binary 'biome' not found on PATH), and no detection of which linter the
target project actually has configured before choosing the ESLint filter.

Patterns confirmed to trigger this rewrite (piping the hook's own JSON stdin format
directly into rtk hook claude):

$ echo '{"tool_name":"Bash","tool_input":{"command":"biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk lint check app/api/user/sessions/route.ts"}}}

$ echo '{"tool_name":"Bash","tool_input":{"command":"pnpm exec biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk lint check app/api/user/sessions/route.ts"}}}

$ echo '{"tool_name":"Bash","tool_input":{"command":"npx biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk lint check app/api/user/sessions/route.ts"}}}

$ echo '{"tool_name":"Bash","tool_input":{"command":"pnpm run lint"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk lint"}}}

(In this project, pnpm run lint is defined in package.json as
ultracite check --config-path biome.jsonc — a Biome wrapper, not ESLint.)

Patterns confirmed NOT to trigger the rewrite (untested beyond these — not a claim
about the general matching rule):

$ echo '{"tool_name":"Bash","tool_input":{"command":"node_modules/.bin/biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
(no output — command passed through unmodified)

$ echo '{"tool_name":"Bash","tool_input":{"command":"rtk proxy pnpm exec biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
(no output — command passed through unmodified)

$ echo '{"tool_name":"Bash","tool_input":{"command":"pnpm exec ultracite check --config-path biome.jsonc"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk pnpm exec ultracite check --config-path biome.jsonc"}}}

(this last one is a generic passthrough-shaped rewrite, not the broken ESLint
substitution — ultracite as a literal token is not treated as a lint/biome
keyword.)

Consequence: for the four triggering patterns above, the real Biome/Ultracite
check is never executed. RTK substitutes its own ESLint invocation instead, in a
project that has no ESLint installed.


Bug 2 — when the substituted rtk lint call fails, the reported result is

inconsistent and can be a false pass (including exit 0)

Running rtk lint directly (bypassing the hook, to isolate this from Bug 1) shows
what happens once the substitution from Bug 1 has occurred:

$ rtk lint app/api/user/sessions/route.ts -vvv
ESLint output (JSON parse failed: expected value at line 1 column 1)
undefined
[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL] Command "eslint" not found
$ echo $?
1

This confirms rtk lint shells out to eslint via pnpm, that ESLint is not
resolvable in this project, and that RTK's ESLint-JSON output parser fails to parse
the resulting plaintext pnpm error (JSON parse failed: expected value at line 1 column 1).

The two argument shapes actually produced by the Bug-1 rewrites behave differently
after that parse failure:

$ rtk lint check app/api/user/sessions/route.ts
Lint: No issues found
$ echo $?
1

(what biome check <file> / pnpm exec biome check <file> / npx biome check <file> become — false "No issues found" message, but the exit code does correctly
propagate as failure)

$ rtk lint
ESLint output (JSON parse failed: expected value at line 1 column 1)
undefined
[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL] Command "eslint" not found
$ echo $?
0

(what bare pnpm run lint becomes — the raw failure text is shown, but the process
exits 0: a caller that checks only the exit code is told the check passed)

Consequence: the same underlying failure (ESLint not found → JSON parse failure)
produces two different outcomes depending on how the command reached rtk lint, and
in the pnpm run lint case the exit code itself is wrong, not just the message.


Related but separate: exclude_commands doesn't reliably opt a command out of

Bug 1's rewrite

While investigating a local workaround, adding "biome" to [hooks].exclude_commands
in config.toml was found to stop the rewrite only when biome is the first token of
the command:

$ rtk config | grep -A1 biome
    "biome",
]
$ echo '{"tool_name":"Bash","tool_input":{"command":"biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
(no output — correctly not rewritten)

$ echo '{"tool_name":"Bash","tool_input":{"command":"pnpm exec biome check app/api/user/sessions/route.ts"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk lint check app/api/user/sessions/route.ts"}}}
(still rewritten — exclude_commands did not apply)

The rewrite matcher (Bug 1) scans the whole command string, but exclude_commands
appears to check only argv[0]. This means exclude_commands cannot be used to
reliably protect a tool that's normally invoked via pnpm exec/npx/a package
script, which is the common case for biome. (This config change was reverted after
testing — it offered only partial protection and is a global, per-developer setting
that would have affected other, ESLint-using projects.)


Suggested fixes

  1. Before routing a lint/biome-keyword command to the ESLint filter, detect what
    the target project actually has configured (presence of biome.json(c) vs an
    ESLint config / eslint resolvable in node_modules/.bin), or add a first-class
    Biome filter (rtk biome, analogous to rtk prettier/rtk ruff) and route to it
    instead when Biome is what's present.
  2. When the underlying linter process fails to spawn/resolve (as opposed to running
    and reporting zero violations), that should be surfaced as an execution error —
    non-zero exit, clear "underlying linter not found/failed to run" message — every
    time, regardless of which argument shape reached the parser. It should never look
    the same as a clean pass.
  3. Make exclude_commands matching consistent with the rewrite matcher (both
    argv[0]-only, or both whole-string) so it can reliably opt out pnpm exec <tool>,
    npx <tool>, and pnpm run <script-that-wraps-tool> forms, not just the bare
    <tool> ... form.

This is reported as a correctness/reliability bug — the tool changes what actually
runs and what result is reported, silently, without exposing this in its own output.

Activity

  1. added
    bug
    help wanted
    on Jul 21, 2026
  2. pszymkowiak commented on Jul 21, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    rtk hook claude misidentifies Biome-only projects as ESLint (rewriting biome/pnpm run lint invocations to rtk lint), and the resulting ESLint spawn failure is inconsistently reported — sometimes a false 'No issues found', sometimes exit 0 on outright failure — masking real lint status; exclude_commands also fails to protect non-argv0 invocations.

    📁 Relevant files
    • src/hooks/claude.rs
    • src/commands/lint.rs
    • src/config.rs

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

  3. MannXo commented on Jul 21, 2026

    @MannXo

    I'd like to give this a shot if it's unassigned.

  4. noctua84 commented on Sep 7, 2026

    @noctua84

    Two data points from hitting this today, both verified directly.

    1. Still reproduces on rtk 0.43.0.

    This was filed against 0.38.0 (and #1489 against 0.37.2), so the behaviour has survived several releases. Same environment as the report: Windows 11, Git Bash, Claude Code PreToolUse hook (rtk hook claude), a Biome-only project with no ESLint installed or configured anywhere in the tree.

    $ rtk --version
    rtk 0.43.0
    
    $ rtk hook check "npm run lint"
    rtk lint
    
    $ rtk hook check "npx biome check"
    rtk lint check
    

    Note the second one: an explicit biome invocation is also routed to the ESLint filter, not just the npm run lint alias.

    2. Project-local .rtk/filters.toml cannot be used to scope a workaround.

    Worth recording so the next person doesn't repeat the experiment. filters.toml says "Project-local .rtk/filters.toml takes precedence over these", which reads like it could override the routing per project. It cannot — it filters the output of rtk subcommands, and the hook's command rewrite happens before any filter applies.

    Verified with a project-local filter present and rtk trusted, run from inside that directory:

    $ cat .rtk/filters.toml
    schema_version = 1
    
    [filters.biome-lint]
    description = "Pass Biome check output through untouched"
    match_command = "^(npm run lint|npx biome|biome)\b"
    strip_ansi = true
    
    $ rtk trust
    $ rtk hook check "npm run lint"
    rtk lint                                  # unchanged
    
    $ npm run lint
    ESLint output (JSON parse failed: EOF while parsing a value at line 1 column 0)
    

    So the only available lever today is the global [hooks] exclude_commands, which cannot be scoped to a single project.

    Workaround, for anyone landing here meanwhile — in config.toml:

    [hooks]
    exclude_commands = ["npm run lint", "biome", "npx biome"]

    Entries match the start of the command rather than a substring (cf. #1919, #3838), so each invocation form needs its own entry — "biome" alone does not stop npx biome check. With those three in place, npm run lint returns Biome's real output and, importantly, exits 1 on an actual lint failure instead of 0.

    The exit-code half seems the more dangerous of the two bugs: an agent or CI step reading only the status code sees a passing lint on a failing tree, independent of which linter is involved.

  5. added a commit that references this issue on Sep 21, 2026
    433fe9d
  6. xiechimon commented on Sep 29, 2026

    @xiechimon

    Additional data point on rtk 0.50.0 (still present, and the failure mode has gotten worse than #1489 reported): the swallowed parse failure now also inverts the exit code, so a passing tree reports a lint failure.

    Environment

    • rtk 0.50.0 (Homebrew, /opt/homebrew/bin/rtk), macOS 26.7 arm64
    • Claude Code PreToolUse hook rtk hook claude
    • pnpm 12.5.1 workspace (pnpm-workspace.yaml), Biome 2.5.14, no ESLint in the project
    • package.json: "lint": "biome ci ."

    Repro

    $ rtk rewrite "pnpm lint"
    rtk lint
    $ rtk rewrite "pnpm exec biome ci ."
    rtk lint ci .

    Native run (no hook) — tree is clean, only warnings:

    $ pnpm lint; echo "exit=$?"
    Checked 389 files in 226ms. No fixes applied.
    Found 18 warnings.
    Found 1 info.
    exit=0

    Same command through the Claude Code hook:

    ESLint output (JSON parse failed: EOF while parsing a value at line 1 column 0)
    Error: ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL
    exit=1

    Real biome output is discarded entirely and the exit code flips 0 → 1.

    Why this matters more than a cosmetic mislabel

    The rewritten path is the only path an agent using Claude Code sees, while CI and pre-commit hooks (which do not go through the LLM hook) run natively. Result: local "red" vs CI "green" on the same commit — an agent reading its own Bash output concludes the lint gate fails, and can spend a turn "fixing" a passing tree. This is the masking case in #3117/#1489, but in the false-failure direction rather than the false-pass direction #1489 observed (process exit 0).

    Workaround that works on 0.50.0

    [hooks] exclude_commands in the rtk config, anchored:

    [hooks]
    exclude_commands = [
        "^pnpm\\s+lint(\\s|$)",
        "^pnpm\\s+(exec\\s+)?biome(\\s|$)",
        "^pnpm\\s+dlx\\s+biome(\\s|$)",
        "^npx\\s+biome(\\s|$)",
        "^npm\\s+run(-script)?\\s+lint(\\s|$)",
    ]

    Verified: rtk rewrite "pnpm lint" then exits 1 (no rewrite), pnpm lint returns the real output and exit 0.

    Suggested fixes (in rough priority order)

    1. Never convert a passing child into a failing command. If the linter output cannot be parsed, fall back to raw passthrough and preserve the child's exit code — a filter must not be able to invent a failure.
    2. Route to a Biome-aware path (Biome supports --reporter=json, or biome ci) when the resolved linter is Biome rather than running the ESLint adapter; the rewrite table currently maps biome / pnpm lint / pnpm exec biome onto rtk lint regardless of the project's linter (also covered by bug(rewrite): npm run lint forced into rtk lint on Biome projects #1489, bug(hook): pnpm exec biome ci . → rtk lint ci . drops the explicit biome name and runs ci as the linter (exit 254 misreported as "possibly out of memory") #2906).
    3. Label the parse-failure message with the linter actually run — on a Biome-only project the message reads ESLint output (...), which sends debugging in the wrong direction.

    Cross-refs: #1489 (same symptom string, exit 0 at the time), #2906 (pnpm exec biome ci . → rtk lint ci .), #3117 (umbrella).

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

    area:clibughelp wantedpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions