Repository navigation
Description
Summary
The PreToolUse hook rewrites pnpm lint → rtk lint, discarding the body of the project's package.json lint script. For projects whose script enforces flags eslint doesn't default to (e.g. --max-warnings 0) or chains commands (e.g. pnpm check:foo && eslint ...), the rewritten rtk lint invokes eslint with defaults and exits 0 even when the original pnpm lint would have exited 1.
This is the same false-green symptom as #185 (closed) but originates at the hook-rewrite layer, not inside rtk lint. rtk lint --max-warnings 0 exits 1 correctly — #185's fix still holds for explicit invocations.
Affected version
rtk 0.42.0(Homebrew, macOS arm64)- Confirmed in both the legacy shell-script hook (
~/.claude/hooks/rtk-rewrite.shproduced by olderrtk init) and the current in-binary hook (rtk hook claude).
Reproduction
package.json:
{ "scripts": { "lint": "eslint --max-warnings 0" } }a.ts (one unused-import warning):
import { randomUUID } from 'node:crypto';
export const x = 1;# What CI runs (raw pnpm script):
pnpm lint a.ts; echo "raw=$?"
# raw=1 ← eslint --max-warnings 0 fails the run
# What Claude Code runs (hook rewrites pnpm lint → rtk lint):
rtk hook check "pnpm lint a.ts"
# → rtk lint a.ts
rtk lint a.ts; echo "hooked=$?"
# hooked=0 ← false green; --max-warnings 0 was droppedFor confirmation that rtk lint itself is fine when flags are explicit:
rtk lint --max-warnings 0 a.ts; echo $?
# 1 ← propagation is correct when the flag is passedImpact
Reaches every user who hasn't typed rtk lint themselves. The hook makes pnpm lint the de facto path through which agentic CLI tools (Claude Code, Cursor, etc.) validate before pushing. Local pre-push reports green; CI fails on the dropped flag.
In our team this caused a hotfix PR after a clean local check (keryx#2824 — "Local lint reported the same warning but the wrapper masked the non-zero exit code"). Net cost: ~15 minutes per occurrence plus an additional PR to unblock the deploy.
Affects any project whose lint script:
- chains commands (
pnpm check:foo && eslint ...), or - enforces flags
eslintdoesn't default to (--max-warnings 0,--report-unused-disable-directives, etc.).
Suggested fixes (any one resolves)
-
Stop rewriting
pnpm lint/pnpm tsc/pnpm test/npm run <X>. These names point at project-defined script bodies whose contents the hook can't see. Substitutingrtk <subcommand>discards user intent. Users can still typertk lintexplicitly when they want it. Smallest possible diff — a registry edit. -
Resolve the script body before rewriting. When the hook matches
pnpm lint, readpackage.json'sscripts.lint, then rewrite asrtk lint <resolved-script>so the user's chain runs faithfully with rtk summarizing on top. Retains rtk's value; more code. -
Default
rtk lintto--max-warnings 0when no explicit--max-warningsis given. Matches the de facto CI convention; documents itself inrtk lint --help. Minor behavior change for users with permissive eslint setups.
Option 1 is the cheapest and matches the principle of least surprise — pnpm lint is project-defined, not a known shape rtk can transform safely.
Local workaround
For users hitting this today, a 15-line shell shim around rtk hook claude resolves it without touching rtk:
#!/bin/bash
# rtk-hook-shim.sh — short-circuits the `pnpm lint` rewrite, delegates
# everything else to `rtk hook claude`.
if ! command -v rtk &>/dev/null || ! command -v jq &>/dev/null; then
exit 0
fi
INPUT=$(cat)
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
case "$CMD" in
"pnpm lint"|"pnpm lint "*|"pnpm run lint"|"pnpm run lint "*|"npm run lint"|"npm run lint "*)
exit 0
;;
esac
echo "$INPUT" | rtk hook claudePoint ~/.claude/settings.json PreToolUse:Bash hook at this shim instead of rtk hook claude.
Related
Same class of bug recurring at the wrapper layer:
- bug: rtk lint does not propagate ESLint non-zero exit code #185 (closed) —
rtk lintexit code, fixed for direct invocations; doesn't cover the hook rewrite path. - bug: rtk lint duplicates ESLint diagnostics and misreports summary counts #186 (closed) —
rtk lintsummary count. - tsc wrapper: --pretty flag suppresses errors and prints fake "compilation completed" success message #1772 (open) —
rtk tsc --prettyswallows errors. - rtk git push reports "ok (up-to-date)" when push is rejected by GitHub repository rulesets #1581 (open) —
rtk git pushreports ok on push rejected by GitHub rulesets. - Read-only commands (ls/grep/find/wc/cat/tail) should return exit 0 from
rtk rewrite, not exit 3 #1232 (open) — read-only commands exit code semantics. - Exit 3
updatedInputmutations silently dropped in permissive Claude Code Bash modes #1233 (open) —updatedInputmutations dropped in permissive Claude Code modes.
There may be value in a wrapper-level invariant test: for every command in the rewrite registry, assert rtk <cmd> exit code matches the raw invocation across documented flag combinations. Happy to contribute that test pattern if welcome.
Activity
ron332 commentedon May 26, 2026
Addendum:
pnpm testhas the same class of bugAfter filing this, auditing the project's
package.jsonturned up a second affected script:{ "scripts": { "test": "NODE_OPTIONS='--max-old-space-size=4096' vitest run" } }The hook rewrites
pnpm test→rtk vitest run, dropping theNODE_OPTIONSenv var. Any project relying on a heap-size bump for large test suites will silently lose it. The failure mode here is OOM during test runs rather than a false-green, but it's the same root cause: the hook can't see the script body so it substitutes a known shape that may not match.General pattern: any
pnpm <script-name>/npm run <script-name>rewrite is unsafe by construction, becausepackage.jsonscripts are project-defined strings that can prefix env vars, chain with&&, pipe, or compose in ways the hook registry can't anticipate.The local workaround shim in the original report has been extended to cover
pnpm test/npm test/npm run testas well.pszymkowiak commentedon May 27, 2026
🔍 Automated Triage
bughighSummary
PreToolUse hook rewrites
pnpm lint→rtk lint, silently dropping package.json script flags (e.g. --max-warnings 0), producing false-green lint results; fix by removing npm/pnpm script names from the rewrite registryTriaged automatically by wshm · This is an automated analysis, not a human review.
wilmerdooley commentedon Jul 1, 2026
I opened #2776 to address this. The details are in the PR; happy to adjust based on what you'd prefer.
fix(npm,lint): remove hardcoded allowlists, forward args untouched
fix(npm,lint): remove hardcoded allowlists, forward args untouched
m12-t26-r1: dist-demo/** を ESLint ignores に追加(衛生対応 / defense-in-depth)
fix(npm,lint): remove hardcoded allowlists, forward args untouched
fix(npm,lint): remove hardcoded allowlists, forward args untouched
fix(lint): remove `lint` script name from lint rewrite rule
KuSh commentedon Oct 3, 2026
Closing as a duplicate of #1489, which tracks the same rule: package scripts named lint (npm run lint, pnpm lint) are rewritten to rtk lint and lose the script body. The fix there covers pnpm lint too, and PR #2860 is linked from here. Please add anything further on #1489.