Agent skill

Rust TDD Workflow

by rtk-ai in rtk-ai/rtk

Enforces red-green-refactor for Rust work, with idiomatic test patterns, a naming convention and a pre-commit gate of cargo fmt, clippy and test.

Apache-2.0Auto-check: notesTesting & QA

Install Rust TDD Workflow

skills CLI
$ npx skills add rtk-ai/rtk --skill rtk-tdd -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rtk-ai/rtk rtk-tdd --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rtk-ai/rtk.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/rtk-tdd .claude/skills/rtk-tdd && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rtk-tdd
GitHub stars
83k
Token cost
~753 tokens
SKILL.md length
215 words
Files
2 (incl. references)
Skills in repo
7
Repo updated
First seen
Licence
Apache-2.0

At a glance

Enforces red-green-refactor for Rust work, with idiomatic test patterns, a naming convention and a pre-commit gate of cargo fmt, clippy and test.

  • Works in 3 steps: Do NOT write production code without a… → Write only enough test to fail… → Write only enough production code to…
  • Implementing a new Rust function or feature test-first
  • SKILL.md covers Three Laws of TDD, Red-Green-Refactor Steps, Idiomatic Rust Test Patterns and Patterns by Code Type, plus 3 more sections
  • Calls cargo

What it does

The skill applies the three laws of test-driven development to Rust: no production code without a failing test, write only enough test to fail (a compile failure counts), and write only enough production code to pass. Tests go in a cfg(test) module of the same file. The agent runs the specific test and confirms it fails before implementing the minimum, and it never skips that step, because a test that passes at once tests nothing.

A pattern table covers Arrange-Act-Assert, assert_eq and assert, error-path checks with is_err, tests that return Result, should_panic, and tempfile-based tests for filesystem code. A second table maps code types such as pure functions, parsing, validation, error handling and serialization roundtrips to test shapes, and tests are named test_function_scenario. For functions that spawn commands, process exit calls, direct I/O and CLI wiring it suggests testing the parser or the pure logic instead.

Before a commit, cargo fmt --all --check, cargo clippy --all-targets and cargo test must all pass, with no allow attributes unless justified. A testing-patterns reference file is included.

When your agent uses it

  • Implementing a new Rust function or feature test-first
  • Fixing a Rust bug starting from a failing test
  • Refactoring Rust code under test coverage
  • Deciding how to test code that touches I/O or spawns commands

Example prompts

  • “Add a function that truncates long strings in src/format.rs, test first.”
  • “Fix the panic when parsing empty config input and add a regression test.”
  • “Refactor the filter module without changing behavior, running cargo test after each step.”

Requirements

  • A Rust project with cargo, rustfmt and clippy
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit e4f0509. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • cargo

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rust TDD Workflow loads about 753 tokens when it runs, and up to ~1.6k if it reads all its reference files. Until then it costs about 62 tokens; SKILL.md has 215 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~62
When it runs · the whole SKILL.md, loaded when a task matches
~753
With references · SKILL.md plus every file in references/, read only if the agent opens them
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rtk-ai/rtk at commit e4f0509, republished under its Apache-2.0 licence (© rtk-ai). 215 words, ~753 tokens.

Download SKILL.mdSave it as .claude/skills/rtk-tdd/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
rtk-tdd
description
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.
allowed-tools
Read, Write, Edit, Bash
effort
medium
tags
tdd, testing, rust, red-green-refactor, rtk

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

PatternUsageWhen
Arrange-Act-AssertBase structure for every testAlways
assert_eq! / assert!Direct comparison / booleansDeterministic values
assert!(result.is_err())Error path testingInvalid inputs
Result<()> return typeTests with ? operatorFallible functions
#[should_panic]Expected panicInvariants, preconditions
tempfile::NamedTempFileFile/I/O testsFilesystem-dependent code

Patterns by Code Type

Code TypeTest PatternExample
Pure function (str -> str)Input literal -> assert outputassert_eq!(truncate("hello", 3), "...")
Parsing/filteringRaw string -> filter -> contains/not-containsassert!(filter(raw).contains("expected"))
Validation/securityBoundary inputs -> assert boolassert!(!is_valid("../etc/passwd"))
Error handlingBad input -> is_err()assert!(parse("garbage").is_err())
Struct/enum roundtripConstruct -> serialize -> deserialize -> eqassert_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 to Result first, 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

bash
cargo fmt --all --check
cargo clippy --all-targets
cargo test

All 3 must pass. No exceptions. No #[allow(...)] without documented justification.

© rtk-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .claude/skills/rtk-tdd of rtk-ai/rtk.

  • SKILL.md
  • references/testing-patterns.md

Open the folder on GitHubat commit e4f0509

Compare with similar skills

Rust TDD Workflow next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rust TDD Workflow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rust TDD Workflow this skillrtk-ai/rtk83k—~753Automated safety check: NotesApache-2.0
Rust Testingkurealnum/dotfiles2906 repos~2.9kAutomated safety check: PassNone
MoAI TDD Workflowmodu-ai/moai-adk1.2k—~3.1kAutomated safety check: PassApache-2.0
Test-Driven Development Enforcerzereight/gitlab-mcp2k1 repos~904Automated safety check: PassMIT
Jest Testing PatternsChrisWiles/claude-code-showcase6.1k7 repos~1.5kAutomated safety check: PassNone
TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph11211 repos~2.4kAutomated safety check: PassNone

Similar skills

  • Rust Testing

    kurealnum/dotfiles

    Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage.

    290 GitHub starsUsed in 6 repos~2.9k tokens
    Testing & QAAuto-check passed
  • MoAI TDD Workflow

    modu-ai/moai-adk

    Drives test-first development through the RED, GREEN, REFACTOR cycle, with a config switch that selects between TDD and a DDD workflow for existing code.

    1.2k GitHub stars~3.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Enforces strict red-green-refactor, with a failing test first, the minimum code to pass it, then cleanup, and a quick reference for common test runners.

    2k GitHub starsUsed in 1 repo~904 tokens
    Testing & QAAuto-check passed
  • Jest Testing Patterns

    ChrisWiles/claude-code-showcase

    Jest patterns for React Native style tests: TDD discipline, mock factory functions, module and GraphQL hook mocking, custom render helpers and anti-patterns to avoid.

    6.1k GitHub starsUsed in 7 repos~1.5k tokens
    Testing & QAAuto-check passed
  • TDD Workflow

    hellangleZ/burn-in-cceverywhere-ralph

    A skill your agent uses when writing new features, fixing bugs, or refactoring code.

    112 GitHub starsUsed in 11 repos~2.4k tokens
    Testing & QAAuto-check passed
  • Testing OpenLogi UI

    AprilNEA/OpenLogi

    Verifies OpenLogi's native GPUI interface with focused tests, the component gallery and a mock agent, choosing the evidence that fits each change.

    23k GitHub stars~1.1k tokensUpdated today
    Testing & QAAuto-check passed

More from rtk-ai/rtk

  • Describes seven Rust design patterns for the RTK CLI filter modules, with when to use each, RTK examples, and notes on when a pattern is overkill.

    83k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Enforces red-green-refactor for new RTK output filters in Rust, using real captured fixtures, snapshot tests with insta and token-savings assertions.

    83k GitHub stars~1.9k tokensUpdated today
    Auto-check: notes
  • Reviews RTK's Rust code for over-engineering and verbose patterns, applying idioms like iterator chains and early returns while protecting a specific list of constraints from being simplified away.

    83k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Audits open GitHub issues, categorizes them, flags duplicates and linked PRs in three phases, with optional deep analysis and comments posted only after validation.

    83k GitHub stars~3k tokensUpdated today
    Auto-check: notes
  • PR Triage

    rtk-ai/rtk

    Audits a repository's open pull requests, deep-reviews chosen ones and drafts review comments that are only posted after you approve them.

    83k GitHub stars~2.5k tokensUpdated today
    Auto-check: notes
  • Runs issue triage and PR triage in parallel, then cross-analyzes the results to flag duplicate coverage, security gaps, P0 issues with no PR, and PR conflicts.

    83k GitHub stars~1.6k tokensUpdated today
    Auto-check: notes

Works with

Questions about Rust TDD Workflow

What does Rust TDD Workflow do?

Enforces red-green-refactor for Rust work, with idiomatic test patterns, a naming convention and a pre-commit gate of cargo fmt, clippy and test. The skill applies the three laws of test-driven development to Rust: no production code without a failing test, write only enough test to fail (a compile failure counts), and write only enough production code to pass. Tests go in a cfg(test) module of the same file.

When should I use Rust TDD Workflow?

Rust TDD Workflow fits situations like: implementing a new Rust function or feature test-first; fixing a Rust bug starting from a failing test; refactoring Rust code under test coverage; deciding how to test code that touches I/O or spawns commands.

How do I install Rust TDD Workflow in Claude Code?

Run `npx skills add rtk-ai/rtk --skill rtk-tdd -a claude-code`. Or copy the skill folder (.claude/skills/rtk-tdd in rtk-ai/rtk) into .claude/skills/rtk-tdd in your project. Claude Code loads it when a task matches its description.

How do I install Rust TDD Workflow in Codex?

Run `npx skills add rtk-ai/rtk --skill rtk-tdd -a codex`. Or copy the skill folder (.claude/skills/rtk-tdd in rtk-ai/rtk) into .agents/skills/rtk-tdd in your project. Codex loads it when a task matches its description.

Can I use Rust TDD Workflow in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rtk-ai/rtk --skill rtk-tdd -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rtk-tdd, .gemini/skills/rtk-tdd, .github/skills/rtk-tdd and .opencode/skills/rtk-tdd in your project.

What does Rust TDD Workflow need to run?

Going by SKILL.md and its folder, Rust TDD Workflow needs the command-line tools its instructions call (cargo). Our summary lists: A Rust project with cargo, rustfmt and clippy. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash.

Does Rust TDD Workflow access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Rust TDD Workflow safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Rust TDD Workflow use?

Rust TDD Workflow is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rust TDD Workflow use?

About 753 tokens (SKILL.md is roughly 3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 895 tokens, read only when the agent opens those files.

What are the alternatives to Rust TDD Workflow?

Skills that share tags, products or a category with Rust TDD Workflow: Rust Testing (kurealnum/dotfiles, 290 stars), MoAI TDD Workflow (modu-ai/moai-adk, 1.2k stars), Test-Driven Development Enforcer (zereight/gitlab-mcp, 2k stars) and Jest Testing Patterns (ChrisWiles/claude-code-showcase, 6.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rust TDD Workflow?

rtk-ai (a GitHub organization) maintains it in rtk-ai/rtk, which has 82,728 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 8, 2026.

Source: rtk-ai/rtk on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.