mcpbeat Sign in

Test Driven Generation Skill for Claude

Generate implementation code that passes existing unit tests. Use when the user provides test files (Python pytest/unittest, Java JUnit/TestNG) and asks Claude to implement the code to make those tests pass. Supports full TDD workflow - analyzing tests, generating implementation, running tests, debugging failures, and iterating until all tests pass.

1k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
141
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill test-driven-generation

The instruction itself

16 sections, as written by the author

Test-Driven Generation

Generate implementation code that satisfies existing unit tests through an iterative test-driven development workflow.

Workflow

1. Analyze Tests

Read and understand the provided test file(s):

  • Identify what functions/classes/methods need to be implemented
  • Extract input/output expectations from assertions
  • Note edge cases, error conditions, and special behaviors
  • Understand dependencies and imports

2. Generate Implementation

Create implementation code that should satisfy the tests:

For Python:

  • Match the exact function/class signatures expected by tests
  • Implement logic to satisfy assertions
  • Handle all tested edge cases
  • Add necessary imports and dependencies

For Java:

  • Match exact method signatures and return types
  • Implement logic within the correct class structure
  • Handle exceptions as tested
  • Add required imports and annotations

3. Run Tests

Execute the test suite to verify the implementation:

Python:

pytest <test_file>.py -v
# or
python -m unittest <test_file>.py -v

Java:

mvn test
# or
gradle test
# or for single test file
javac <TestFile>.java && java org.junit.runner.JUnitCore <TestFile>

4. Debug Failures

If tests fail, analyze the failure output:

  • Read the assertion error messages carefully
  • Identify which specific test cases are failing
  • Understand what the test expected vs. what was returned
  • Locate the bug in the implementation

5. Iterate

Fix the implementation based on failure analysis:

  • Update the code to handle the failing case
  • Re-run tests to verify the fix
  • Repeat until all tests pass

Best Practices

Code Quality

  • Write clean, readable implementation code
  • Use descriptive variable names
  • Add comments for complex logic
  • Follow language conventions (PEP 8 for Python, Java naming conventions)

Test Understanding

  • Read ALL test cases before implementing
  • Don't assume - verify exact expected behavior from assertions
  • Pay attention to parametrized tests and edge cases
  • Check test fixtures and setup methods for context

Debugging Strategy

  • Start with the first failing test
  • Fix one test at a time when possible
  • After each fix, run the full suite to catch regressions
  • If stuck, re-read the test to verify understanding

Common Pitfalls

  • Type mismatches: Ensure return types match exactly (e.g., int vs float, List vs array)
  • Off-by-one errors: Carefully check boundary conditions
  • Null/None handling: Implement null checks if tests verify null behavior
  • Exception types: Raise/throw the exact exception type the test expects
  • Mutable state: Reset state between test runs if using class-level variables

Example Session

User provides test_calculator.py:

import pytest
from calculator import Calculator

def test_add():
    calc = Calculator()
    assert calc.add(2, 3) == 5
    assert calc.add(-1, 1) == 0

def test_divide():
    calc = Calculator()
    assert calc.divide(10, 2) == 5
    with pytest.raises(ValueError):
        calc.divide(10, 0)

Step 1: Analyze - need Calculator class with add() and divide() methods, divide should raise ValueError on zero

Step 2: Generate calculator.py:

class Calculator:
    def add(self, a, b):
        return a + b

    def divide(self, a, b):
        if b == 0:
            raise ValueError("Cannot divide by zero")
        return a / b

Step 3: Run pytest test_calculator.py -v

Step 4: If failure occurs, read error and identify issue

Step 5: Fix and re-run until passing

Language-Specific Notes

Python

  • Use type hints when test imports suggest them
  • Match pytest vs unittest assertion styles
  • Check for setUp/tearDown or fixtures that provide context
  • Watch for @pytest.mark.parametrize for multiple test cases

Java

  • Match access modifiers (public/private/protected)
  • Implement interfaces if tests verify interface compliance
  • Use correct exception handling (throws vs try-catch)
  • Check for @Before/@After setup methods
  • Watch for @ParameterizedTest annotations

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
Test Driven Development
by w95
×7

Use when implementing any feature or bugfix, before writing implementation code

2k tokens
Systematic Debugging
by ratacat
×7

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

10k tokens scripts
Verification Before Completion
by ZhanlinCui
×6

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

1k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Adaptyv
by christophacham
×3

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

16k tokens
Aeon
by christophacham
×3

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

19k tokens

How to use it

Copy the folder

Take arabelatso/test-driven-generation from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.