Index of every page on this site: llms.txt
All skills
rtk-ai avatar

/rtk-tdd

@ef0b734
by rtk-airtk-ai/rtk87k stars
5,610
Run it yourself

Enforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow.

Use this Skill: https://skilld.dev/gh/rtk-ai/rtk/rtk-tdd

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencestesting-patterns.md

≈895 tokens on demand. Your agent reads this file only when SKILL.md points to it.

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
hooks/init/ 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_cmd.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
    }
}

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning1mo5 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill enforces a standard Test-Driven Development (TDD) workflow for Rust development, utilizing idiomatic testing patterns and the standard cargo toolchain. No malicious patterns, obfuscation, or unauthorized network activities were detected.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

  • Runlayer9mo

    2/2 files flagged

  • ZeroLeaks7mo

    1 finding · Score: 86/100

Signed by skilld at ef0b734. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 hours ago.

Activeupdated 8 months ago
What it can do
Reads files Edits files Runs commands
effort
medium
tags
[
  "tdd",
  "testing",
  "rust",
  "red-green-refactor",
  "rtk"
]
All 4 allowed tools
ReadWriteEditBash

README badge

README badge for rtk-ai/rtk/rtk-tdd