refactor

Analyzes code for complexity, duplication, and code smells, then suggests prioritized refactorings.

4|2|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/Arete-Consortium/ai-skills --skill refactor-arete-consortium
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/Arete-Consortium/ai-skills/tree/main/personas/engineering/refactor
Command: npx skills add https://github.com/Arete-Consortium/ai-skills --skill refactor-arete-consortium

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate technical debt through complex functions, duplicated logic, and design issues that are hard to spot manually. This Skill automates the detection of refactoring opportunities and produces a prioritized report with concrete before-and-after fixes. ## Core Features & Use Cases - Complexity Analysis: Flags functions with cyclomatic complexity above 10, nesting deeper than 4 levels, and methods exceeding 50 lines. - Duplication & Code Smell Detection: Identifies repeated code blocks, god classes, feature envy, long parameter lists, magic numbers, and dead code. - Prioritized Report with Fixes: Outputs a Markdown report ranking issues as High/Medium/Low with before-and-after code examples, and can apply refactorings directly with the --apply flag. - Use Case: Run /refactor on a legacy Python module to get a summary table of complexity, duplication, and smell counts, plus actionable refactoring steps like extracting a 87-line function into validate/transform/save helpers. ## Quick Start Ask Claude to run /refactor on a specific file or directory, for example: refactor the module at src/utils/ and show the highest priority issues.

Frequently Asked Questions about refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find complex functions in my codebase?▼

Run /refactor on a file or directory to calculate cyclomatic complexity, nesting depth, and function length for every function. Functions exceeding thresholds like complexity above 10 or more than 50 lines are flagged as high priority issues.

How to detect duplicated code across a module?▼

The duplication detection pass finds repeated code blocks and similar function patterns, including copy-paste code with slight variations. The report shows locations and similarity percentages, then suggests consolidating them into parameterized functions.

Can the refactor skill apply changes automatically?▼

Yes, invoking /refactor with the --apply flag implements the suggested refactorings directly in the code. After applying changes, it runs the test suite to verify the refactorings did not break existing behavior.

What code smells does refactoring analysis detect?▼

It detects god classes and functions, feature envy, long parameter lists over five parameters, magic numbers, and dead code. It also flags design issues like tight coupling, low cohesion, and missing abstractions.

When should I not rely on automated refactoring suggestions?▼

Automated suggestions work best for mechanical issues like long methods and duplication, but architectural redesigns require human judgment. Review each suggested change before applying, especially when the --apply flag modifies code across multiple files.