TDD Discipline for Openclaw

A rigorous Test-Driven Development framework for AI agents to ensure code reliability and eliminate regressions.

kjaylee
v1.0.0
Feb 9, 2026
0
0
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install tdd-discipline

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install tdd-discipline using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is TDD Discipline?

TDD Discipline is a professional methodology designed to enforce strict Test-Driven Development (TDD) practices within AI coding workflows. By prioritizing the creation of failing tests before writing any functional code, this skill ensures that every feature and bug fix is verified, documented, and maintainable. It eliminates the risk of shipping untested or broken code by making the RED-GREEN-REFACTOR cycle the standard operating procedure for Openclaw Skills users.

This skill is particularly valuable for developers who want to maintain high code quality and prevent the 'spaghetti code' often associated with rapid AI generation. It enforces a philosophy where code is only written to satisfy a specific, tested requirement, adhering to the YAGNI (You Ain't Gonna Need It) principle.

TDD Discipline Use Cases

  • Implementing new features with clearly defined acceptance criteria.
  • Fixing software bugs by reproducing the issue with a failing test first.
  • Modifying existing behaviors to ensure no breaking changes are introduced.
  • Refactoring complex logic while maintaining a green test state.

How TDD Discipline Works

  1. RED Phase: The agent writes a single test for a specific behavior that does not yet exist. The test must have a clear name and use actual code paths.
  2. Verification: The agent runs the test command to confirm failure. It must verify that the failure message is expected and not due to a syntax error or typo.
  3. GREEN Phase: The agent writes the absolute minimum amount of code required to make the test pass, avoiding any additional logic or premature optimization.
  4. REFACTOR Phase: The agent cleans up the implementation, removes duplication, and improves naming while ensuring the test suite remains in a green state.
  5. Repetition: The cycle repeats for every incremental change until the feature or fix is complete.

TDD Discipline Setup

To integrate TDD Discipline into your workflow, ensure your project has a test runner configured. You can use this skill within Openclaw Skills by following these steps:

# Install a test runner (example using Jest for TypeScript)
npm install --save-dev jest ts-jest @types/jest

# Run the specific test file during the RED and GREEN phases
npm test path/to/your/file.test.ts

TDD Discipline Data Schema & Taxonomy

The skill follows a strict organizational structure for code and tests to ensure clarity within Openclaw Skills projects:

Component Description
Test Files Naming convention follows [filename].test.ts or [filename].spec.js to distinguish from source.
Source Code Minimalist implementation files that only contain code mapped to a passing test.
Bug Regression Tests created during bug fixes are permanently stored to prevent regression in future builds.
Metadata The skill tracks author, version, and TDD state to maintain discipline across sessions.

TDD Discipline Advanced Features

  • Strict Enforcement Rule: If code is written before a test, the agent is instructed to delete the code and restart from the RED phase.
  • Bug Reproduction Protocol: Ensures every bug fix starts with a failing test that captures the specific edge case.
  • YAGNI Guardrails: Prevents the AI from adding 'just in case' code that isn't covered by the current test suite.
  • Continuous Verification: Encourages frequent test runs to catch failures immediately after minimal code changes.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*