Skip to content

SSH filter passes verify (3/3) but rtk rewrite returns exit 1 — ssh commands unintercepted on Claude Code hook path #1654

Closed

Description

@pitimon

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.toml overrides 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 rewritten rtk ssh ... command, mirroring ps -ef behavior, so the
    Claude Code hook can route ssh through compression.
  • Actual: rtk rewrite returns exit 1 (passthrough) for every ssh form
    tested, despite rtk verify --filter ssh reporting 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

  1. added
    bug
    effort-small
    filter-quality
    on Apr 30, 2026
  2. pszymkowiak commented on Apr 30, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 91%

    Summary

    SSH filter passes verify but rtk rewrite returns exit 1 for all ssh command shapes; PR #2004 already open with a fix.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/filters/ssh.rs
    • src/rewrite.rs

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

  3. pitimon commented on Apr 30, 2026

    @pitimon
    Author

    Cross-link: #1607 is a feature request to add an ssh wrapper, 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.

  4. KuSh commented on Sep 26, 2026

    @KuSh
    Collaborator

    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" returns rtk 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.

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:clibugeffort-smallfilter-qualityplatform:macospriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions