moai-workflow-ddd

Refactor legacy code while preserving behavior using an ANALYZE-PRESERVE-IMPROVE cycle.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/yslee5005/app-library --skill moai-workflow-ddd-yslee5005
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-workflow-ddd
Source: https://github.com/yslee5005/app-library/tree/main/.claude/skills/moai-workflow-ddd
Command: npx skills add https://github.com/yslee5005/app-library --skill moai-workflow-ddd-yslee5005

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides structured, behavior-preserving refactoring of legacy code using a Domain-Driven Development workflow (ANALYZE-PRESERVE-IMPROVE), ensuring existing behavior remains intact.

Core Features & Use Cases

  • Structured refactoring: Analyze, preserve, and improve with safety nets and characterization tests.
  • Behavior preservation: Maintains public API contracts while improving code structure.
  • Guided tooling: Leverages AST-grep and domain boundaries to target safe changes across modules.

Quick Start

Initiate a Moai DDD workflow session on a legacy codebase and begin the ANALYZE phase with AST-grep guidance.

Frequently Asked Questions about moai-workflow-ddd

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

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

Behavior-preserving refactoring uses a structured ANALYZE-PRESERVE-IMPROVE cycle with AST-grep analysis and characterization tests to validate behavior after each incremental structural change. This ensures public API contracts remain intact while reducing technical debt across complex modules.

What is the best way to migrate APIs in a mature codebase with existing tests?

The best way to migrate APIs safely is applying an incremental transformation workflow with safety nets, ensuring existing tests validate behavior preservation throughout the migration. This structured approach targets safe changes across complex modules without breaking observable functionality.

How do characterization tests work during code refactoring?

Characterization tests function as safety nets during refactoring by capturing and validating the current observable behavior of legacy code before structural changes begin. They run after each incremental transformation to confirm the public API contracts and existing behavior remain completely intact.

When do I need AST-grep for refactoring complex modules?

AST-grep is needed when analyzing mature codebases for structured refactoring, as it provides domain boundary analysis to target safe structural changes across complex modules. It identifies specific code patterns to transform incrementally while maintaining behavior preservation safety nets.

Can I use this DDD workflow on codebases without existing tests?

This structured refactoring workflow is designed specifically for mature codebases with existing tests requiring safe structural changes. Without existing tests to act as safety nets, validating behavior preservation during incremental transformations would not be reliably possible.

What are the limitations of behavior-preserving refactoring on legacy code?

The main limitation is that behavior-preserving refactoring maintains existing public API contracts, meaning it cannot intentionally change observable functionality. It focuses strictly on structural improvements and debt reduction, relying heavily on existing tests to catch any accidental behavioral deviations.