rtk-tdd
rtk-tdd enforces the red-green-refactor cycle for Rust development, automatically guiding you through failing tests, minimal implementations, and refactoring phases. It provides Rust-idiomatic testing patterns using anyhow/thiserror, cfg(test) modules, and Arrange-Act-Assert workflows, with pre-commit gates ensuring code quality.
rtk-tdd enforces test-driven development for Rust projects using red-green-refactor cycles and idiomatic testing patterns.
AI-generated summary based on this skill's SKILL.md
Install
rtk-ai/rtk/rtk-tdd · repository language: Rust
git clone https://github.com/rtk-ai/rtk
cp -r rtk/.claude/skills/rtk-tdd ~/.claude/skills/rtk-tddFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is rtk-tdd and how does it enforce test-driven development?
rtk-tdd is an Apache-2.0 licensed skill that enforces the red-green-refactor cycle for Rust development. It automatically guides you through failing tests, minimal implementations, and refactoring phases, ensuring TDD discipline throughout your Rust projects while maintaining idiomatic patterns.
How do I write rust tests first in the rtk-tdd workflow?
rtk-tdd teaches you to write failing tests before implementation using Rust-idiomatic patterns. Start with Arrange-Act-Assert structure in cfg(test) modules, use anyhow/thiserror for error handling tests, and follow rtk-tdd's guidance through the red phase (failing test), green phase (minimal implementation), and refactor phase.
What rust testing patterns does rtk-tdd recommend?
rtk-tdd provides Rust-idiomatic testing patterns including cfg(test) module setup, Arrange-Act-Assert workflows, proper test naming conventions, and error handling patterns using anyhow/thiserror. It covers unit test organization, edge case testing, and bug-fix TDD approaches aligned with Rust best practices.
How does rtk-tdd implement the red-green-refactor cycle?
rtk-tdd automates the red-green-refactor methodology by guiding you to write failing tests first, then implement minimal code to pass them, then refactor safely. It integrates with cargo test automation to validate each phase and ensures you follow this cycle consistently across your Rust projects.
Can rtk-tdd set up pre-commit quality gates for my Rust code?
Yes, rtk-tdd supports pre-commit quality gates to enforce code quality in Rust projects. These gates ensure tests pass, code follows idiomatic patterns, and TDD discipline is maintained before commits, helping your team maintain consistent testing standards.
What cargo automation does rtk-tdd provide for testing workflows?
rtk-tdd integrates cargo test automation into your TDD workflow, automating test execution across the red-green-refactor cycle. It helps you structure tests properly, organize test modules with cfg(test), and maintain efficient cargo-based testing practices throughout development.
SKILL.md
rendered from the published skill — quoted content, verbatim
Rust TDD Workflow
Three Laws of TDD
- Do NOT write production code without a failing test
- Write only enough test to fail (including compilation failure)
- Write only enough production code to pass the failing test
Cycle: RED (test fails) -> GREEN (minimum to pass) -> REFACTOR (cleanup, cargo test)
Red-Green-Refactor Steps
1. Write test in #[cfg(test)] mod tests of the SAME file
2. cargo test MODULE::tests::test_name -- must FAIL (red)
3. Implement the minimum in the function
4. cargo test MODULE::tests::test_name -- must PASS (green)
5. Refactor if needed, re-run cargo test (still green)
6. cargo fmt && cargo clippy --all-targets && cargo test (final gate)
Never skip step 2. If the test passes immediately, it tests nothing.
Idiomatic
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 2 files
.claude/skills/rtk-tdd/SKILL.md
.claude/skills/rtk-tdd/references/testing-patterns.md