Built-in filters for ssh / dig / lsof / scp (custom TOML filters don't reach the PreToolUse hook)
#2,268 opened on Jun 4, 2026
Description
Summary
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:
$ zap hook check "ssh host docker ps"
No rewrite for: ssh host docker ps
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.
Thanks — great tool.