rtk-ai/rtk

Hook matcher: leading backslash-newline defeats command rewrite

Geschlossen

#1.564 geöffnet am 28.04.2026

 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Rust (2.914 Forks)batch import
P1-criticalbugeffort-smallgood first issue

Repository-Metriken

Stars
 (48.085 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 11T 1h) (45 gemergte PRs in 30 T)

Beschreibung

If a Bash command starts with a backslash-newline (line continuation), rtk hook check reads the literal \ as the leading token and bails out instead of stripping the continuation first. Claude Code emits this shape often when formatting long invocations, so it shows up in real traffic.

Repro on rtk 0.37.2 (brew, macOS):

$ rtk hook check $'\\\ngit diff HEAD~1'
No rewrite for: \
git diff HEAD~1

Without the leading \<newline>, the same command rewrites cleanly to rtk git diff HEAD~1.

rtk discover -a -s 30 shows ~15 calls in the last 30 days that slipped past the hook this way — almost all git, gh, find, i.e. commands with working handlers. Pure matcher-side recoverable savings.

Related: #1243 (heredoc / multi-line) and #1252 ($(…), backticks, xargs) — same family of "matcher tokenizes too literally", but a distinct surface (leading-whitespace normalization, not nested-context detection).

Contributor Guide