moai-workflow-ddd

Analyze codebases with AST-grep and establish characterization tests for refactoring.

Updated Nov 28, 2024
One-click install
npx skills add https://github.com/desafin/Resource-Monitor-pyQT --skill moai-workflow-ddd-desafin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-workflow-ddd
Source: https://github.com/desafin/Resource-Monitor-pyQT/tree/main/.claude/skills/moai-workflow-ddd
Command: npx skills add https://github.com/desafin/Resource-Monitor-pyQT --skill moai-workflow-ddd-desafin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of refactoring legacy codebases or improving code structure without introducing regressions or altering existing functionality, thereby reducing technical debt and enhancing maintainability.

Core Features & Use Cases

  • Behavior Preservation: Ensures code changes maintain identical observable behavior through characterization tests and AST analysis.
  • Incremental Refactoring: Guides users through safe, step-by-step structural improvements like method extraction, class extraction, and renaming.
  • Use Case: You have a large, complex Python application with minimal test coverage. You need to improve its modularity and reduce coupling without breaking its current functionality. This Skill will help you analyze the code, create safety nets, and refactor incrementally.

Quick Start

Use the moai-workflow-ddd skill to refactor the legacy_module.py file by extracting a new utils class.

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 functionality?

Refactor legacy code without breaking existing functionality by establishing characterization tests to capture current behavior and using AST-grep analysis to guide safe, incremental structural improvements. This ensures verifiable outcomes and preserves observable behavior.

What are characterization tests and when do I need them for refactoring?

Characterization tests capture and verify the current behavior of existing code before you change it. You need them for refactoring legacy code with minimal test coverage to ensure your structural improvements do not introduce regressions.

How do I extract a class from a large legacy module safely?

Extract a class from a large legacy module safely by using AST-grep to analyze the codebase structure, establishing characterization tests as a safety net, and applying incremental structural improvements like method and class extraction.

Does AST-grep work for behavior-preserving code transformations?

AST-grep works for behavior-preserving code transformations by analyzing existing codebases to identify structural patterns. This analysis supports incremental refactoring to reduce technical debt and enhance maintainability.

Can I use this approach for API migration and code modernization?

You can use this approach for API migration and code modernization. It supports behavior-preserving code transformations through incremental structural improvements, focusing on safety and verifiable outcomes to reduce technical debt.

What is the best way to reduce coupling in a complex Python application?

The best way to reduce coupling in a complex Python application is to apply Domain-Driven Development workflows. Analyze the code with AST-grep, establish characterization tests, and guide incremental structural improvements to enhance modularity safely.