Skip to content

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

Closed as not planned

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 539 invocations in 30 days vs 53 for sqlite3 and 26 for scp.

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.

Activity

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

    @pszymkowiak
    Collaborator

    [w] wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    The ssh built-in filter passes rtk verify but rtk rewrite never matches ssh commands (exit 1), leaving all ssh invocations uncompressed; likely a discrepancy between the verify and rewrite code paths, possibly introduced by the v0.35.0 registry change.


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

  3. pitimon commented on Apr 30, 2026

    @pitimon
    Author

    Withdrawing this issue — original report had unsanitized output that I'd rather not leave in revision history. Refiling a cleaner version separately. Sorry for the noise.

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

    bugeffort-mediumfilter-quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions