refactor-patterns
Install
mayros skill install refactor-patterns
mayros skill install [email protected]
Code smell detection, SOLID principles, GoF patterns, health scoring
README
@apilium/refactor-patterns
Detect code smells and suggest refactoring patterns using GoF design patterns and SOLID principles.
Installation
mayros skill install @apilium/refactor-patterns
Usage
Detect Code Smells
Ask Mayros to analyze your code for smells:
Analyze src/services/ for code smells and suggest refactoring patterns.
The skill detects smells from Martin Fowler's catalog:
- Critical: God Class, Duplicate Code
- High: Long Method, Feature Envy, Switch Statements
- Medium: Data Clumps, Primitive Obsession, Long Parameter List, Message Chains
- Low: Lazy Class, Speculative Generality, Parallel Inheritance
Pattern Suggestions
Each smell maps to a specific refactoring technique or GoF pattern:
- God Class --> Extract Class (Single Responsibility)
- Switch Statements --> Strategy Pattern (Open/Closed)
- Feature Envy --> Move Method
- Data Clumps --> Extract Parameter Object
- Long Parameter List --> Builder Pattern
SOLID Analysis
Every suggestion references which SOLID principle is violated and how the recommended pattern addresses it.
Health Score
The skill computes a health score from 0 to 100 based on the number and severity of detected smells. Critical smells deduct 15 points, high smells deduct 10, medium deduct 5, and low deduct 2.
Semantic Predicates
| Predicate | Description |
|-----------|-------------|
| refactor:smell_detected | Asserted for each smell found |
| refactor:pattern_suggested | Asserted for each refactoring recommendation |
| refactor:history | Query for previous refactoring analysis |
License
MIT
Versions
Comments
Sign in to leave a comment.
Loading comments...