You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Built-in filters for ssh / dig / lsof / scp (custom TOML filters don't reach the PreToolUse hook) #2268
Request built-in filters for ssh, dig, lsof, and scp.
Why custom filters don't cover this
The Claude Code auto-rewrite hook (zap hook claude) only auto-prefixes commands that have a built-in filter. Commands handled only by a user-defined filters.toml are not rewritten by the hook:
So custom TOML filters require explicit rtk ssh ... invocation (+ zap trust) and deliver zero automatic savings through the hook. The only path to automatic interception is a built-in filter.
Evidence these are high-impact
From zap discover on a real workflow (server/infra management, 30 days):
Command
Count
ssh
547 (321 + 117 + 87 + 22 across hosts)
dig +short
44
lsof
24
scp
7
ssh is the single most-used command and is entirely unhandled.
Suggested behavior
ssh: strip ANSI + login/locale noise (Warning: Permanently added, manpath: can't set the locale, Pseudo-terminal will not be allocated, Connection to X closed), then apply the inner command's filter when recognizable (e.g. ssh host "docker ps" → docker filter), else dedupe/cap. The remote command output is where the tokens are.
scp: strip transfer progress bars / ETA lines; success-only on clean transfer.
dig: keep answer section, drop ;; comment lines and blanks.
lsof: strip blank lines, cap long tabular output.
Alternative ask
If built-ins aren't desired, expose a config knob (e.g. [hooks] include_commands = ["ssh", ...]) so user TOML filters can opt into the auto-rewrite hook. Today only exclude_commands and transparent_prefixes exist.
Feature request for built-in filters for ssh/dig/lsof/scp; strong usage evidence (ssh is #1 unhandled command at 547 invocations/month) and well-specified behavior; also requests fallback config knob to opt user TOML filters into the auto-rewrite hook
Triaged automatically by wshm · This is an automated analysis, not a human review.
I looked into this and the built-in filter pattern seems straightforward for dig, lsof, and scp: add discovery rules, a small filter module for each command, dispatch wiring, and focused tests.
ssh looks like the one design question. A basic filter could strip ANSI/login/connection noise, but the issue also mentions applying the inner command's filter for something like ssh host "docker ps". That seems like it may need recursive command classification/dispatch rather than just output cleanup.
Would you prefer this to be split into smaller PRs, for example:
dig, lsof, and scp as simple output filters
ssh noise stripping
remote-command filter dispatch as a follow-up if desired
Or would you rather keep all four commands together in one PR?
Confirming this is still the case on rtk 0.43.0 (macOS, native-binary hook rtk hook claude), with two more commands and some measurements.
Same symptom, different tools
flyctl and blender are my two heaviest unfiltered commands (227 and 99 invocations in 30 days). I wrote user-global TOML filters for both in ~/Library/Application Support/rtk/filters.toml. rtk verify passes (154/154), and the filters work correctly when invoked explicitly:
Both subtract. There is no way to add a command to the rewrite set, so a user TOML filter is unreachable from the hook by construction.
Suggestion
Rather than adding built-ins case by case (ssh/dig/lsof/scp here, flyctl/blender for me, and #3490 brew / #3487 make / #3491 sort elsewhere), the general fix is to let the rewriter consult user TOML filters: if a filter's match_command matches, rewrite to rtk <cmd>. That closes this class of issue once, and every future custom filter becomes hook-reachable for free.
include_commands (#2231) would also solve it and is arguably simpler, but it requires the user to maintain the list in two places — once as a filter, once as an allowlist entry — where match_command already carries that information.
Happy to test a build against the flyctl/blender filters above if that's useful.
Activity
pszymkowiak commentedon Jun 4, 2026
🔍 Automated Triage
featurehighSummary
Feature request for built-in filters for ssh/dig/lsof/scp; strong usage evidence (ssh is #1 unhandled command at 547 invocations/month) and well-specified behavior; also requests fallback config knob to opt user TOML filters into the auto-rewrite hook
Triaged automatically by wshm · This is an automated analysis, not a human review.
axelray-dev commentedon Jun 4, 2026
I looked into this and the built-in filter pattern seems straightforward for dig, lsof, and scp: add discovery rules, a small filter module for each command, dispatch wiring, and focused tests.
ssh looks like the one design question. A basic filter could strip ANSI/login/connection noise, but the issue also mentions applying the inner command's filter for something like ssh host "docker ps". That seems like it may need recursive command classification/dispatch rather than just output cleanup.
Would you prefer this to be split into smaller PRs, for example:
Or would you rather keep all four commands together in one PR?
JayTheriau commentedon Aug 11, 2026
Confirming this is still the case on rtk 0.43.0 (macOS, native-binary hook
rtk hook claude), with two more commands and some measurements.Same symptom, different tools
flyctlandblenderare my two heaviest unfiltered commands (227 and 99 invocations in 30 days). I wrote user-global TOML filters for both in~/Library/Application Support/rtk/filters.toml.rtk verifypasses (154/154), and the filters work correctly when invoked explicitly:Both keep the diagnostic line and drop only the progress noise (
Fra:, layer pulls,MB/MB), so the filters do exactly what a built-in would.But the hook never routes to them:
So the savings are real but only reachable by typing
rtkmanually — which an agent won't do reliably, and which is the entire point of the hook.Why the config knob doesn't help today
rtk configcurrently exposes only:Both subtract. There is no way to add a command to the rewrite set, so a user TOML filter is unreachable from the hook by construction.
Suggestion
Rather than adding built-ins case by case (ssh/dig/lsof/scp here, flyctl/blender for me, and #3490 brew / #3487 make / #3491 sort elsewhere), the general fix is to let the rewriter consult user TOML filters: if a filter's
match_commandmatches, rewrite tortk <cmd>. That closes this class of issue once, and every future custom filter becomes hook-reachable for free.include_commands(#2231) would also solve it and is arguably simpler, but it requires the user to maintain the list in two places — once as a filter, once as an allowlist entry — wherematch_commandalready carries that information.Happy to test a build against the flyctl/blender filters above if that's useful.