test-driven-development

bobmatnyc/claude-mpm-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill test-driven-development
0 commentsdiscussion
summary

Comprehensive TDD patterns and practices for all programming languages. This skill eliminates ~500-800 lines of redundant testing guidance per agent.

skill.md

Test-Driven Development (TDD)

Comprehensive TDD patterns and practices for all programming languages. This skill eliminates ~500-800 lines of redundant testing guidance per agent.

When to Use

Apply TDD for:

  • New feature implementation
  • Bug fixes (test the bug first)
  • Code refactoring (tests ensure behavior preservation)
  • API development (test contracts)
  • Complex business logic

TDD Workflow (Red-Green-Refactor)

1. Red Phase: Write Failing Test

Write a test that:
- Describes the desired behavior
- Fails for the right reason (not due to syntax errors)
- Is focused on a single behavior

2. Green Phase: Make It Pass

Write the minimum code to:
- Pass the test
- Not introduce regressions
- Follow existing patterns

3. Refactor Phase: Improve Code

While keeping tests green:
- Remove duplication
- Improve naming
- Simplify logic
- Extract functions/classes

Test Structure Patterns

Arrange-Act-Assert (AAA)

// Arrange: Set up test data and conditions
const user = createTestUser({ role: 'admin' });

// Act: Perform the action being tested
const result = await authenticateUser(user);

// Assert: Verify the outcome
expect(result.isAuthenticated).toBe(true);
expect(result.permissions).toContain('admin');

Given-When-Then (BDD Style)

Given: A user with admin privileges
When: They attempt to access protected resource
Then: Access is granted with appropriate permissions

Test Naming Conventions

Pattern: test_should_<expected_behavior>_when_<condition>

Examples:

  • test_should_return_user_when_id_exists()
  • test_should_raise_error_when_user_not_found()
  • test_should_validate_email_format_when_creating_account()

Language-Specific Conventions

Python (pytest):

def test_should_calculate_total_when_items_added():
    # Arrange
    cart = ShoppingCart()
    cart.add_item(Item("Book", 10.00))
    cart.add_item(Item("Pen", 1.50))

    # Act
    total = cart.calculate_total()

    # Assert
    assert total == 11.50

JavaScript (Jest):

describe('ShoppingCart', () => {
  test('should calculate total when items added', () => {
    const cart = new ShoppingCart();
    cart.addItem({ name: 'Book', price: 10.00 });
    cart.addItem({ name: 'Pen', price: 1.50 });

    const total = cart.calculateTotal();

    expect(total).toBe(11.50);
  });
});

Go:

func TestShouldCalculateTotalWhenItemsAdded(t *testing.T) {
    // Arrange
    cart := NewShoppingCart()
    cart.AddItem(Item{Name: "Book", Price: 10.00})
    cart.AddItem(Item{Name: "Pen", Price: 1.50})

    // Act
    total := cart.CalculateTotal()

    // Assert
    if total != 11.50 {
        t.Errorf("Expected 11.50, got %f", total)
    }
}

Test Types and Scope

Unit Tests

  • Scope: Single function/method
  • Dependencies: Mocked
  • Speed: Fast (< 10ms per test)
  • Coverage: 80%+ of code paths

Integration Tests

  • Scope: Multiple components
  • Dependencies: Real or test doubles
  • Speed: Moderate (< 1s per test)
  • Coverage: Critical paths and interfaces

End-to-End Tests

  • Scope: Full user workflows
  • Dependencies: Real (in test environment)
  • Speed: Slow (seconds to minutes)
  • Coverage: Core user journeys

Mocking and Test Doubles

When to Mock

  • External APIs and services
  • Database operations (for unit tests)
  • File system operations
  • Time-dependent operations
  • Random number generation

Mock Types

Stub: Returns predefined data

def get_user_stub(user_id):
    return User(id=user_id, name="Test User")

Mock: Verifies interactions

mock_service = Mock()
service.process_payment(payment_data)
mock_service.process_payment.assert_called_once_with(payment_data)

Fake: Working implementation (simplified)

class FakeDatabase:
    def __init__(self):
        self.data = {}

    def save(self, key, value):
        self.data[key] = value

    def get(self, key):
        return self.data.get(key)

Test Coverage Guidelines

Target Coverage Levels

  • Critical paths: 100%
  • Business logic: 95%+
  • Overall project: 80%+
  • UI components: 70%+

What to Test

  • ✅ Business logic and algorithms
  • ✅ Edge cases and boundary conditions
  • ✅ Error handling and validation
  • ✅ State transitions
  • ✅ Public APIs and interfaces

What NOT to Test

  • ❌ Framework internals
  • ❌ Third-party libraries
  • ❌ Trivial getters/setters
  • ❌ Generated code
  • ❌ Configuration files

Testing Best Practices

1. One Assertion Per Test (When Possible)

# Good: Focused test
def test_should_validate_email_format():
    assert is_valid_email("[email protected]") is True

# Avoid: Multiple unrelated assertions
def test_validation():
    assert is_valid_email("[email protected]") is True
    assert is_valid_phone("123-456-7890") is True  # Different concept

2. Test Independence

# Good: Each test is self-contained
def test_user_creation():
    user = create_user("[email protected]")
    assert user.email == "[email protected]"

# Avoid: Tests depending on execution order
shared_user = None

def test_create_user():
    global shared_user
    shared_user = create_user("[email protected]")

def test_update_user():  # Depends on previous test
    shared_user.name = "Updated"

3. Descriptive Test Failures

# Good: Clear failure message
assert result.status == 200, f"Expected 200, got {result.status}: {result.body}"

# Avoid: Unclear failure
assert result.status == 200

4. Test Data Builders

# Good: Reusable test data creation
def create_test_user(**overrides):
    defaults = {
        'email': '[email protected]',
        'name': 'Test User',
        'role': 'user'
    }
    return User(**{**defaults, **overrides}
how to use test-driven-development

How to use test-driven-development on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add test-driven-development
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill test-driven-development

The skills CLI fetches test-driven-development from GitHub repository bobmatnyc/claude-mpm-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/test-driven-development

Reload or restart Cursor to activate test-driven-development. Access the skill through slash commands (e.g., /test-driven-development) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.668 reviews
  • Dev Okafor· Dec 24, 2024

    test-driven-development has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Layla Abebe· Dec 12, 2024

    Keeps context tight: test-driven-development is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Evelyn Nasser· Dec 12, 2024

    We added test-driven-development from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Aditi Haddad· Dec 12, 2024

    I recommend test-driven-development for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Nia Malhotra· Dec 8, 2024

    test-driven-development fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Yuki Gupta· Dec 8, 2024

    test-driven-development reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ganesh Mohane· Dec 4, 2024

    test-driven-development is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Olivia Harris· Nov 27, 2024

    I recommend test-driven-development for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Yuki Khanna· Nov 27, 2024

    Registry listing for test-driven-development matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Sakshi Patil· Nov 23, 2024

    Keeps context tight: test-driven-development is the kind of skill you can hand to a new teammate without a long onboarding doc.

showing 1-10 of 68

1 / 7