Back to Skills

tdd-workflow

verified

This skill implements test-driven development workflow using the red-green-refactor cycle. Use when building new features or fixing bugs that require test coverage. Framework-agnostic methodology that works with any testing framework and programming language. Triggers on requests to implement features using TDD, write tests first, or follow test-driven development practices.

View on GitHub

Marketplace

majestic-marketplace

majesticlabs-dev/majestic-marketplace

Plugin

majestic-engineer

Repository

majesticlabs-dev/majestic-marketplace
19stars

plugins/majestic-engineer/skills/tdd-workflow/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/majesticlabs-dev/majestic-marketplace/blob/main/plugins/majestic-engineer/skills/tdd-workflow/SKILL.md -a claude-code --skill tdd-workflow

Installation paths:

Claude
.claude/skills/tdd-workflow/
Powered by add-skill CLI

Instructions

# TDD Workflow

## Overview

This skill guides the implementation of features using Test-Driven Development (TDD) principles. TDD is a disciplined, framework-agnostic approach where tests are written before implementation code, ensuring comprehensive test coverage and driving clean, testable design.

## Core Principle

**Never write implementation code before a failing test exists for that behavior.**

## Red-Green-Refactor Cycle

### 1. Red Phase: Write a Failing Test

**Goal:** Express the expected behavior through a test that fails.

**Process:**
- Select one small, specific behavior from the requirements
- Write a descriptive test that clearly expresses the expected behavior
- Run the test to confirm it **fails** (red)
- The failure should be for the right reason (not a syntax error or missing dependency)

**Why it must fail first:** A test that passes before any implementation is written might be testing the wrong thing or not actually exercising the code.

### 2. Green Phase: Minimal Implementation

**Goal:** Make the test pass with the simplest possible implementation.

**Process:**
- Implement only the minimal code necessary to pass the failing test
- Resist the urge to add extra features or handle edge cases not yet covered by tests
- Focus on making it work, not making it perfect
- Run the test to confirm it **passes** (green)

**Key principle:** Write the simplest code that could possibly work. Even hardcoding values is acceptable if it makes the current test pass - subsequent tests will force generalization.

### 3. Refactor Phase: Improve Quality

**Goal:** Improve code quality while maintaining passing tests.

**Process:**
- Review both implementation and test code for improvements
- Remove duplication (DRY principle)
- Improve naming and clarity
- Extract methods or classes if responsibilities are growing
- Apply language-specific idioms and patterns
- Ensure tests remain readable and maintainable
- Run tests after each refactoring step to ensure they

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5874 chars