moai-workflow-ddd

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill enables systematic refactoring of existing codebases, ensuring that critical behaviors are preserved while improving code structure and reducing technical debt.

Core Features & Use Cases

  • Behavior Preservation: Guarantees that code changes do not alter existing functionality through characterization tests and AST analysis.
  • Structural Improvement: Facilitates refactoring of legacy code, modernization, and API migration without introducing regressions.
  • Use Case: Refactor a complex, legacy module by identifying domain boundaries, creating safety nets with characterization tests, and incrementally improving its structure using AST-grep for safe transformations.

Quick Start

Use the moai-workflow-ddd skill to refactor the UserAuth module, ensuring all existing tests pass and behavior remains unchanged.

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?

Refactoring legacy code without breaking behavior requires a structured ANALYZE-PRESERVE-IMPROVE cycle. This approach leverages characterization tests and AST analysis to guarantee functional equivalence while incrementally improving code structure and reducing technical debt.

What is the best way to safely migrate legacy APIs and reduce technical debt?

Safely migrating legacy APIs involves applying structural transformations with AST-grep. This ensures safe API migration and technical debt reduction by validating changes through characterization tests that confirm no functional regressions occur.

How does AST-grep work for behavior-preserving code transformations?

AST-grep performs structural analysis to identify domain boundaries and apply safe code modifications for behavior-preserving transformations. It operates within a cycle using characterization tests to verify functional equivalence before and after structural improvements.

Do I need pytest and ruff to use this refactoring workflow?

Pytest and ruff are required dependencies to execute this refactoring workflow. These tools support the process by running characterization tests to preserve behavior and maintaining code quality standards during structural improvements.

When should I not use AST-grep for code refactoring?

Avoid using AST-grep for code refactoring without a safety net of characterization tests. Without tests verifying functional equivalence, automated structural transformations risk introducing regressions during legacy code modernization or API migration.