Skip to main content

delegate

Function delegate 

Source
pub fn delegate<F>(stdin_payload: &str, config: &Config, run: F) -> String
where F: FnOnce(&[String], &str) -> Option<String>,
Expand description

Decide what this hook writes to stdout.

run receives the rtk argument vector and the raw stdin payload, and returns rtk’s stdout on a clean exit — or None if rtk could not be spawned, exited non-zero, or produced non-UTF-8.

Every failure path returns an empty string, which is Claude Code’s “no opinion” response: the command runs exactly as the model wrote it. That is the whole safety story of this plugin — a broken or absent rtk must never cost the user a shell command.

Note that empty output is also rtk’s own signal for “nothing to rewrite”, so the failure path and the no-op path coincide by construction rather than by coincidence.