Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    TDD Loop: Red-Green-Refactor in Verified Baby Steps

    2

    - **Green**: minimum code to pass, whole suite run every cycle, tests never bent to fit the code.

    Free

    10 uses5.0 (1 review)
    TDD Loop: Red-Green-Refactor in Verified Baby Steps

    TDD Loop: Red-Green-Refactor in Verified Baby Steps

    Example session with this skill installed

    Use TDD to add shipping cost calculation to our checkout (TypeScript + Vitest): base 4.90 € up to 1 kg, +1.20 € per extra kg, free from 50 €, international uses a zone table.

    • Read your context and instructions
    • Compiled the tdd loop

    Setup

    Detected Vitest 2, src/**/*.spec.ts, builders in test/builders.ts. Baseline: 84 tests green.

    Test list

    • empty order costs 0
    • 1 kg domestic costs 4.90
    • 3 kg domestic costs 7.30
    • 1.5 kg rounds up to next kg (discovered)
    • order ≥ 50 € ships free
    • exactly 50 € ships free (boundary)
    • international uses zone table
    • unknown country throws UnsupportedDestinationError
    • negative weight rejected

    Cycles

    ✅ #1 empty order costs 0 - red (expected undefined to be 0) → green → refactor (85 tests, 0.6s)
    ✅ #2 1 kg domestic 4.90 - hard-coded return 4.9
    ✅ #3 3 kg domestic 7.30 - triangulation forced the formula BASE + max(0, kg-1) * PER_KG
    ✅ #4 1.5 kg rounds up - new item found during #3; Math.ceil
    ✅ #5/#6 free shipping ≥ 50 € incl. boundary - first attempt used >; boundary test caught it
    ✅ #7 zone table - extracted ZONES constant in refactor step
    ✅ #8 unknown country throws typed error
    ✅ #9 negative weight rejected

    export function calculateShipping({ total, weightKg, country }: Order): number {
      if (weightKg < 0) throw new RangeError('weightKg must be >= 0')
      if (weightKg === 0) return 0
      if (total >= FREE_FROM) return 0
      const zone = zoneFor(country) // throws UnsupportedDestinationError
      return round2(zone.base + Math.max(0, Math.ceil(weightKg) - 1) * zone.perKg)
    }
    

    Done

    • 9 new tests, suite 93/93 green (0.9s), no .only/skips
    • tsc --noEmit and eslint clean
    • Commits: 9 cycles as test:/feat:/refactor:

    Question: should free shipping also apply to international orders? Currently yes - add a test if you want it domestic-only.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Stop letting your agent write code first and "tests" later

    Agents love to write 300 lines of code and then tests that just confirm what the code does. TDD Loop enforces real test-driven development, so every line exists because a test needed it.

    What it does

    • Setup: detects your test framework, runner, naming and mocking conventions; runs the suite to get a green baseline.
    • Test list as the plan: turns the request into small behaviours ordered from degenerate case to happy path, boundaries and errors.
    • Red: one behaviour-focused test at a time, and it must fail for the expected reason (not an import error).
    • Green: minimum code to pass, whole suite run every cycle, tests never bent to fit the code.
    • Refactor: clean code and tests with everything green.
    • Progress log per cycle, optional commit per cycle (test: / feat: / refactor:).
    • Bug-fix mode: reproduce with a failing test, minimal fix, root cause in 1-2 lines, regression guard kept.
    • Quality rules: deterministic tests (fake clock, no real network), mocks only at boundaries, fakes over deep mocks, baby steps with revert when a cycle grows too big.
    • Done means done: list empty, suite green, no .only/skipped tests, lint and typecheck clean.

    Includes

    • SKILL.md workflow
    • references/test-list.md - how to order behaviours, with an example
    • references/test-quality.md - good tests in TS/Python, smells and fixes, test doubles, runner commands for 7 ecosystems

    Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI and any SKILL.md-compatible agent.

    Cycles exceeding 10 minutes trigger a revert to smaller steps. Deep mocking of the unit under test is avoided. Requires an existing test runner configuration.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    5.0
    1 review
    5
    1
    4
    0
    3
    0
    2
    0
    1
    0

    This skill has been used 10 times.

    Trust & safety

    Security scan

    Security scan passed 10 days ago

    • Free with an Agensi account

    Requires

    vitest
    Node.js
    jest

    Permissions

    No special permissions declared or detected

    Listed10 days ago
    Updated5 days ago

    What's inside

    Frequently Asked Questions

    The skill automatically detects your project's test framework (like Jest or pytest) and manages a strict Red-Green-Refactor cycle, preventing the AI from writing production code until a failing test is established.

    It is compatible with any agent capable of file system access and shell execution, supporting major ecosystems including JavaScript, Python, Go, Rust, and Ruby.

    The skill requires an existing testing framework to be present; upon activation, it performs an environment scan to identify your test runners and mocking conventions automatically.

    You receive the full TDD workflow logic, the environment detection module, and a standardized 'test-list.md' template for tracking progress, along with documentation for integration.

    If a development cycle results in an overly large code diff or exceeds a 10-minute execution window, the skill will automatically trigger a revert to the last 'Green' state to maintain project integrity.

    Yes, it is ideal for legacy code; the skill focuses on creating reproduction tests for bugs or wrapping existing logic in tests before any refactoring takes place.

    New in Testing & Debugging