code-refactoring
Skill17 starsChanged 10 months agoMITView on GitHub
Guides systematic code refactoring to improve code quality, maintainability, and design. Identifies code smells, applies refactoring patterns, ensures test coverage, and follows safe refactoring practices. Produces cleaner, more maintainable code while preserving functionality. Use when improving code quality, eliminating technical debt, preparing for feature additions, addressing code smells, or when users mention refactoring, code cleanup, improving design, reducing complexity, or modernizing legacy code.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Ethanon/developer.aitheir own version, first seen Sep 6, 2026
- joabgonzalez/ai-agents-skillstheir own version, first seen Jun 8, 2026
- myths-labs/musetheir own version, first seen Apr 10, 2026
- autohandai/community-skillstheir own version, first seen Mar 9, 2026
- Willhong/claude_skilltheir own version, first seen Nov 17, 2025
Used with
Projects with it also use receiving-code-review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CloudflareSkillreceiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Also in 3 projects that use this
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- myths-labs/muse★ 35same name
- autohandai/community-skills★ 11same name
- Ethanon/developer.ai★ 9same name
- joabgonzalez/ai-agents-skills★ 9same name
- Willhong/claude_skill★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- alibaba-cloudSkill
- application-migrationSkill
- architecture-design-reviewSkill
- architecture-designSkill
- aws-cloudSkill
- azure-cloudSkill
- backend-code-reviewSkill
- backend-codingSkill
- backend-design-reviewSkill
- backend-designSkill
- bug-analysisSkill
- cobol-migration-analyzerSkill
- code-quality-reviewSkill
- code-security-reviewSkill
- database-designSkill
- database-migrationSkill
- devopsSkill
- frontend-code-reviewSkill
- frontend-codingSkill
- frontend-design-reviewSkill
- frontend-ui-ux-designSkill
- fujitsu-mainframeSkill
- git-commitSkill
- google-cloudSkill
- ibm-cloudSkill
- ibm-mainframeSkill
- integration-testingSkill
- jcl-migration-analyzerSkill
- keycloak-administrationSkill
- mockup-creationSkill
- oracle-cloudSkill
- platform-migrationSkill
- pli-migration-analyzerSkill
- project-planningSkill
- pseudocode-to-specificationSkill
- requirement-reviewSkill
- requirements-gatheringSkill
- rpg-migration-analyzerSkill
- system-migrationSkill
- technical-writingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. 0 are common, 19 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
19
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Before refactoring ANY code:
- Distinctive: line 30
Check existing test coverage for the code to be refactored
- Distinctive: line 31
If tests are missing or inadequate, write tests FIRST
- Distinctive: line 32
Run all tests to establish baseline (all should pass)
- Distinctive: line 33
Never proceed without adequate test coverage
- Distinctive: line 47
Inline Method/Variable: Remove unnecessary indirection
- Distinctive: line 56
Run all tests immediately after the change
- Distinctive: line 57
If tests pass, commit the change
- Distinctive: line 58
If tests fail, revert and try a different approach
- Distinctive: line 63
Never change behavior while refactoring
- Distinctive: line 64
Never refactor and add features simultaneously
- Distinctive: line 65
Use IDE automated refactoring tools when available
- Distinctive: line 66
Keep each refactoring commit small and focused
- Distinctive: line 74
Run full test suite to ensure all tests pass
- Distinctive: line 75
Check that code quality metrics improved
- Distinctive: line 77
Document significant architectural changes if needed
- Distinctive: line 78
Create clear commit messages describing refactorings
- Distinctive: line 94
Follow established principles for high-quality refactoring:
- Distinctive: line 117
When presenting refactoring recommendations:
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Refactoring
Overview
This skill guides systematic code refactoring to improve code quality, maintainability, and design while preserving functionality. Follow the safe refactoring workflow with comprehensive test coverage and incremental changes.
Refactoring Workflow
Step 1: Analyze Code and Identify Issues
Examine the codebase to identify code smells and quality issues:
- Long methods (>20-30 lines) or large classes (>300-500 lines)
- Duplicated code blocks or similar logic in multiple places
- Unclear or misleading names for variables, methods, or classes
- Complex conditional logic or deeply nested structures
- Poor separation of concerns or tight coupling between components
For detailed code smell catalog: See code-smells.md
Step 2: Verify Test Coverage
Before refactoring ANY code:
- Check existing test coverage for the code to be refactored
- If tests are missing or inadequate, write tests FIRST
- Run all tests to establish baseline (all should pass)
- Never proceed without adequate test coverage
For test coverage strategies: See testing-strategies.md
Step 3: Choose Refactoring Technique
Select the appropriate refactoring pattern based on the issue:
- Extract Method/Function: Break down long methods into smaller, focused ones
- Extract Class: Split large classes with multiple responsibilities
- Rename: Improve clarity with better names
- Move Method/Field: Relocate functionality to more appropriate classes
- Replace Conditional with Polymorphism: Simplify complex conditionals
- Introduce Parameter Object: Group related parameters
- Inline Method/Variable: Remove unnecessary indirection
For complete pattern catalog: See refactoring-patterns.md
Step 4: Apply Refactoring Incrementally
Make ONE small change at a time:
- Apply a single refactoring technique
- Run all tests immediately after the change
- If tests pass, commit the change
- If tests fail, revert and try a different approach
- Repeat for each refactoring needed
Critical Rules:
- Never change behavior while refactoring
- Never refactor and add features simultaneously
- Use IDE automated refactoring tools when available
- Keep each refactoring commit small and focused
For detailed process guidance: See refactoring-process.md
Step 5: Verify and Document
After completing refactorings:
- Run full test suite to ensure all tests pass
- Check that code quality metrics improved
- Review code to confirm readability enhanced
- Document significant architectural changes if needed
- Create clear commit messages describing refactorings
Common Refactoring Scenarios
Scenario-specific guidance is available for:
- Legacy code modernization
- Preparing code for new features
- Performance optimization through refactoring
- Reducing technical debt systematically
- Extracting reusable components
See common-refactoring-scenarios.md for detailed examples and approaches.
Best Practices and Quality Guidelines
Follow established principles for high-quality refactoring:
- Apply SOLID principles (Single Responsibility, Open/Closed, etc.)
- Reduce coupling between components
- Increase cohesion within components
- Eliminate duplication (DRY principle)
- Maintain consistent coding standards
For comprehensive best practices: See refactoring-best-practices.md
Tools and Automation
Modern IDEs and tools can automate many refactorings safely:
- IDE refactoring features (IntelliJ, VS Code, Visual Studio)
- Static analysis tools for code smell detection
- Test coverage tools
- Automated code formatting and linting
For tool recommendations and usage: See tools-and-automation.md
Output Format
When presenting refactoring recommendations:
- Identify the code smell or quality issue
- Explain why it's problematic
- Propose specific refactoring approach
- Show before/after code examples
- List tests to verify behavior preservation
For detailed output templates: See output-format.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

