moai-workflow-ddd

Refactor legacy code while preserving behavior via characterization tests and AST-grep.

Updated Feb 2, 2026
One-click install
npx skills add https://github.com/CJ-1981/excel-processor --skill moai-workflow-ddd-cj-1981
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-workflow-ddd
Source: https://github.com/CJ-1981/excel-processor/tree/main/.claude/skills/moai-workflow-ddd
Command: npx skills add https://github.com/CJ-1981/excel-processor --skill moai-workflow-ddd-cj-1981

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ast-grep, and includes references (resource) and scripts (resource) components.

What problem does it solve?

This Skill enables systematic refactoring of existing codebases to improve structure and reduce technical debt while strictly preserving existing behavior, making it ideal for modernizing legacy systems or migrating APIs safely.

Core Features & Use Cases

  • Analyze: Identifies domain boundaries, coupling metrics, and structural code patterns using AST analysis.
  • Preserve: Creates characterization tests and behavior snapshots to establish a safety net before changes.
  • Improve: Applies incremental, safe refactoring patterns with continuous behavior validation.
  • Use Case: Refactor a complex, poorly documented module in a production application to improve its maintainability without introducing any regressions or altering its external behavior.

Quick Start

Use the moai-workflow-ddd skill to refactor the authentication module to improve its structure while ensuring all existing tests pass.

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 while preserving existing behavior?

To refactor legacy code while preserving behavior, you must first establish a safety net using characterization tests and behavior snapshots. Then, apply incremental structural improvements with continuous validation to guarantee functional equivalence throughout the process.

How does AST-grep help with safe code refactoring?

AST-grep enables safe code refactoring by analyzing structural code patterns and domain boundaries at the syntax tree level. This allows you to apply incremental transformations while continuously validating that the changes preserve the original behavior.

What is the best way to migrate legacy APIs without introducing regressions?

The best way to migrate legacy APIs without regressions is to use behavior-preserving code transformation. This involves creating characterization tests to capture existing behavior, followed by incremental AST-based modifications to ensure functional equivalence.

Does ast-grep support analyzing domain boundaries for reducing technical debt?

Yes, ast-grep supports analyzing domain boundaries and coupling metrics to identify structural code patterns. This analysis helps target technical debt reduction safely by guiding incremental refactoring steps while preserving functional equivalence.

How do I create characterization tests before improving code structure?

To create characterization tests before improving code structure, you capture behavior snapshots of the current system. These tests act as a safety net, ensuring that any incremental structural changes or API migrations maintain strict functional equivalence.

When should I avoid incremental refactoring for legacy systems?

You should avoid incremental refactoring for legacy systems when you cannot establish characterization tests or behavior snapshots. Without this safety net, guaranteeing functional equivalence during structural improvements and technical debt reduction is not possible.