with one click
performance
// RTK CLI performance analysis and optimization. Startup time (<10ms), binary size (<5MB), regex compilation, memory usage. Use when adding dependencies, changing initialization, or suspecting regressions.
// RTK CLI performance analysis and optimization. Startup time (<10ms), binary size (<5MB), regex compilation, memory usage. Use when adding dependencies, changing initialization, or suspecting regressions.
Issue triage: audit open issues, categorize, detect duplicates, cross-ref PRs, risk assessment, post comments. Args: "all" for deep analysis of all, issue numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.
PR triage: audit open PRs, deep review selected ones, draft and post review comments. Args: "all" to review all, PR numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.
Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.
Rust design patterns for RTK. Newtype, Builder, RAII, Trait Objects, State Machine. Applied to CLI filter modules. Use when designing new modules or refactoring existing ones.
Enforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow.
Triage complet RTK : exécute issue-triage + pr-triage en parallèle, puis croise les données pour détecter doubles couvertures, trous sécurité, P0 sans PR, et conflits internes. Sauvegarde dans claudedocs/RTK-YYYY-MM-DD.md. Args: "en"/"fr" pour la langue (défaut: fr), "save" pour forcer la sauvegarde.
| name | performance |
| description | RTK CLI performance analysis and optimization. Startup time (<10ms), binary size (<5MB), regex compilation, memory usage. Use when adding dependencies, changing initialization, or suspecting regressions. |
| triggers | ["startup time","performance regression","too slow","benchmark","binary size","memory usage"] |
| allowed-tools | ["Bash","Read","Grep"] |
| effort | medium |
| tags | ["performance","benchmark","startup","binary-size","memory","rtk"] |
| Metric | Target | Blocker |
|---|---|---|
| Startup time | <10ms | Release blocker |
| Binary size (stripped) | <5MB | Release blocker |
| Memory (resident) | <5MB | Release blocker |
| Token savings per filter | ≥60% | Release blocker |
# Install hyperfine (once)
brew install hyperfine
# Baseline (before changes)
hyperfine 'rtk git status' --warmup 3 --export-json /tmp/before.json
# After changes — rebuild first
cargo build --release
# Compare against installed
hyperfine 'target/release/rtk git status' 'rtk git status' --warmup 3
# Target: <10ms mean time
# Release build with strip=true (already in Cargo.toml)
cargo build --release
ls -lh target/release/rtk
# Should be <5MB
# If too large — check what's contributing
cargo bloat --release --crates
cargo bloat --release -n 20
# Install: cargo install cargo-bloat
# macOS
/usr/bin/time -l target/release/rtk git status 2>&1 | grep "maximum resident"
# Target: <5,000,000 bytes (5MB)
# Linux
/usr/bin/time -v target/release/rtk git status 2>&1 | grep "Maximum resident"
# Target: <5,000 kbytes
Regex compilation on every function call is a common perf killer:
# Find all Regex::new calls
grep -n "Regex::new" src/*.rs
# Verify ALL are inside lazy_static! blocks
# Any Regex::new outside lazy_static! = performance bug
// ❌ Recompiles on every filter_line() call
fn filter_line(line: &str) -> bool {
let re = Regex::new(r"^error").unwrap(); // BAD
re.is_match(line)
}
// ✅ Compiled once at first use
lazy_static! {
static ref ERROR_RE: Regex = Regex::new(r"^error").unwrap();
}
fn filter_line(line: &str) -> bool {
ERROR_RE.is_match(line) // GOOD
}
Before adding any new crate:
# Check startup impact (measure before adding)
hyperfine 'rtk git status' --warmup 3
# Add dependency to Cargo.toml
# Rebuild
cargo build --release
# Measure after
hyperfine 'target/release/rtk git status' --warmup 3
# If startup increased >1ms — investigate
# If startup increased >3ms — reject the dependency
| Crate | Reason | Alternative |
|---|---|---|
tokio | +5-10ms startup | Blocking std::process::Command |
async-std | +5-10ms startup | Blocking I/O |
rayon | Thread pool init overhead | Sequential iteration |
reqwest | Pulls tokio | ureq (blocking) if HTTP needed |
# After cargo build --release
cargo build --release --timings
# Open target/cargo-timings/cargo-timing.html
# Look for crates with long compile times (correlates with complexity)
# macOS — use Instruments
instruments -t Allocations target/release/rtk git log -10
# Or use cargo-instruments
cargo install cargo-instruments
cargo instruments --release -t Allocations -- git log -10
Common RTK allocation hotspots:
// ❌ Allocates new String on every line
let lines: Vec<String> = input.lines().map(|l| l.to_string()).collect();
// ✅ Borrow slices
let lines: Vec<&str> = input.lines().collect();
// ❌ Clone large output unnecessarily
let raw_copy = output.stdout.clone();
// ✅ Use reference until you actually need to own
let display = &output.stdout;
// In tests — always verify claims
fn count_tokens(text: &str) -> usize {
text.split_whitespace().count()
}
#[test]
fn test_savings_claim() {
let input = include_str!("../tests/fixtures/mycmd_raw.txt");
let output = filter_output(input).unwrap();
let input_tokens = count_tokens(input);
let output_tokens = count_tokens(&output);
let savings = 100.0 * (1.0 - output_tokens as f64 / input_tokens as f64);
assert!(
savings >= 60.0,
"Expected ≥60% savings, got {:.1}% ({} → {} tokens)",
savings, input_tokens, output_tokens
);
}
Template for any performance-sensitive change:
# 1. Baseline
cargo build --release
hyperfine 'target/release/rtk git status' --warmup 5 --export-json /tmp/before.json
/usr/bin/time -l target/release/rtk git status 2>&1 | grep "maximum resident"
ls -lh target/release/rtk
# 2. Make changes
# ... edit code ...
# 3. Rebuild and compare
cargo build --release
hyperfine 'target/release/rtk git status' --warmup 5 --export-json /tmp/after.json
/usr/bin/time -l target/release/rtk git status 2>&1 | grep "maximum resident"
ls -lh target/release/rtk
# 4. Compare
# Startup: jq '.results[0].mean' /tmp/before.json /tmp/after.json
# If after > before + 1ms: investigate
# If after > 10ms: regression, do not merge