Xspoonai official code refactoring advisor

From jiayaoqijia/cryptoskill · View interactive version

Xspoonai official code refactoring advisor is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Enterprise code refactoring advisor that detects code smells, anti-patterns, and complexity issues with specific refactoring recommendations, test generation, and maintainability metrics

How to use this skill

Skill file

capabilities:

security_considerations:

Overview

The Code Refactoring Advisor is an enterprise-grade code quality tool that analyzes Python and Solidity code to detect smells, anti-patterns, and complexity issues with actionable refactoring recommendations. It combines pattern detection, complexity metrics, and test generation to improve code quality systematically.

Key capabilities:

Module Details

Module 1: Pattern Detector (92% Confidence)

Detects code smells and anti-patterns in Python and Solidity:

Module 2: Refactoring Suggester (88% Confidence)

Generates specific refactoring solutions:

Module 3: Complexity Analyzer (90% Confidence)

Calculates code metrics:

Module 4: Test Generator (85% Confidence)

Creates test cases for refactored code:

Usage Examples

Detect Code Smells

from scripts.pattern_detector import PatternDetector

detector = PatternDetector()
result = detector.analyze_code(source_code, language="python")
print(f"Smells found: {result['smells_detected']}")
print(f"Code quality: {result['code_quality']}%")

Get Refactoring Recommendations

from scripts.refactoring_suggester import RefactoringSuggester

suggester = RefactoringSuggester()
suggestions = suggester.suggest_refactoring(smell_data)
for suggestion in suggestions['suggestions']:
    print(f"{suggestion['smell_type']}: {suggestion['solutions']}")

Analyze Complexity

from scripts.complexity_analyzer import ComplexityAnalyzer

analyzer = ComplexityAnalyzer()
metrics = analyzer.analyze_module(source_code)
print(f"Maintainability: {metrics['maintainability_index']['rating']}")

Generate Tests

from scripts.test_generator import TestGenerator

generator = TestGenerator()
tests = generator.generate_tests(refactoring_suggestions)
for test in tests['test_cases']:
    print(f"Test: {test['name']}")

Output Format

All modules return structured JSON:

{
  "analysis_type": "string",
  "smells_detected": number,
  "code_quality_score": 0-100,
  "severity_breakdown": { "CRITICAL": n, "HIGH": n, ... },
  "refactoring_opportunities": number,
  "estimated_effort": "string",
  "estimated_quality_improvement": number,
  "test_cases_generated": number,
  "recommendations": ["array of actionable items"],
  "metrics": { "complexity": number, "maintainability": number, ... }
}

Severity Levels

| Level | Meaning | Impact | Action |

|-------|---------|--------|--------|

| CRITICAL | Major security/correctness issue | High risk | Fix immediately |

| HIGH | Significant code quality issue | Moderate risk | Fix in this sprint |

| MEDIUM | Maintainability concern | Low-moderate risk | Plan refactoring |

| LOW | Minor improvement opportunity | Low risk | Consider for future |

Version & Support

Future Enhancements (v1.1.0)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.