Moai Workflow Tdd logo

Moai Workflow Tdd

OrganizationPopular
modu-ai
moai-workflow-tdd

Test-Driven Development workflow specialist using RED-GREEN-REFACTOR cycle for test-first software development. Use when developing new features from scratch or when behavior specification drives implementation.

Overview

Publishermodu-ai
Repositorymoai-adk
Skill namemoai-workflow-tdd
Stars
1.2K
Forks
226
Bundled files
2
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by modu-ai on GitHub. Read the source before you install it.

Installation

Install the Moai Workflow Tdd AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-workflow-tdd
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/modu-ai/moai-adk.git /tmp/moai-adk
mkdir -p .claude/skills
cp -r /tmp/moai-adk/.claude/skills/moai-workflow-tdd .claude/skills/moai-workflow-tdd
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Moai Workflow Tdd in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Moai Workflow Tdd on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Moai Workflow Tdd is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Test-Driven Development (TDD) Workflow

Development Mode Configuration (CRITICAL)

[NOTE] This workflow is selected based on .moai/config/sections/quality.yaml:

yaml
constitution:
  development_mode: tdd    # or ddd

When to use this workflow:

  • development_mode: tdd → Use TDD (this workflow, default)
  • development_mode: ddd → Use DDD instead (moai-workflow-ddd)

Key distinction:

  • TDD (default): Test-first development for all work, including brownfield projects with pre-RED analysis
  • DDD: Characterization-test-first for existing codebases with minimal test coverage

Quick Reference

Test-Driven Development provides a disciplined approach for creating new functionality where tests define the expected behavior before implementation.

Core Cycle - RED-GREEN-REFACTOR:

  • RED: Write a failing test that defines desired behavior
  • GREEN: Write minimal code to make the test pass
  • REFACTOR: Improve code structure while keeping tests green

When to Use TDD:

  • Creating new functionality from scratch
  • Building isolated modules with no existing dependencies
  • When behavior specification drives development
  • New API endpoints with clear contracts
  • New UI components with defined behavior
  • Greenfield projects (rare - usually Hybrid is better)

When NOT to Use TDD:

  • Refactoring existing code (use DDD instead)
  • When behavior preservation is the primary goal
  • Legacy codebase without test coverage (use DDD first)
  • When modifying existing files (consider Hybrid mode)

Core Philosophy

TDD vs DDD Comparison

TDD Approach:

  • Cycle: RED-GREEN-REFACTOR
  • Goal: Create new functionality through tests
  • Starting Point: No code exists
  • Test Type: Specification tests that define expected behavior
  • Outcome: New working code with test coverage

DDD Approach:

  • Cycle: ANALYZE-PRESERVE-IMPROVE
  • Goal: Improve structure without behavior change
  • Starting Point: Existing code with defined behavior
  • Test Type: Characterization tests that capture current behavior
  • Outcome: Better structured code with identical behavior

Test-First Principle

The golden rule of TDD is that tests must be written before implementation code:

  • Tests define the contract
  • Tests document expected behavior
  • Tests catch regressions immediately
  • Implementation is driven by test requirements

Implementation Guide

Phase 1: RED - Write a Failing Test

The RED phase focuses on defining the desired behavior through a failing test.

Writing Effective Tests

Before writing any implementation code:

  • Understand the requirement clearly
  • Define the expected behavior in test form
  • Write one test at a time
  • Keep tests focused and specific
  • Use descriptive test names that document behavior
Test Structure

Follow the Arrange-Act-Assert pattern:

  • Arrange: Set up test data and dependencies
  • Act: Execute the code under test
  • Assert: Verify the expected outcome
Verification

The test must fail initially:

  • Confirms the test actually tests something
  • Ensures the test is not passing by accident
  • Documents the gap between current and desired state

Phase 2: GREEN - Make the Test Pass

The GREEN phase focuses on writing minimal code to satisfy the test.

Minimal Implementation

Write only enough code to make the test pass:

  • Do not over-engineer
  • Do not add features not required by tests
  • Focus on correctness, not perfection
  • Hardcode values if necessary (refactor later)
Verification

Run the test to confirm it passes:

  • All assertions must succeed
  • No other tests should break
  • Implementation satisfies the test requirements

Phase 3: REFACTOR - Improve the Code

The REFACTOR phase focuses on improving code quality while maintaining behavior.

Safe Refactoring

With passing tests as a safety net:

  • Remove duplication
  • Improve naming and readability
  • Extract methods and classes
  • Apply design patterns where appropriate
Continuous Verification

After each refactoring step:

  • Run all tests
  • If any test fails, revert immediately
  • Commit when tests pass

TDD Workflow Execution

Standard TDD Session

When executing TDD through manager-develop:

Step 1 - Understand Requirements:

  • Read SPEC document for feature scope
  • Identify test cases from acceptance criteria
  • Plan test implementation order

Step 2 - RED Phase:

  • Write first failing test
  • Verify test fails for the right reason
  • Document expected behavior

Step 3 - GREEN Phase:

  • Write minimal implementation
  • Run test to verify it passes
  • Move to next test

Step 4 - REFACTOR Phase:

  • Review code for improvements
  • Apply refactoring with tests as safety net
  • Commit clean code

Step 5 - Repeat:

  • Continue RED-GREEN-REFACTOR cycle
  • Until all requirements are implemented
  • Until all acceptance criteria pass

TDD Loop Pattern

For features requiring multiple test cases:

  • Identify all test cases upfront
  • Prioritize by dependency and complexity
  • Execute RED-GREEN-REFACTOR for each
  • Maintain cumulative test suite

Quality Metrics

TDD Success Criteria

Test Coverage (Required):

  • Minimum 80% coverage per commit
  • 90% recommended for new code
  • All public interfaces tested

Code Quality (Goals):

  • All tests pass
  • No test written after implementation
  • Clear test names documenting behavior
  • Minimal implementation satisfying tests

TDD-Specific TRUST Validation

Apply TRUST 5 framework with TDD focus:

  • Tested: Test-first approach ensures coverage
  • Readability: Tests document expected behavior
  • Unified: Style and structure consistent with the surrounding code
  • Security: Security tests written before implementation
  • Trackable: Test failures provide immediate, attributable feedback

Integration Points

With DDD Workflow

TDD and DDD are complementary:

  • TDD for new code
  • DDD for existing code refactoring
  • Hybrid mode combines both approaches

With Testing Workflow

TDD integrates with testing workflow:

  • Uses specification tests
  • Integrates with coverage tools
  • Supports mutation testing for test quality

With Quality Framework

TDD outputs feed into quality assessment:

  • Coverage metrics tracked
  • TRUST 5 validation for changes
  • Quality gates enforce standards

Troubleshooting

Common Issues

Test is Too Complex:

  • Break into smaller, focused tests
  • Test one behavior at a time
  • Use test fixtures for complex setup

Implementation Grows Too Fast:

  • Resist urge to implement untested features
  • Return to RED phase for new functionality
  • Keep GREEN phase minimal

Refactoring Breaks Tests:

  • Revert immediately
  • Refactor in smaller steps
  • Ensure tests verify behavior, not implementation

Recovery Procedures

When TDD discipline breaks down:

  • Stop and assess current state
  • Write characterization tests for existing code
  • Resume TDD for remaining features
  • Consider switching to Hybrid mode

Version: 1.0.0 Status: Active

Common Rationalizations

RationalizationReality
"I'll add tests after the implementation works"Post-hoc tests verify what the code does, not what it should do. They miss the bugs RED phase catches.
"The existing tests cover this case"Existing tests verify old behavior. New behavior needs its own failing test first.
"This function is too simple to test"Simple functions accumulate complexity. The test documents expected behavior before drift.
"I tested it manually in the terminal"Manual checks do not persist. Tomorrow's change breaks the contract with no signal.
"The test requires complex mocking"If the test is hard to write, the code is hard to reason about. Refactor the design first.
"Tests slow me down"Test-first surfaces design problems early, when they are cheapest to fix.
"I'll skip REFACTOR this cycle to keep moving"Skipped refactors compound. The next cycle starts from a worse baseline.

DAMP over DRY: In test code, prefer Descriptive And Meaningful Phrases over Don't Repeat Yourself. Duplication inside a test that makes the intent obvious is better than an abstraction that hides it.

Beyonce Rule: If you liked it, you should have put a test on it. Any behavior CI does not verify will eventually break without warning.

Red Flags

  • Implementation file created in the same commit as its test file (RED phase skipped)
  • Test names describe implementation (test_function_returns_true) instead of behavior (test_user_login_rejects_expired_token)
  • All tests in a new file pass on first run — no RED phase was captured
  • Commit message says "add tests" after the feature is already merged
  • Test suite contains mocks of the code under test (mocking implementation, not collaborators)
  • Coverage dropped in the commit that added a new feature

Verification

  • Git history shows a failing-test commit before the implementation commit, or evidence of RED in the same commit
  • Test names read as behavior specifications, not function descriptions
  • Every new public function has at least one corresponding test case
  • Full test suite passes (paste command output)
  • Coverage for changed files is measured and reported (show tool output)
  • No skip, xit, or disabled tests were added in this change
  • REFACTOR phase was executed or explicitly justified as unnecessary

Test-First Anti-Cheat

[ZONE:Evolvable] [HARD] The Red Flags and Verification checklists above sit in advisory (evolvable) blocks and are consumed by no completion gate. This section promotes them into two enforced invariants that make test-first falsifiable in the completion matrix.

  • Invariant i — RED failure output is mandatory completion evidence. The verbatim RED failing-test output (the failing-test run captured BEFORE any implementation makes it pass) MUST be observed and shown as part of run-phase completion evidence. A run that cannot produce this output skipped RED and cannot be reported as clean.
  • Invariant ii — implementation written before its failing test is deleted and re-derived test-first. Any implementation code written before its failing test exists MUST be deleted and re-derived from a failing test (RED then GREEN). "I already wrote the implementation, so the test passes on first run" is the exact failure mode this invariant forbids — it is test-after, not test-first, and it leaves no RED output (Invariant i) to show as evidence.

These two invariants close the falsifiability gap: before them, a fully-passing self-verification matrix was producible with NO RED evidence, so test-first could not be distinguished from test-after by the completion report. After them, the matrix requires the verbatim pre-GREEN RED output, so a run that skipped RED has no such output to supply and the matrix is structurally incomplete.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Moai Workflow Tdd AI skill do?

Test-Driven Development workflow specialist using RED-GREEN-REFACTOR cycle for test-first software development. Use when developing new features from scratch or when behavior specification drives implementation.

Why use Moai Workflow Tdd on TypingMind?

Because you install it once and use it with any model. Moai Workflow Tdd is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Moai Workflow Tdd in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-workflow-tdd. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Moai Workflow Tdd?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Moai Workflow Tdd?

As many as you like. As long as a model supports skills, you can use Moai Workflow Tdd with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Moai Workflow Tdd AI skill free?

Yes. It is published on GitHub by modu-ai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇