
Rtk Tdd
- 1.2k installs
- 74.8k repo stars
- Updated August 3, 2026
- rtk-ai/rtk
rtk-tdd is a test-driven development skill that applies red-green-refactor TDD practices for backend and API work for developers who want tests to drive service and endpoint design.
About
rtk-tdd is a test-driven development skill from rtk-ai/rtk that applies TDD practices specifically to backend and API work. Listed on skills.sh with 724 installs and rank 7039, rtk-tdd systematizes the red-green-refactor loop so coding agents write failing tests before implementation. Developers reach for rtk-tdd when building REST or RPC endpoints, service layers, or data access code where test coverage should shape the API contract. The skill fits backend engineers who want agents to follow disciplined TDD rather than bolting tests on after implementation.
- 724 installs
- TDD workflow for backend code
Rtk Tdd by the numbers
- 1,230 all-time installs (skills.sh)
- +50 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #510 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/rtk-ai/rtk --skill rtk-tddAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.2k |
|---|---|
| repo stars | ★ 74.8k |
| Last updated | August 3, 2026 |
| Repository | rtk-ai/rtk ↗ |
How do you apply TDD to backend API development?
Applies test-driven development practices for backend and API work.
Who is it for?
Backend developers building APIs or services who want coding agents to follow strict test-driven development from the first failing test.
Skip if: Frontend-only UI work, one-off scripts, or teams that prefer integration tests written after feature completion.
When should I use this skill?
A user starts backend or API work and wants tests written first, or explicitly asks for test-driven development on services or endpoints.
What you get
Failing tests, passing implementation, and refactored backend or API code following TDD discipline.
- Failing tests
- Passing backend implementation
By the numbers
- 724 installs on skills.sh
- Rank 7039 on skills.sh
Files
Rust TDD Workflow
Three Laws of TDD
1. Do NOT write production code without a failing test 2. Write only enough test to fail (including compilation failure) 3. 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 Rust Test Patterns
| Pattern | Usage | When |
|---|---|---|
| Arrange-Act-Assert | Base structure for every test | Always |
assert_eq! / assert! | Direct comparison / booleans | Deterministic values |
assert!(result.is_err()) | Error path testing | Invalid inputs |
Result<()> return type | Tests with ? operator | Fallible functions |
#[should_panic] | Expected panic | Invariants, preconditions |
tempfile::NamedTempFile | File/I/O tests | Filesystem-dependent code |
Patterns by Code Type
| Code Type | Test Pattern | Example |
|---|---|---|
| Pure function (str -> str) | Input literal -> assert output | assert_eq!(truncate("hello", 3), "...") |
| Parsing/filtering | Raw string -> filter -> contains/not-contains | assert!(filter(raw).contains("expected")) |
| Validation/security | Boundary inputs -> assert bool | assert!(!is_valid("../etc/passwd")) |
| Error handling | Bad input -> is_err() | assert!(parse("garbage").is_err()) |
| Struct/enum roundtrip | Construct -> serialize -> deserialize -> eq | assert_eq!(from_str(to_str(x)), x) |
Naming Convention
test_{function}_{scenario}
test_{function}_{input_type}Examples: test_truncate_edge_case, test_parse_invalid_input, test_filter_empty_string
When NOT to Use Pure TDD
- Functions calling
Command::new()-> test the parser, not the execution std::process::exit()-> refactor toResultfirst, then test the Result- Direct I/O (SQLite, network) -> use tempfile/mock or test the pure logic separately
- Main/CLI wiring -> covered by integration/smoke tests
Pre-Commit Gate
cargo fmt --all --check
cargo clippy --all-targets
cargo testAll 3 must pass. No exceptions. No #[allow(...)] without documented justification.
RTK Testing Patterns Reference
Untested Modules Backlog
Prioritized by testability (pure functions first, I/O-heavy last).
High Priority (pure functions, trivial to test)
| Module | Testable Functions | Notes |
|---|---|---|
diff_cmd.rs | compute_diff, similarity, truncate, condense_unified_diff | 4 pure functions, 0 tests |
env_cmd.rs | mask_value, is_lang_var, is_cloud_var, is_tool_var, is_interesting_var | 5 categorization functions |
Medium Priority (need tempfile or parsed input)
| Module | Testable Functions | Notes |
|---|---|---|
tracking.rs | estimate_tokens, Tracker::new, query methods | Use tempfile for SQLite |
config.rs | Config::default, config parsing | Test default values and TOML parsing |
deps.rs | Dependency file parsing | Test with sample Cargo.toml/package.json strings |
summary.rs | Output type detection heuristics | Pure string analysis |
Low Priority (heavy I/O, CLI wiring)
| Module | Testable Functions | Notes |
|---|---|---|
container.rs | Docker/kubectl output filters | Requires mocking Command output |
find_cmd.rs | Directory grouping logic | Filesystem-dependent |
wget_cmd.rs | compact_url, format_size, truncate_line, extract_filename_from_output | Some pure helpers worth testing |
gain.rs | Display formatting | Depends on tracking DB |
init.rs | CLAUDE.md generation | File I/O |
main.rs | CLI routing | Covered by smoke tests |
RTK Test Patterns
Pattern 1: Filter Function (most common in RTK)
#[test]
fn test_FILTER_happy_path() {
// Arrange: raw command output as string literal
let input = r#"
line of noise
line with relevant data
more noise
"#;
// Act
let result = filter_COMMAND(input);
// Assert: output contains expected, excludes noise
assert!(result.contains("relevant data"));
assert!(!result.contains("noise"));
}Used in: git.rs, grep_cmd.rs, lint_cmd.rs, tsc_cmd.rs, vitest_cmd.rs, pnpm_cmd.rs, next_cmd.rs, prettier_cmd.rs, playwright_cmd.rs, prisma_cmd.rs
Pattern 2: Pure Computation
#[test]
fn test_FUNCTION_deterministic() {
assert_eq!(truncate("hello world", 8), "hello...");
assert_eq!(truncate("short", 10), "short");
}Used in: gh_cmd.rs (truncate), utils.rs (truncate, format_tokens, format_usd)
Pattern 3: Validation / Security
#[test]
fn test_VALIDATOR_rejects_injection() {
assert!(!is_valid("malicious; rm -rf /"));
assert!(!is_valid("../../../etc/passwd"));
}Used in: pnpm_cmd.rs (is_valid_package_name)
Pattern 4: ANSI Stripping
#[test]
fn test_strip_ansi() {
let input = "\x1b[32mgreen\x1b[0m normal";
let output = strip_ansi(input);
assert_eq!(output, "green normal");
assert!(!output.contains("\x1b["));
}Used in: vitest_cmd.rs, utils.rs
Test Skeleton Template
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_FUNCTION_happy_path() {
// Arrange
let input = r#"..."#;
// Act
let result = FUNCTION(input);
// Assert
assert!(result.contains("expected"));
assert!(!result.contains("noise"));
}
#[test]
fn test_FUNCTION_empty_input() {
let result = FUNCTION("");
assert!(...);
}
#[test]
fn test_FUNCTION_edge_case() {
// Boundary conditions: very long input, special chars, unicode
}
}Related skills
How it compares
Pick rtk-tdd when you want TDD discipline specifically for backend and API layers rather than general test generation after the fact.
FAQ
What does rtk-tdd specialize in?
rtk-tdd applies test-driven development practices to backend and API work. The skill guides coding agents through red-green-refactor cycles where failing tests are written before service or endpoint implementation.
How popular is rtk-tdd on skills.sh?
rtk-tdd from rtk-ai/rtk shows 724 installs on skills.sh with rank 7039. It is listed as a well-known community skill for backend TDD workflows.