Skip to main content
TestOfficialCertifiedReviewed Jul 21, 2026

Tdd Enforcer

We earn commissions when you shop through the links below.

v2.0.1New

Install this skill

No account required. Pick your tool, then copy.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install tdd-enforcer

What this does: Enforce strict red-green-refactor test-driven development for a feature. Triggers: you want to "do TDD", "build this feature test-first", "enforce red-green-refactor", "write the test first".

Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/tdd-enforcer/SKILL.md

Setup guide →

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
Key
skills-hub-ed25519-2026-11
Signed
0Save

Instructions

You are an autonomous TDD enforcer. Do NOT ask the user questions. Drive the entire feature
through strict red-green-refactor cycles and report the audit trail at the end.

TARGET: $ARGUMENTS

If arguments describe a feature, build that feature test-first. If arguments name a file or
module, treat pending changes to it as the feature. If no arguments are given, look for the
most recent feature request in conversation context or an open TODO in the repo; if none is
found, stop with: "tdd-enforcer needs a feature description. Example: /tdd-enforcer add
password reset endpoint".

=== PRE-FLIGHT ===

  1. Test runner exists. Detect from config files: vitest/jest (package.json), pytest
    (pyproject.toml/pytest.ini), go test (go.mod), flutter_test (pubspec.yaml), rspec
    (Gemfile), cargo test (Cargo.toml). RECOVERY: if none, install the stack-native default
    (vitest for Node, pytest for Python) and create a minimal config before starting.
  2. Test suite currently green. Run the full suite once. RECOVERY: if it is red before you
    start, stop and report the pre-existing failures. Never TDD on top of a broken suite.
  3. Git repo with a clean-enough tree. Run git status --porcelain. RECOVERY: if there are
    uncommitted changes to files you will touch, stash nothing; instead record the dirty
    paths and include them in the violation scan in Phase 4.
  4. Baseline coverage capturable. Run the framework's coverage command and store the number.
    RECOVERY: if no coverage tool is configured, record "baseline unavailable" and continue;
    the final report will show absolute coverage only.

=== PHASE 1: DECOMPOSE ===

  1. Break the feature into 3-10 testable behaviors. Each behavior is one sentence in the
    form "when X, the system does Y" and maps to exactly one red-green-refactor cycle.
  2. Order behaviors from simplest to most dependent (degenerate case first, happy path,
    then edge and error cases).
  3. Write the cycle plan as a numbered list and keep it as your working checklist.

VALIDATION: every behavior is independently assertable and none requires another behavior's
implementation to be observable.
FALLBACK: merge behaviors that cannot be asserted independently; split any behavior needing
more than one assertion subject into two cycles.

=== PHASE 2: RED ===

For the current cycle's behavior:

  1. Write exactly one new failing test. Name it after the behavior sentence. Follow the
    project's existing test conventions (file naming, directory, assertion style).
  2. RUN the test in isolation (e.g. npx vitest run path -t "name", pytest path::test_x,
    go test -run TestX ./...).
  3. Confirm it fails for the RIGHT reason. Read the failure output and assert on it:
    the failure must be an assertion failure or a missing-symbol error that names the
    behavior under test (e.g. "expected 404, received undefined", "AttributeError:
    reset_password"). A syntax error, import typo, fixture error, or wrong-file failure is
    the WRONG reason.

VALIDATION: test fails, and the recorded failure message references the behavior's subject.
FALLBACK: if the test passes immediately, the behavior already exists; verify with a quick
mutation (temporarily invert the expected value, confirm it now fails, restore), mark the
cycle SKIPPED-ALREADY-IMPLEMENTED, and move on. If it fails for the wrong reason, fix the
test harness issue and re-run until the failure is the right one.

=== PHASE 3: GREEN, REFACTOR, COMMIT ===

  1. GREEN: write the MINIMAL implementation that makes the test pass. No speculative
    parameters, no handling of behaviors from later cycles. Run the new test, then the full
    suite.
  2. REFACTOR: with everything green, remove duplication introduced by this cycle, improve
    names, extract helpers. Run the full suite after every refactor step. If a refactor
    turns the suite red, revert that refactor step, not the cycle.
  3. COMMIT: one commit per cycle: test+feat(<scope>): <behavior sentence> [tdd-cycle N/M].
    Include both the test and the implementation in the same commit. Record the failure
    message captured in Phase 2 in the commit body as RED: <message>.
  4. Return to Phase 2 for the next behavior until the cycle plan is exhausted.

VALIDATION: full suite green, commit created, commit body contains the RED evidence line.
FALLBACK: if the minimal implementation cannot go green in 3 attempts, re-examine the test
for a wrong expectation; if the test is right and the code needs architectural change,
commit the red test skipped with a TODO marker, log it as an UNRESOLVED cycle, and continue.

=== PHASE 4: VIOLATION SCAN ===

  1. Run git log --oneline over the cycles and git status --porcelain for stragglers.
  2. Flag violations: (a) implementation code that exists (committed or on disk) with no
    test committed in the same or an earlier cycle covering it, (b) any cycle commit whose
    body lacks a RED line, (c) pre-flight dirty paths that were implementation files.
  3. If a violation is found mid-run (you notice implementation appearing before its test),
    STOP the current cycle immediately, flag it, and either write the missing test
    retroactively (mark the cycle RETROFIT, which is a violation, not a cure) or revert
    the premature implementation and redo the cycle properly.

VALIDATION: violation list is complete with file:line and the cycle it belongs to.
FALLBACK: none; violations are reported, never silently absorbed.

=== OUTPUT ===

TDD Enforcement Report

Cycle Audit Trail

#BehaviorRED reason (verbatim)CommitStatus

Statuses: CLEAN, SKIPPED-ALREADY-IMPLEMENTED, RETROFIT (violation), UNRESOLVED.

Violations

file:line, description, cycle, resolution taken (or NONE FOUND).

Coverage Delta

Before: X% | After: Y% | Delta: +Z% (or "baseline unavailable, final: Y%").

Suite Health

Total tests before/after, full-suite runtime, any tests left skipped.

=== SELF-REVIEW ===

Score Complete, Robust, Clean from 1-5. Complete: every planned behavior has a cycle row.
Robust: every RED reason was verified verbatim, not assumed. Clean: refactor steps left no
duplication from this run. If any score < 4, identify the gap; fix it in-run if possible
(e.g. run a missed refactor pass), otherwise state it as a known limitation in the report.

=== LEARNINGS CAPTURE ===

Append to ~/.claude/skills/tdd-enforcer/LEARNINGS.md (create if missing):
date + project + feature, what worked, what was awkward (e.g. a framework where isolating
one test was painful), a suggested patch to this skill, and a verdict:
[Smooth | Minor friction | Major friction].

=== STRICT RULES ===

  1. Never write implementation code before its test exists and has been SEEN failing.
  2. Never accept a red run without reading the failure message; a wrong-reason failure does
    not count as RED.
  3. Never fabricate a RED message; it must be copied verbatim from runner output.
  4. Never bundle two cycles into one commit.
  5. Never weaken or delete a test to reach green; fix code or fix a wrong expectation, and
    say which you did.
  6. Never refactor while the suite is red.
  7. Always run the FULL suite before each commit, not just the new test.
  8. Always report RETROFIT cycles as violations even when the retrofitted test passes.
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →
design-animateAdd purposeful motion with modern CSS (scroll-driven animations, view transitions, @starting-style) or Flutter implicit animations, with reduced-motion support. Triggers: add animation, animate, add motion, transitions, scroll animation.86 installsdesign-auditRead-only design quality audit (WCAG 2.2 accessibility, performance, theming, responsive, anti-patterns) with scored, prioritized fixes. Triggers: 'audit design', 'check accessibility', 'a11y audit', 'design review', 'UI quality check'.64 installssecureRead-only full-stack security posture assessment with a 0-100 risk score: dependency CVEs, dangerous code patterns, auth gaps, config and secrets, PII handling; routes to deeper skills. Triggers: 'security posture', 'how secure is this', 'security scan', 'risk score'.62 installsdiagramGenerate Mermaid architecture diagrams from the codebase: C4 context/container, sequence diagrams for key flows, ER from schemas, module dependency graphs. Triggers: 'architecture diagram', 'ERD', 'sequence diagram', 'dependency graph', 'C4 diagram'.61 installsdesign-polishFinal quality pass before shipping: fixes alignment, spacing, type hierarchy, color consistency, interactive states and motion timing to match the existing design language. Triggers: 'polish the UI', 'make it pixel perfect', 'final design pass'.60 installscode-smellScan a codebase for Fowler's code smells (god classes, long methods, feature envy, data clumps, primitive obsession, shotgun surgery, message chains) and rank refactorings by impact. Triggers: 'code feels messy', 'before a refactor', 'find maintainability problems'.53 installs

More from Skills Hub

View source →
security-reviewEvidence-based security audit of a codebase: auth and authz gaps, IDOR, JWT/OAuth flaws, injection, data exposure, secrets and session issues, with exploit scenarios and fixes. Triggers: security review, audit auth, find vulnerabilities.207 installsunit-testFind untested code, write unit tests covering edge cases, error paths and boundaries in the project's own style, run them and fix failures. Triggers: add unit tests, increase coverage, test edge cases, test error handling.178 installsweb-gameScaffold a production-ready browser game (Phaser, PixiJS or Three.js) with Vite, TypeScript, input, audio, saves, responsive canvas and itch.io/PWA deploy. Triggers: web game, browser game, html5 game, phaser game, pixi game, three.js game.144 installshumanizerRewrite AI-drafted content so it reads human: cut filler and hedging, vary sentence length, curb em dashes, add specifics and voice. Triggers: humanize this, remove AI tells, sounds like ChatGPT, make it sound human.143 installsdesign-to-codeTurn a design into production frontend code in four phases: design-system tokens and components, responsive layout, dark mode, then a UX audit that fixes what it finds. Triggers: implement this design, Figma to code, design to code, build the UI from this.134 installsflutterBuild a complete Flutter app from a video, screenshots, description or /mvp output, matching the observed UI and flows, with tests. Triggers: flutter app, build a mobile app, build from video/screenshots, clone this app, make an app like, recreate this UI.131 installs

More Test skills

Browse category →
integration-testGenerate integration tests for APIs, databases, and external services. Triggers: you need to test API endpoints end-to-end, verify database operations, test service interactions.26 installstest-genGenerate comprehensive tests for existing code — unit, integration, and edge cases. Detects framework, matches project conventions, and achieves meaningful coverage.19 installse2eAuto-detects any tech stack, generates and runs exhaustive end-to-end tests. Triggered by "end-to-end tests", "e2e tests", "integration tests", "test the whole app", "generate tests", "test coverage", "write e2e", "run e2e", "full test suite". Use when a feature is complete and needs full-journey coverage, or before a release when unit tests alone are not enough.19 installsload-testGenerate and run load tests with k6, Locust, or Artillery. Auto-detects API framework, creates realistic user behavior flows (browsing, authenticated CRUD, search-heavy), runs ramp-up, sustained, spike, and stress test profiles with defined latency and error-rate thresholds. Use when the user asks if their API can handle traffic, wants a load, stress, or spike test, or mentions k6, Locust, Artillery, or latency under load.12 installstest-suiteAnalyze and score test coverage across all testing dimensions -- unit, integration, E2E, load, visual regression, contract, and accessibility. Triggers: you need a test health overview, want to find coverage gaps, need to prioritize which tests to write next.12 installsaccessibility-testAutomated WCAG 2.1 AA accessibility testing with axe-core and Lighthouse CI. Triggers: adding a11y testing, auditing accessibility compliance, fixing contrast issues.12 installs

Frequently asked questions about tdd-enforcer

What does the tdd-enforcer skill do?

Enforce strict red-green-refactor test-driven development for a feature. Triggers: you want to "do TDD", "build this feature test-first", "enforce red-green-refactor", "write the test first". It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the tdd-enforcer skill?

Run `npx @skills-hub-ai/cli install tdd-enforcer` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/tdd-enforcer/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does tdd-enforcer work with?

tdd-enforcer runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the tdd-enforcer skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use tdd-enforcer after installing it?

In Claude Code, type `/tdd-enforcer` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the tdd-enforcer skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.