Skip to content

Add whitelist mode for command filtering #2231

Open

Description

@sleetdrop

Feature Request: Whitelist Mode for Command Filtering

Currently, RTK only supports blacklist-style filtering via exclude_commands in the config. I would like to request a whitelist mode:

  • Only commands explicitly listed in include_commands are filtered and rewritten by RTK.
  • All other commands should be passed through unchanged.
  • Example syntax:
[hooks]
include_commands = ["git status", "cargo build"]

Use Case:
This type of control lets users opt-in with a safe set of verified commands, reducing risk from unknown scenarios and making adoption in stable workflows much safer. This would be mutually exclusive with exclude_commands.

Thank you!

Activity

  1. added
    enhancement
    help wanted
    on Jun 3, 2026
  2. pszymkowiak commented on Jun 3, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟡 Priority medium
    🎯 Confidence 97%

    Summary

    Feature request: add include_commands whitelist mode as an alternative to the existing exclude_commands blacklist, so only explicitly listed commands are filtered by rtk.


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

  3. changed the title [-]支持命令过滤“白名单”模式:只过滤指定命令,其它全部直通[/-] [+]Add whitelist mode for command filtering[/+] on Jun 3, 2026
  4. jdgajjar commented on Jun 3, 2026

    @jdgajjar

    Hi! I'd like to work on this issue if it's still available.

    I'll first review the existing "exclude_commands" implementation and command filtering flow, then propose and implement support for "include_commands" as a mutually exclusive whitelist mode. I'll also add/update tests covering the new behavior and configuration validation.

    Please let me know if there are any design considerations or edge cases you'd like me to keep in mind before I start.

  5. jdgajjar commented on Jun 5, 2026

    @jdgajjar

    Hi! The CLA has been signed and the PR is ready for review. Please let me know if any changes are needed. Thank you!

  6. wauxhall commented on Jul 1, 2026

    @wauxhall

    Any updates on this?

  7. vlsi commented on Aug 16, 2026

    @vlsi

    Same need here, from the opposite direction: the set of commands I want rewritten is much smaller than the set I want left alone.

    rtk go test is a clear win and I want to keep it. find is the opposite — the agent writes -exec, -not, and other compound predicates that rtk find does not accept, so the command fails before it runs. The same goes for a few other tools I have not hit yet, and that is the point: I cannot enumerate what to exclude, because I do not know what the agent will type next week. I can enumerate what to include — it is one or two entries.

    exclude_commands cannot express this today (rtk 0.44.0):

    • patterns are literal command prefixes matched on a token boundary (git, go test, ./gradlew), so gradlew does not match ./gradlew build;
    • regex applies only when the pattern starts with ^ — git|go, (git|go), and g* match nothing;
    • exclude_commands = ["^.*$"] does disable every rewrite, so the only way to get a whitelist today is to turn everything off and wrap the hook in a script that calls rtk rewrite for the commands I want.

    That wrapper works, but the allowlist then lives outside rtk, in a hook script I maintain myself.

    The list is not static either. rtk go test only earns its keep while go test prints a line per package, and there is an open proposal to stop doing that: golang/go#64576 (comment). If that lands, rtk go becomes noise and I want to drop that one entry without auditing what my exclusions now let through.

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

    area:configenhancementhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions