rtk-ai avatar

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-code

Installs 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

More from rtk-ai/rtk

All 7
1neolabhq avatartest-promptneolabhq/context-engineering-kitUse when creating or editing any prompt (commands, hooks, skills, subagent instructions) to verify it produces desired behavior - applies RED-GREEN-REFACTOR cyc1.3Kskills.sh installs
2next-safe-action avatarsafe-action-testingnext-safe-action/skillsUse when writing tests for next-safe-action actions or hooks -- Vitest patterns for testing server actions directly, middleware behavior, hooks with React Testi1.2Kskills.sh installs
3mindrally avatarpython-testingmindrally/skillsExpert in Python testing with pytest and test-driven development1.1Kskills.sh installs
4testdino-hq avatarplaywright-coretestdino-hq/playwright-skillBattle-tested Playwright patterns for writing and debugging reliable E2E, API, component, visual, accessibility, and security tests. Use when you need locator s966skills.sh installs
5bobmatnyc avatarvitestbobmatnyc/claude-mpm-skillsVitest - Modern TypeScript testing framework with Vite-native performance, ESM support, and TypeScript-first design942skills.sh installs
6secondsky avatarapi-testingsecondsky/claude-skillsHTTP API testing for TypeScript (Supertest) and Python (httpx, pytest). Test REST APIs, GraphQL, request/response validation, authentication, and error handling910skills.sh installs