moai-workflow-ddd

Refactors legacy code through an ANALYZE-PRESERVE-IMPROVE cycle with characterization tests.

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

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 regressions are caught instead of shipped. ## Core Features & Use Cases - ANALYZE Phase: Identifies domain boundaries, coupling and cohesion metrics, and problematic structural patterns using AST-grep analysis. - PRESERVE Phase: Builds a safety net of characterization tests and behavior snapshots that document what the code actually does before changes begin. - IMPROVE Phase: Applies incremental refactorings (extract method, extract class, move method, rename) with continuous test validation after every step. - Use Case: When modernizing a production module with few tests, run this workflow to first characterize existing behavior, then restructure the code step by step while keeping every test 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 map domain boundaries and coupling, then write characterization tests that capture current behavior, then make small structural changes while running the full test suite after each step.

What is the difference between DDD and TDD workflows for refactoring?▼

TDD uses a RED-GREEN-REFACTOR cycle to create new functionality with specification tests. DDD uses ANALYZE-PRESERVE-IMPROVE with characterization tests that capture what existing code actually does, making it suited for restructuring code without behavior changes.

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

Characterization tests document the actual current behavior of code, including surprising or incorrect outputs, rather than expected behavior. Write them before refactoring any code path that lacks coverage, so regressions surface immediately during transformation.

When should I not use a behavior-preserving refactoring workflow?▼

Do not use it when the goal is to change behavior rather than improve structure. If new functionality or different outputs are required, modify the SPEC first or use a test-first TDD workflow instead.

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

Revert immediately to the last known good state, analyze which tests failed and whether the transformation changed behavior unintentionally, then retry with a smaller transformation step. Git stash or reset to the last successful commit for recovery.