
Tdd Rust
This enforces red-green-refactor discipline for Rust filter development with real fixtures instead of synthetic test data. You capture actual command output (git log, cargo test, etc.), write failing snapshot tests with insta, implement the minimum code to pass, then verify at least 60% token reduction. It includes fallback patterns so filters never panic on malformed input, and won't let you move forward without hitting cargo fmt, clippy, and full test coverage. The workflow is opinionated about lazy_static regexes, anyhow::Result returns, and Arrange-Act-Assert structure. If you're building CLI filters and keep forgetting the savings assertions or edge cases, this keeps you honest.
- skills.sh installs
- 1.5K
- GitHub stars
- 86K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add rtk-ai/rtk --skill tdd-rust --agent claude-codeInstalls into .claude/skills of the current project.
Files
RTK TDD Workflow
Enforce Red-Green-Refactor for all RTK filter development.
The Loop
1. RED — Write failing test with real fixture
2. GREEN — Implement minimum code to pass
3. REFACTOR — Clean up, verify still passing
4. SAVINGS — Verify ≥20% token reduction
5. SNAPSHOT — Lock output format with insta
Step 1: Real Fixture First
Never write synthetic test data. Capture real command output:
# Capture real output from the actual command
git log -20 > tests/fixtures/git_log_raw.txt
cargo test 2>&1 > tests/fixtures/cargo_test_raw.txt
cargo clippy 2>&1 > tests/fixtures/cargo_clippy_raw.txt
gh pr view 42 > tests/fixtures/gh_pr_view_raw.txt
# For commands with ANSI codes — capture as-is
script -q /dev/null cargo test 2>&1 > tests/fixtures/cargo_test_ansi_raw.txt
Fixture naming: tests/fixtures/<command>_raw.txt
Step 2: Write the Test (Red)
#[cfg(test)]
mod tests {
use super::*;
use insta::assert_snapshot;
fn count_tokens(s: &str) -> usize {
s.split_whitespace().count()
}
Sponsors
Details
- Repository
- github.com/rtk-ai/rtk
- Categories
- Testing & QA, Code Review & Quality, Automation & Workflows, Rust
- First seen
- Jun 3, 2026