Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Failing Test First TDD

    1

    Prove every behavior change with an observed failing test before writing code, so no untested behavior ever ships.

    Free

    2 usesSecurity scanned
    Failing Test First TDD

    Failing Test First TDD

    Example session with this skill installed

    I'm fixing a bug in our comments service: users can currently post comments containing only whitespace, and they shouldn't be able to. The create_comment function lives in app/services/comments.py and the suite is in tests/test_comments.py. Please add the validation using strict test-first discipline: write the failing test documenting the expected rejection, run it and confirm it fails for the right reason, then implement the minimal fix, re-run the targeted test and the full pytest suite, and report the observed red and green states.

    • Read your context and instructions
    • Compiled the failing test first

    Summary

    Added whitespace-comment rejection via a full RED → GREEN → IMPROVE cycle: one failing test observed first, minimal implementation second, whole suite green afterwards.

    StageCommandObserved outcome
    REDpytest tests/test_comments.py::test_rejects_comment_containing_only_whitespace -qFailed as intended — expected {"ok": False}, got {"ok": True}
    GREENSame targeted testPassed after a minimal text.strip() guard
    SUITEpytest -q112 passed, 0 failed, no new warnings
    def create_comment(text: str) -> dict:
        if not text.strip():
            return {"ok": False, "error": "Comment text is required"}
        return store.insert(text)
    

    Next steps

    • Add tests for the empty string and tab/newline-only payloads to force generalization
    • Write characterization tests for the edit-comment path before refactoring it
    • Sweep other validators for the same missing .strip() guard

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

    About this skill

    The problem

    Writing tests after implementation often leads to biased coverage that only confirms what the code already does, rather than what it should do. This creates false confidence and makes bugs harder to catch during the development cycle.

    What it does

    • Enforces a strict Red-Green-Improve cycle for every behavior change.
    • Identifies valid vs. invalid failure states to ensure tests are actually meaningful.
    • Guides the creation of minimal, honest implementations that solve the immediate requirement without over-engineering.
    • Provides clear criteria for safe refactoring only when the test suite is green.
    • Detects design smells like high coupling or unclear boundaries via test setup friction.

    Why this beats prompting it yourself

    General LLMs often skip straight to providing the solution, ignoring the critical failure step that proves the test's validity. This skill prevents implementation bias by forcing a stop at the "Red" phase, ensuring you never ship unverified behavior or hollow proofs.

    Use cases

    • Fixing bugs by creating a failing reproduction before writing the patch.
    • Developing new features with a clear specification of the public API.
    • Safe refactors of legacy code using characterization tests as a safety net.
    • Implementing validation rules and permission checks with verified edge-case coverage.

    Known limitations

    Requires an existing automated testing framework. Not suitable for disposable research spikes or static configuration changes.

    Assumes the project already has a runnable test suite and runner configured; without one, the first cycle spends time on setup. The strict discard-and-restart rule intentionally feels heavy for throwaway spikes, which need an explicit opt-out.

    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

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    2 uses

    Times used to date

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    • Free with an Agensi account

    Permissions

    Read Files
    Write Files

    File Scopes

    tests/**
    src/**
    app/**

    Terminal access runs the test commands that prove each red and green state; read/write scope covers the test and source files the cycle creates and edits.

    Listed1 month ago

    What's inside

    Frequently Asked Questions

    This skill enforces a strict Red-Green-Refactor workflow, ensuring every code change is preceded by a verifiable failing test to eliminate implementation bias and untested behavior.

    The skill is designed to integrate with most major AI coding agents that support custom tool-use or structured workflows, provided they have access to your local or CI testing environment.

    You will need an existing automated testing framework (like Jest, PyTest, or JUnit) configured in your project, as the skill relies on executing these suites to verify failure and success states.

    Yes, this skill is highly effective for legacy systems; it guides you through creating characterization tests to capture current behavior before you safely attempt any refactoring or bug fixes.

    You receive the specialized TDD logic, integration instructions for your AI agent, and a guide on interpreting 'valid' vs 'invalid' failure states to maximize code quality.

    Updates are included with your purchase, and the skill is versioned to ensure compatibility as underlying LLM models and coding agent capabilities evolve.

    New in Testing & Debugging