Repository navigation
Description
Summary
The built-in ssh filter is registered (passes rtk verify --filter ssh)
but rtk rewrite never matches any ssh ... command shape, so the Claude
Code Bash hook path leaves all ssh invocations uncompressed. Other built-in
filters (ps, grep, ls) on the same machine continue to match correctly.
Environment
- rtk 0.37.2 (Homebrew,
/opt/homebrew/Cellar/rtk/0.37.2/bin/rtk) - macOS (Darwin 25.4.0)
- Claude Code hook:
rtk hook claude(configured in~/.claude/settings.json) RTK_TELEMETRY=off- No project-local
.rtk/filters.tomloverrides for ssh
Reproduction
$ rtk --version
rtk 0.37.2
$ rtk verify --filter ssh
3/3 tests passed
# SSH never matches rewrite (any shape):
$ for cmd in 'ssh root@host uptime' 'ssh [email protected] ls' \
'ssh -o ConnectTimeout=5 host echo OK' 'ssh host'; do
rtk rewrite "$cmd" >/dev/null 2>&1; echo "exit=$? cmd=$cmd"
done
exit=1 cmd=ssh root@host uptime
exit=1 cmd=ssh [email protected] ls
exit=1 cmd=ssh -o ConnectTimeout=5 host echo OK
exit=1 cmd=ssh host
# Sanity check — other built-ins match correctly:
$ rtk rewrite "ps -ef" # → exit 3, "rtk ps -ef"
$ rtk rewrite "grep -n x f" # → exit 0, "rtk grep -n x f"
$ rtk rewrite "ls -la" # → exit 0, "rtk ls -la"Impact (30-day data)
rtk discover from this machine lists ssh as the #1 unhandled command,
with several hundred invocations in 30 days — far ahead of any other
unhandled command on the list.
Estimated savings missed at 95% compression: ~50K-100K tokens/month for
this single user (infra ops with heavy ssh use).
Earlier in-the-wild evidence
rtk gain --history from a prior session captured 10 rtk:toml ssh ...
intercepts during a ~5-min window (86.5% savings) and zero intercepts since,
across multiple Claude Code session restarts. The current 30-day history
shows rtk:toml ps -ef and rtk:toml ansible-playbook firing normally —
ssh is the only built-in filter that has gone dark.
Expected vs actual
- Expected:
rtk rewrite "ssh root@host uptime"returns exit 0/3 with
the rewrittenrtk ssh ...command, mirroringps -efbehavior, so the
Claude Code hook can route ssh through compression. - Actual:
rtk rewritereturns exit 1 (passthrough) for every ssh form
tested, despitertk verify --filter sshreporting 3/3 tests passing.
Hypothesis
The verify and rewrite code paths appear to consult the SSH filter
differently — verify exercises the filter directly while rewrite may
have an exclusion or path bug that skips ssh. Possibly related to the
v0.35.0 security change (#886) that altered registry default behavior, but
that should produce exit 3, not exit 1.
Ask
Could you confirm whether rtk rewrite is intentionally excluding ssh
in current builds, and if not, what diagnostic output would help track this
down? Happy to bisect across versions if useful.
(Note: this is a clean refile. Original #1653 was withdrawn for a content-hygiene cleanup; same technical content, no internal hostnames in the example output.)
Activity
pszymkowiak commentedon Apr 30, 2026
🔍 Automated Triage
bugmediumSummary
SSH filter passes verify but rtk rewrite returns exit 1 for all ssh command shapes; PR #2004 already open with a fix.
📁 Relevant files
src/filters/ssh.rssrc/rewrite.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
pitimon commentedon Apr 30, 2026
Cross-link: #1607 is a feature request to add an
sshwrapper, filed by another user who appears unaware that the ssh filter already exists in the registry. That seems consistent with the regression framing here — if the filter were actually firing, users probably would not be requesting ssh as a missing wrapper.KuSh commentedon Sep 26, 2026
Fixed by #2748, shipped in v0.44.0: the hook rewrite path now matches built-in TOML filters, so
rtk rewrite "ssh root@host uptime"returnsrtk ssh root@host uptime(exit 3), and the other shapes from the report rewrite too. If ssh commands still pass through on the latest version, please comment or reopen.