skillfed

tdd-rust

tdd-rust guides you through test-driven filter implementation for RTK using the Red-Green-Refactor cycle. Start with real command output fixtures, write failing tests that verify both output format and ≥60% token reduction, then implement the minimum code to pass. Lock output format with snapshot tests and integrate into your CLI.

tdd-rust enforces Red-Green-Refactor discipline for RTK filter development with real fixtures and token-savings verification.

AI-generated summary based on this skill's SKILL.md

73,568 4,597 Apache-2.0 updated by rtk-ai

Install

rtk-ai/rtk/tdd-rust · repository language: Rust

CLI (skillfed)coming soon
git clone https://github.com/rtk-ai/rtk
cp -r rtk/.claude/skills/tdd-rust ~/.claude/skills/tdd-rust

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What is the red green refactor rust testing workflow in tdd-rust?

tdd-rust teaches the Red-Green-Refactor cycle for filter development. First, write a failing test (red) against real command output fixtures. Second, implement the minimum code to make it pass (green). Third, refactor while keeping tests green. This cycle enforces quality gates via cargo test, clippy, and fmt, ensuring your RTK filter implementation stays maintainable and correct.

How does tdd-rust verify token savings of ≥60% in filter implementations?

tdd-rust includes test patterns that measure token reduction in your filter output. Your tests compare the original command output size against the filtered result, asserting that the reduction meets or exceeds 60%. This verification runs automatically during cargo test, so token savings become a testable requirement rather than a manual check.

Can tdd-rust lock filter output format using snapshot testing with insta?

Yes. tdd-rust integrates insta snapshot testing to lock your filter's output format. Once you approve a snapshot, any unintended change to the filter output will cause the test to fail, preventing regressions. This pairs with real fixtures to ensure your RTK filter produces consistent, predictable results across runs.

What role do real fixtures play in tdd-rust filter development?

tdd-rust emphasizes real command output fixtures as your test foundation. Rather than mocking, you capture actual CLI output and use it as test input. This grounds your tests in reality, ensures your filter handles genuine edge cases, and makes snapshot tests meaningful. Real fixtures also support fallback behavior testing and ANSI stripping validation.

How does tdd-rust enforce quality gates in the test workflow?

tdd-rust integrates cargo test, cargo clippy, and cargo fmt into your development loop. These tools enforce code quality and consistency automatically. Combined with the Red-Green-Refactor discipline, quality gates prevent low-quality code from entering your filter implementation, keeping your RTK filter robust and maintainable.

Does tdd-rust cover edge case and fallback behavior testing for Rust filters?

Yes. tdd-rust includes patterns for testing edge cases and fallback behavior in your RTK filters. Examples include ANSI stripping edge cases, missing fields, and graceful degradation when filters encounter unexpected input. These tests ensure your filter remains reliable even when real-world data deviates from the happy path.

SKILL.md

rendered from the published skill — quoted content, verbatim

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 ≥60% token reduction
5. SNAPSHOT — Lock output format with insta

Step 1: Real Fixture First

Never write synthetic test data. Capture real command output:

```bash

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

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
.claude/skills/tdd-rust/SKILL.md

Related skills

Tags

fixture-driven-testing token-optimization snapshot-validation quality-gates test-automation edge-case-coverage regression-prevention code-cleanup integration-testing error-handling