test-driven-development

Enforce a RED-GREEN-REFACTOR TDD workflow for Rust and TypeScript.

15|5|Updated Jul 1, 2025
One-click install
npx skills add https://github.com/swissarmyhammer/swissarmyhammer --skill test-driven-development-swissarmyhammer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/swissarmyhammer/swissarmyhammer/tree/main/.skills/test-driven-development
Command: npx skills add https://github.com/swissarmyhammer/swissarmyhammer --skill test-driven-development-swissarmyhammer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces a rigorous development process to ensure code quality, reduce bugs, and improve maintainability by mandating a test-first approach.

Core Features & Use Cases

  • Enforces RED-GREEN-REFACTOR cycle: Ensures every code change is preceded by a failing test, followed by minimal implementation, and then refactoring.
  • Promotes Behavior-Driven Testing: Focuses on testing observable behavior through public interfaces, not implementation details.
  • Use Case: When tasked with fixing a bug, you'll first write a test that fails due to the bug, then write the minimal code to make the test pass, and finally refactor.

Quick Start

Use the test-driven-development skill before writing any new code or fixing a bug.

Frequently Asked Questions about test-driven-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the test-driven development workflow for writing new code?

Test-driven development (TDD) is a workflow mandating a failing test before any production code, followed by minimal implementation to pass the test, and subsequent refactoring. This enforces a strict RED-GREEN-REFACTOR cycle.

How do I fix a bug using test-driven development?

To fix a bug using test-driven development, first write a test that fails due to the bug, then write the minimal code to make the test pass, and finally refactor. This behavior-driven testing approach ensures observable behavior is verified.

Does test-driven development work with Rust and TypeScript?

Test-driven development works with Rust and TypeScript, providing specific guidance for both languages. It enforces high test coverage and discourages mocking internal components while supporting behavior-driven testing through public interfaces.

How do I refactor code safely while maintaining high test coverage?

To refactor code safely while maintaining high test coverage, follow the test-driven development RED-GREEN-REFACTOR cycle. Write a failing test, implement minimal code to pass it, then refactor with confidence knowing the test verifies behavior.

Why should I avoid mocking internal components during TDD?

Avoiding mocking internal components during test-driven development promotes behavior-driven testing through public interfaces. This approach ensures high test coverage and reduces bugs by focusing on observable behavior rather than implementation details.

What are the limitations of a strict test-first development approach?

A strict test-first development approach mandates writing a failing test before any production code, which can slow down initial prototyping. However, this behavior-driven testing method reduces bugs and improves maintainability by enforcing high test coverage.