#3410·rtk

The rewrite rule for `find` is unconditional, so `find … -delete` / `-exec` is captured and refused — the command silently does nothing and breaks `&&` chains

Author: HetCreepCreated Aug 4, 2026Updated Sep 28, 2026
Labelsbugpriority:higharea:cli

find is rewritten to rtk find for every invocation, but rtk find deliberately refuses the predicates and actions it does not implement. The result is that a working find command becomes a no-op with a nonzero exit.

*Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). Reproduced by running the shipped rtk 0.44.2 binary against a scratch directory; outputs verbatim.*

Reproduction

$ ls a
keep.txt  x.tmp  y.tmp

$ rtk rewrite find . -name '*.tmp' -delete
rtk find . -name *.tmp -delete

$ rtk find . -name '*.tmp' -delete
rtk: rtk find does not support compound predicates or actions (e.g. -not, -exec). Use `find` directly.
$ echo $?
1
$ ls a
keep.txt  x.tmp  y.tmp        ← nothing was deleted

$ find . -name '*.tmp' -delete   # real find
$ ls a
keep.txt                       ← deleted

And because the exit status is nonzero, anything chained after it does not run:

$ rtk find . -name '*.tmp' -delete && echo next
                               # "next" never prints

The cause

src/discover/rules.rs:139-141 matches ^find\s+ unconditionally — there is no allowlist of the predicates rtk find actually supports. So the rewrite captures -delete, -exec, -not and every other form the implementation then rejects.

The rewrite layer is deciding to handle a command that the handler has already declared it cannot handle.

Why it matters beyond the error message

  • find -delete and find -exec are the destructive forms. The user's intent was to change the filesystem; nothing changed, and the only signal is a message that reads like advice rather than a failure.
  • Under an agent, this is worse: the agent asked for a cleanup, got a message about unsupported predicates, and the files it believes are gone are still there.
  • The nonzero exit aborts && chains, so a script or agent workflow built around find … -delete && … stops at the first step.

Suggested fix (untested — no programmer has reviewed this)

Narrow rules.rs:139 so it only matches the find forms rtk find implements — an allowlist of supported predicates, in the same spirit as the kubectl rule at rules.rs:403, which is limited to get|logs|describe|apply and correctly lets kubectl delete pod web pass through untouched.

The kubectl rule is the shape this one should have: rewrite what you can summarise, pass through what you cannot. A rewrite that ends in "use the real tool directly" is strictly worse than never having rewritten it.

Related

Two other rules are total catch-alls on tools with destructive subcommands: rules.rs:627 (^aws\s+) and :712 (^gcloud\b). aws s3 rm --recursive, aws ec2 terminate-instances, gcloud projects delete all get routed through an output filter. Those do not currently fail the way find does, so I am noting them here rather than filing separately — but the same narrowing argument applies, and kubectl shows the project already knows the pattern.