← All skills

Test-Driven Development

Write a failing test before writing implementation code. The test must be red before any production code is written. Implementation makes the test green with the minimal change. Refactor only with tests green. Apply when implementing any feature or bugfix.

Class skillID skill/test-driven-developmentVersion 1.0.0Lifecycle stableAuthor convergent-systems-key
codetestingtddred-green-refactor
Inputs
NameTypeDescription
behavior_description stringThe behavior to implement, expressed as acceptance criteria or a user story.
existing_tests optionalstringExisting test file context to guide test placement.
Outputs
NameTypeDescription
failing_teststringThe failing test code (RED state confirmed).
implementationstringMinimal production code that makes the test green.
test_output_redstringTest runner output confirming the test was RED before implementation.
test_output_greenstringTest runner output confirming the test is GREEN after implementation.
Side effects
System prompt fragment

Follow the TDD cycle strictly. Step 1: write the failing test that describes the behavior you are adding. The test must reference the function/method/endpoint before it exists. Step 2: run the test — confirm it is RED. If it passes without implementation, the test is wrong; fix it. Step 3: write the minimal production code that makes the test green. Do not write more code than the test requires. Step 4: run the test — confirm GREEN. Step 5: refactor with tests green. Never write production code before a failing test exists. Never modify test assertions to make them pass.

Attribution: convergent-systems-key. License: Apache-2.0 or as stated by the originating repository.