Problem
rtk rewrite only checks the built-in Rust registry. It doesn't look at user TOML filters in ~/.config/rtk/filters.toml (or platform equivalent like ~/Library/Application Support/rtk/filters.toml on macOS).
This means the Claude Code hook (rtk-rewrite.sh) can't auto-route commands that only have user-defined TOML filters. The hook delegates to rtk rewrite, gets exit 1, and passes through without filtering.
Reproduction
# Add a user filter for ssh
cat >> ~/Library/Application\ Support/rtk/filters.toml << 'TOML'
[filters.ssh]
description = "Strip SSH connection noise"
match_command = "^ssh\\b"
strip_ansi = true
strip_lines_matching = [
"^Warning: Permanently added",
"^Connection to .* closed",
]
TOML
# Filter works when called directly
echo "Warning: Permanently added 'host' to known hosts." | rtk ssh root@host ls
# -> filters correctly
# But rtk rewrite doesn't know about it
rtk rewrite "ssh root@host ls"
# -> exit 1 (no rewrite)
Current workaround
Patch the hook to maintain a manual list of user TOML commands as fallback:
if [ $? -ne 0 ]; then
USER_TOML_CMDS="ssh|scp|nono|python3"
FIRST_WORD=$(echo "$CMD" | awk '{print $1}')
if echo "$FIRST_WORD" | grep -qE "^($USER_TOML_CMDS)$"; then
REWRITTEN="rtk $CMD"
else
exit 0
fi
fi
Works but requires keeping the hook list in sync with filters.toml manually.
Proposed fix
Have rtk rewrite check user TOML filters as a fallback when the built-in registry has no match. Built-in priority stays the same, it just extends coverage to user-defined commands.
Happy to send a PR if this approach makes sense.
Problem
rtk rewriteonly checks the built-in Rust registry. It doesn't look at user TOML filters in~/.config/rtk/filters.toml(or platform equivalent like~/Library/Application Support/rtk/filters.tomlon macOS).This means the Claude Code hook (
rtk-rewrite.sh) can't auto-route commands that only have user-defined TOML filters. The hook delegates tortk rewrite, gets exit 1, and passes through without filtering.Reproduction
Current workaround
Patch the hook to maintain a manual list of user TOML commands as fallback:
Works but requires keeping the hook list in sync with
filters.tomlmanually.Proposed fix
Have
rtk rewritecheck user TOML filters as a fallback when the built-in registry has no match. Built-in priority stays the same, it just extends coverage to user-defined commands.Happy to send a PR if this approach makes sense.