Skip to content

Custom TOML filters (global or trusted project-local) are never applied by the hook #2179

@jengchakhrit-ck

Description

@jengchakhrit-ck

rtk v0.37.2, macOS (Apple Silicon, homebrew)

Custom TOML filters — defined in the global filters.toml or a rtk trust'd project-local .rtk/filters.toml — parse and pass rtk verify, but are never applied by the Claude Code hook. Only compiled-in/bundled filters get rewritten.

Repro

Add a custom filter (global or trusted project-local):

[filters.zzprobe]
description = "probe"
match_command = '^zzprobe\b'
max_lines = 5
$ rtk trust            # registers .rtk/filters.toml (confirmed in `rtk trust --list`)
$ rtk verify --filter zzprobe     # found, parses (No inline tests)
$ rtk rewrite 'zzprobe --foo'      # -> EMPTY (no rewrite)
$ rtk rewrite 'liquibase update'   # -> "rtk liquibase update"  (bundled filter works)
$ rtk rewrite 'df -h'              # -> "rtk df -h"             (works)

RTK_NO_TOML is unset. A real custom filter (match_command='iconv.*UTF-16' + a replace rule) likewise never fires on iconv ... commands, while it's trivially correct when applied manually.

Also (related, may be by-design)

rtk discover scans the CC transcript (the raw pre-hook command string) and lists e.g. grep -n as "missed -> rtk grep (existing)". But the hook already rewrites those at exec time, so discover's "missed M tokens" / "adoption %" double-counts already-captured savings (verified: raw cat/grep increment the rtk read/rtk grep counters 1:1). Consider netting out hook-captured commands using history.db so "missed" reflects only genuinely-unhandled commands.

Expected

Trusted/global custom filters should be applied by the hook like bundled ones (or rtk pipe -f <customname> should accept custom filter names — it currently rejects anything not built-in). Without this, user-defined filters are non-functional for their primary purpose.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions