Skill

Implement Minimal Code for TDD Green Phase

Guides the GREEN phase of TDD: minimal Django and Express implementations to pass failing tests before refactoring.


71
Spark score
out of 100
Updated yesterday
Version 15.7.0

Add to Favorites

Why it matters

Quickly achieve the 'green' phase in Test-Driven Development by implementing the simplest possible code to satisfy failing tests.

Outcomes

What it gets done

01

Identify the smallest code change to pass a failing test.

02

Implement minimal functionality to meet test requirements.

03

Record technical debt for later refactoring.

04

Ensure code changes are scoped to the failing behavior.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-tdd-workflows-tdd-green | bash

Overview

Green Phase: Simple function

Focuses on the GREEN phase of TDD - writing the minimal implementation to pass a failing test - illustrated with Django (function view to generic ListView) and Express.js (inline handler to layered controller) before/after examples. Use when moving from a failing test to a minimal passing implementation; not for the refactor phase, new requirements, or full architectural redesigns.

What it does

This skill focuses narrowly on the GREEN phase of a red-green-refactor TDD cycle: writing the smallest possible implementation that makes a failing test pass, before any refactoring happens. It illustrates the idea with two worked examples - a Django view evolving from a simple function-based view (product_list) through a class-based View to a generic ListView, and an Express.js endpoint evolving from inline route logic through a validation middleware to a fully layered controller/service structure. In both cases the GREEN-phase code is deliberately minimal, with the more structured versions explicitly labeled as REFACTOR steps that come afterward.

When to use - and when NOT to

Use this skill specifically when moving from RED to GREEN in a TDD cycle - you have a failing test and need to implement just enough behavior to pass it, keeping the implementation intentionally simple rather than reaching for the "proper" architecture immediately. It also applies when you want to record shortcuts or technical debt taken during GREEN for a later REFACTOR pass.

Do not use it when you're already in the refactor phase and optimizing for design or performance, when tests are already passing and you're adding new requirements (that calls for a new RED phase first), or when what's actually needed is a full architectural redesign rather than an incremental TDD step.

Inputs and outputs

Input is a failing test (or the next failing test in a suite) describing required behavior. Output is the smallest code change that makes it pass - illustrated here as a bare Django function view or an inline Express route handler - plus a note of any shortcuts taken for the refactor phase to address later.

# Django GREEN phase example (function-based view)
def product_list(request):
    products = Product.objects.all()
    return JsonResponse({'products': list(products.values())})

Integrations

Worked examples cover Django (function view -> class-based View -> generic ListView) and Express.js (inline handler -> validation middleware -> layered controller/service), and the skill points to a companion resources/implementation-playbook.md for further pattern detail.

Who it's for

Developers actively running a TDD cycle who need a concrete reminder to keep the GREEN-phase implementation minimal and defer structural improvements (layering, generic views, middleware extraction) to the REFACTOR phase, rather than gold-plating the first passing version.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.