moai-workflow-ddd

Refactors legacy code through an ANALYZE-PRESERVE-IMPROVE cycle with characterization tests and AST-grep transformations.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/taewook486/Masters_degree --skill moai-workflow-ddd-taewook486
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: moai-workflow-ddd
Source: https://github.com/taewook486/Masters_degree/tree/main/.claude/skills/moai-workflow-ddd
Command: npx skills add https://github.com/taewook486/Masters_degree --skill moai-workflow-ddd-taewook486

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Refactoring legacy code without breaking existing behavior is risky when test coverage is thin. This Skill provides a structured Domain-Driven Development workflow that captures current behavior with characterization tests before making any structural change, so refactoring never silently alters what the code does. ## Core Features & Use Cases - ANALYZE Phase: Identifies domain boundaries, coupling and cohesion metrics (Ca, Ce, instability), and problematic patterns like god classes and feature envy using AST-grep structural analysis. - PRESERVE Phase: Creates characterization tests and behavior snapshots that document what the code actually does, then verifies the test safety net before any change. - IMPROVE Phase: Applies incremental refactorings (extract method, extract class, move method, rename) with continuous test validation after every step and immediate revert on failure. - Use Case: When modernizing a production module with minimal tests, run this workflow to build a characterization test safety net, then restructure the code step by step while every existing test and behavior snapshot stays green. ## Quick Start Ask the AI to refactor a legacy module using the DDD workflow, starting with characterization tests to preserve its current behavior.

Frequently Asked Questions about moai-workflow-ddd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor legacy code without breaking existing behavior?▼

Use the ANALYZE-PRESERVE-IMPROVE cycle: first analyze structure and coupling, then write characterization tests that capture current behavior, then make small incremental changes running the full test suite after each step. Revert immediately if any test fails.

What is the difference between DDD and TDD workflows?▼

TDD uses a RED-GREEN-REFACTOR cycle to create new functionality from specification tests. DDD uses ANALYZE-PRESERVE-IMPROVE to restructure existing code while keeping behavior identical, relying on characterization tests that document what the code currently does.

What are characterization tests and when should I write them?▼

Characterization tests capture the actual current behavior of existing code, including surprising or incorrect outputs, without assuming correctness. Write them before refactoring any code path that lacks test coverage so regressions are detected during transformation.

When should I not use the DDD refactoring workflow?▼

Do not use DDD when the goal is to change behavior rather than preserve it. For new functionality or behavior changes, modify the SPEC first or use a TDD workflow instead, since DDD's core rule is that observable behavior must remain identical.

What should I do when tests fail after a refactoring step?▼

Revert immediately to the last known good state, analyze which tests failed and why, and check whether the transformation unintentionally changed behavior. Then retry with a smaller transformation step and rerun the full test suite.