Test Driven Development logo

Test Driven Development

Community
korallis
test-driven-development

Implement test-driven development (TDD) workflow using the red-green-refactor cycle. Use when writing new features, fixing bugs, or refactoring existing code. Always write the failing test first, then implement minimal code to pass, then refactor. Essential for ensuring code reliability, preventing regressions, improving design through testability requirements, documenting expected behavior through tests, enabling confident refactoring, and maintaining high code quality standards throughout the development process.

Overview

Publisherkorallis
RepositoryDroidz
Skill nametest-driven-development
Stars
89
Forks
9
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by korallis on GitHub. Read the source before you install it.

Installation

Install the Test Driven Development AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/korallis/Droidz.git /tmp/Droidz
mkdir -p .claude/skills
cp -r /tmp/Droidz/droidz_installer/payloads/claude/default/skills/test-driven-development .claude/skills/test-driven-development
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Test Driven Development in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Test Driven Development on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Test Driven Development is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Test-Driven Development (TDD)

When to use this skill

  • Writing new features or functionality from scratch
  • Fixing bugs with regression tests to prevent recurrence
  • Refactoring existing code safely with test coverage
  • Adding test coverage to untested legacy code
  • Ensuring code behaves as expected before implementation
  • Improving code design through testability constraints
  • Documenting expected behavior and edge cases
  • Building critical business logic that must be correct
  • Developing APIs or libraries with clear contracts
  • Working on projects requiring high reliability
  • Implementing complex algorithms or business rules
  • Collaborating in teams where tests serve as documentation

Implement the red-green-refactor cycle for reliable, testable code.

TDD Cycle

1. RED - Write a Failing Test

Write a test that describes the desired behavior BEFORE implementing:

python
def test_user_can_register():
    """Test that a user can successfully register with valid data."""
    result = register_user(email="test@example.com", password="secure123")
    assert result.success is True
    assert result.user.email == "test@example.com"

Why this works:

  • Forces clear requirements thinking
  • Catches specification issues early
  • Provides immediate feedback on implementation
  • Creates living documentation

2. GREEN - Write Minimal Code to Pass

Implement ONLY what's needed to make the test pass:

python
def register_user(email: str, password: str) -> RegistrationResult:
    """Register a new user with email and password."""
    user = User(email=email)
    return RegistrationResult(success=True, user=user)

Resist the urge to:

  • Add features not covered by tests
  • Over-engineer the solution
  • Optimize prematurely

3. REFACTOR - Improve Code Quality

With tests passing, improve the code structure:

python
def register_user(email: str, password: str) -> RegistrationResult:
    """Register a new user with email and password."""
    validate_email(email)
    validate_password(password)
    
    hashed_password = hash_password(password)
    user = User(email=email, password_hash=hashed_password)
    user.save()
    
    return RegistrationResult(success=True, user=user)

Refactor for:

  • Better naming
  • Removed duplication
  • Improved structure
  • Enhanced readability

Best Practices

Start with the Simplest Test

python
# Good - Start simple
def test_add_returns_sum():
    assert add(2, 3) == 5

# Avoid - Don't start with edge cases
def test_add_handles_overflow_with_large_numbers():
    assert add(sys.maxsize, 1) == expected_overflow_behavior

Test One Thing at a Time

python
# Good - Single concern
def test_user_registration_creates_user():
    result = register_user("test@example.com", "pass123")
    assert result.user is not None

def test_user_registration_hashes_password():
    result = register_user("test@example.com", "pass123")
    assert result.user.password_hash != "pass123"

# Avoid - Multiple assertions
def test_user_registration():
    result = register_user("test@example.com", "pass123")
    assert result.user is not None
    assert result.user.password_hash != "pass123"
    assert result.user.email == "test@example.com"
    assert result.success is True

Use Descriptive Test Names

python
# Good - Describes behavior
def test_invalid_email_returns_validation_error()
def test_duplicate_email_raises_already_exists_error()
def test_successful_registration_sends_welcome_email()

# Avoid - Vague names
def test_register()
def test_email()
def test_validation()

Follow the Three A's Pattern

python
def test_user_can_update_profile():
    # Arrange - Set up test data
    user = create_test_user(email="test@example.com")
    
    # Act - Execute the operation
    result = user.update_profile(name="John Doe", bio="Developer")
    
    # Assert - Verify the outcome
    assert result.success is True
    assert user.name == "John Doe"
    assert user.bio == "Developer"

Common Patterns

Testing Exceptions

python
def test_registration_with_invalid_email_raises_error():
    with pytest.raises(ValidationError) as exc:
        register_user(email="invalid", password="pass123")
    
    assert "valid email" in str(exc.value)

Testing Async Code

python
@pytest.mark.asyncio
async def test_async_user_registration():
    result = await register_user_async("test@example.com", "pass123")
    assert result.success is True

Using Fixtures

python
@pytest.fixture
def test_user():
    return User(email="test@example.com", name="Test User")

def test_user_can_login(test_user):
    result = login(test_user.email, "correct_password")
    assert result.success is True

Mocking External Dependencies

python
def test_user_registration_sends_email(mocker):
    # Mock the email service
    mock_send = mocker.patch('services.email.send_welcome_email')
    
    register_user("test@example.com", "pass123")
    
    # Verify email was sent
    mock_send.assert_called_once_with("test@example.com")

Verification Checklist

Before completing TDD implementation:

  • Test written BEFORE implementation
  • Test fails initially (RED phase confirmed)
  • Minimal code added to pass test (GREEN phase)
  • Code refactored while keeping tests green
  • Test names clearly describe behavior
  • Each test focuses on one behavior
  • No untested code paths remain
  • All tests pass consistently
  • Code is readable and maintainable

Benefits of TDD

  1. Better Design - Writing tests first leads to more modular, testable code
  2. Confidence - Comprehensive test suite catches regressions
  3. Documentation - Tests serve as living documentation
  4. Faster Debugging - Failures pinpoint exact issues
  5. Reduced Bugs - Edge cases caught during development

When NOT to Use Strict TDD

  • Rapid prototyping/proof of concepts
  • UI layout experimentation
  • Exploratory coding (learning new APIs)
  • Trivial getter/setter methods

For these cases, write tests after implementation but before committing.

Integration with Development Workflow

bash
# TDD development loop
git checkout -b feature/user-registration

# 1. Write failing test
# 2. Run tests (should fail)
pytest tests/test_registration.py

# 3. Implement minimal code
# 4. Run tests (should pass)
pytest tests/test_registration.py

# 5. Refactor
# 6. Run tests (should still pass)
pytest tests/test_registration.py

# Commit when all tests pass
git add .
git commit -m "feat: implement user registration with TDD"

References

Frequently asked questions

What does the Test Driven Development AI skill do?

Implement test-driven development (TDD) workflow using the red-green-refactor cycle. Use when writing new features, fixing bugs, or refactoring existing code. Always write the failing test first, then implement minimal code to pass, then refactor. Essential for ensuring code reliability, preventing regressions, improving design through testability requirements, documenting expected behavior through tests, enabling confident refactoring, and maintaining high code quality standards throughout the development process.

Why use Test Driven Development on TypingMind?

Because you install it once and use it with any model. Test Driven Development is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Test Driven Development in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/korallis/Droidz/tree/main/droidz_installer/payloads/claude/default/skills/test-driven-development. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Test Driven Development?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Test Driven Development?

As many as you like. As long as a model supports skills, you can use Test Driven Development with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Test Driven Development AI skill free?

It is published on GitHub by korallis. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇