code-refactoring-advisor
FreeRuns bundled scriptsNot checkedEnterprise code refactoring advisor that detects code smells, anti-patterns, and complexity issues with specific refactoring recommendations, test generation…
by jiayaoqijia★ 81 GitHub starsAbout this skill
capabilities:
- python code smell detection (god functions, long parameters, deep nesting, etc.)
- solidity smart contract anti-patterns (reentrancy, unchecked arithmetic, etc.)
- cyclomatic complexity calculation per function
- maintainability index scoring (0-100)
- specific refactoring recommendations with code examples
- automatic unit test generation
- security pattern detection
- test strategy planning
- code quality metrics and reporting
security_considerations:
- Read-only code analysis (no code execution)
- No external file access
- Pattern-based detection only
- Safe AST parsing with error handling
- No sensitive data exposure
- No code modification without user confirmation
- Sandbox analysis environment
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:
- Code Smell Detection: 12+ patterns (god functions, long parameters, deep nesting, etc.)
- Complexity Analysis: Cyclomatic complexity and maintainability index calculation
- Refactoring Recommendations: Specific solutions with code examples and effort estimates
- Test Generation: Automatic unit and integration test case generation
- Security Patterns: Solidity vulnerability detection (reentrancy, arithmetic, etc.)
Module Details
Module 1: Pattern Detector (92% Confidence)
Detects code smells and anti-patterns in Python and Solidity:
- Python: God functions, long parameter lists, deep nesting, bare excepts, global variables, magic numbers
- Solidity: Reentrancy vulnerabilities, unbounded loops, unchecked arithmetic, unclear visibility
- Outputs: Severity levels (CRITICAL/HIGH/MEDIUM/LOW), confidence scores, line numbers
Module 2: Refactoring Suggester (88% Confidence)
Generates specific refactoring solutions:
- Pattern-based recommendations (extract method, parameter object, strategy pattern, etc.)
- Effort estimates (TRIVIAL to LARGE)
- Benefits per refactoring (testability, maintainability, security, etc.)
- Code examples showing before/after
Module 3: Complexity Analyzer (90% Confidence)
Calculates code metrics:
- Cyclomatic complexity per function
- Maintainability Index (0-100)
- Code statistics (lines, comments, ratio)
- Health scoring and improvement recommendations
Module 4: Test Generator (85% Confidence)
Creates test cases for refactored code:
- Unit tests (extracted methods, parameters, guards)
- Integration tests (combined functionality)
- Security tests (reentrancy, edge cases)
- Test templates and strategies
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
- Version: 1.0.0
- Released: February 8, 2026
- Status: Production Ready
- Confidence: 90%
Future Enhancements (v1.1.0)
- TypeScript a
Install code-refactoring-advisor in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the code-refactoring-advisor skill do?
Enterprise code refactoring advisor that detects code smells, anti-patterns, and complexity issues with specific refactoring recommendations, test generation, and maintainability metrics
How do I install the code-refactoring-advisor skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the code-refactoring-advisor skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic