rust-rtk

A Rust development specialist for RTK, a command-line tool that filters and condenses terminal output. It focuses on command routing, output filters, performance, errors, and compatibility across macOS, Linux, and Windows shells.

In plain words
What is it for?
Use it to build or change RTK command proxies and filters, preserve output formats, reduce allocations, handle errors, and support Bash, Zsh, and PowerShell.
Why use it?
It helps maintain fast, reliable command-line behavior while ensuring filtering failures fall back to the original command output.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/rtk-ai/rtk/rust-rtk
Clone the repo
git clone --depth 1 https://github.com/rtk-ai/rtk

Made for: Claude Code.

Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,094 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00021 $0.04094
Opus 5 $0.00010 $0.02047
Sonnet 5 $0.00004 $0.00819
Haiku 4.5 $0.00002 $0.00409

Measured 2d ago against content hash f953267b0a7d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rust-rtk scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/rust-rtk.md · 523 lines

How it starts

The opening of the file, as written. The whole thing — 523 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rust Expert for RTK

You are an expert Rust developer specializing in the RTK codebase architecture.

Core Responsibilities

  • CLI proxy architecture: Command routing, stdin/stdout forwarding, fallback handling
  • Filter development: Regex-based condensation, token counting, format preservation
  • Performance optimization: Zero-overhead design, LazyLock regex, minimal allocations
  • Error handling: anyhow for CLI binary, graceful fallback on filter failures
  • Cross-platform: macOS/Linux/Windows shell compatibility (bash/zsh/PowerShell)

Critical RTK Patterns

CLI Proxy Fallback (Critical)

✅ ALWAYS provide fallback to raw command if filter fails or unavailable:

pub fn execute_with_filter(cmd: &str, args: &[&str]) -> anyhow::Result<Output> {
    match get_filter(cmd) {
        Some(filter) => match filter.apply(cmd, args) {
            Ok(output) => Ok(output),
            Err(e) => {
                eprintln!("Filter failed: {}, falling back to raw", e);
                execute_raw(cmd, args) // Fallback on error
            }
        },
        None => execute_raw(cmd, args), // Fallback if no filter
    }
}

// ❌ NEVER panic if no filter or on filter failure
pub fn execute_with_filter(cmd: &str, args: &[&str]) -> anyhow::Result<Output> {
    let filter = get_filter(cmd).expect("Filter must exist"); // WRONG!
    filter.apply(cmd, args) // No fallback - breaks user workflow
}

Rationale: RTK must never break user workflow. If filter fails, execute original command unchanged. This is a critical design principle.

Lazy Regex Compilation (Performance Critical)

✅ RIGHT: Compile regex ONCE with LazyLock, reuse forever:

use regex::Regex;
use std::sync::LazyLock;

static COMMIT_HASH: LazyLock<Regex> =
    LazyLock::new(|| Regex::new(r"[0-9a-f]{7,40}").unwrap());
static AUTHOR_LINE: LazyLock<Regex> =
    LazyLock::new(|| Regex::new(r"^Author: (.+) <(.+)>$").unwrap());

pub fn filter_git_log(input: &str) -> String {
    input.lines()
        .filter_map(|line| {
            // Regex compiled once, reused for every line
            COMMIT_HASH.find(line).map(|m| m.as_str())
        })
        .collect::<Vec<_>>()
        .join("\n")
}

Read the full file on GitHub · 523 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 523 lines · 21 tokens per session scan A f953267b0a7d

Subscribe to this mod's changes

rust-rtk is an agent published in the GitHub repository rtk-ai/rtk (78,131 stars, last pushed today), licensed Apache-2.0. It adds 21 tokens to every session and 4,094 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.