Sign in
Explore
Prompts · PromptTesting & SecurityReviewed

rust-test

Enforce TDD workflow for Rust. Write tests first, then implement. Verify 80%+ coverage with cargo-llvm-cov.

Kind
Prompt
Works with
Claude Code, Codex
Languages
Rust
Source
affaan-m/ECC @ d3b8a3e90890
Path
commands/rust-test.md
License
MIT
Jobs
Testing, Implementation, Guardrails
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# Rust TDD Command

This command enforces test-driven development methodology for Rust code using `#[test]`, rstest, proptest, and mockall.

## What This Command Does

1. **Define Types/Traits**: Scaffold function signatures with `todo!()`
2. **Write Tests**: Create comprehensive test module (RED)
3. **Run Tests**: Verify tests fail for the right reason
4. **Implement Code**: Write minimal code to pass (GREEN)
5. **Refactor**: Improve while keeping tests green
6. **Check Coverage**: Ensure 80%+ coverage with cargo-llvm-cov

## When to Use

Use `/rust-test` when:
- Implementing new Rust functions, methods, or traits
- Adding test coverage to existing Rust code
- Fixing bugs (write failing test first)
- Building critical business logic
- Learning TDD workflow in Rust

## TDD Cycle

```
RED     -> Write failing test first
GREEN   -> Implement minimal code to pass
REFACTOR -> Improve code, tests stay green
REPEAT  -> Next test case
```

## Example Session

````text
User: /rust-test I need a function to validate user registration

Agent:
# TDD Session: Registration Validator

## Step 1: Define Interface

```rust
// src/validator.rs
pub struct RegistrationRequest {
    pub name: String,
…