codebase-cleanup-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
About this skill
This skill empowers your AI agent to act as a seasoned code refactoring expert. It meticulously analyzes provided codebases, identifying areas for improvement in quality, maintainability, and performance. Leveraging deep knowledge of clean code principles, SOLID design patterns, and modern software engineering best practices, the agent intelligently refactors code to remove technical debt, simplify complex logic, and enhance overall code health. It's designed to transform messy or suboptimal code into clean, efficient, and easily understandable components.
Best use case
Cleaning up large codebases with accumulated technical debt, removing duplication and simplifying modules, preparing a codebase for new feature development, and aligning code with high-quality standards.
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
Clean, well-structured, and highly maintainable code. Reduced bug surface area, improved readability, better performance, and a codebase that adheres to modern software engineering best practices, making future development faster and less error-prone.
Practical example
Example input
```python
def calculate_total_price(items):
total = 0
for item in items:
if item['type'] == 'book':
total += item['price'] * 1.10 # 10% tax for books
elif item['type'] == 'electronics':
total += item['price'] * 1.20 # 20% tax for electronics
else:
total += item['price'] * 1.05 # 5% tax for others
return total
```Example output
```python
from typing import List
class Item:
def __init__(self, item_type: str, price: float):
self.item_type = item_type
self.price = price
def _get_tax_rate(self) -> float:
if self.item_type == 'book':
return 0.10
elif self.item_type == 'electronics':
return 0.20
return 0.05 # Default for others
def calculate_taxed_price(self) -> float:
return self.price * (1 + self._get_tax_rate())
def calculate_total_price(items: List[Item]) -> float:
total_price = sum(item.calculate_taxed_price() for item in items)
return total_price
```When to use this skill
- When you need to systematically improve the quality and structure of existing code, reduce technical debt, enhance readability and maintainability for future development, or optimize code for better performance and scalability. Ideal for pre-release cleanups or before starting major new features.
When not to use this skill
- When the primary task is a complete architectural redesign rather than code-level refactoring. Avoid using for critical production systems without human review and thorough testing. Not suitable when the code requires deep, nuanced domain-specific knowledge that the AI agent has not been explicitly trained on, or when the focus is on debugging runtime issues rather than structural improvements.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/codebase-cleanup-refactor-clean/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How codebase-cleanup-refactor-clean Compares
| Feature / Agent | codebase-cleanup-refactor-clean | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Refactor and Clean Code You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance. ## Use this skill when - Cleaning up large codebases with accumulated debt - Removing duplication and simplifying modules - Preparing a codebase for new feature work - Aligning implementation with clean code standards ## Do not use this skill when - You only need a tiny targeted fix - Refactoring is blocked by policy or deadlines - The request is documentation-only ## Context The user needs help refactoring code to make it cleaner, more maintainable, and aligned with best practices. Focus on practical improvements that enhance code quality without over-engineering. ## Requirements $ARGUMENTS ## Instructions - Identify high-impact refactor candidates and risks. - Break work into small, testable steps. - Apply changes with a focus on readability and stability. - Validate with tests and targeted regression checks. - If detailed patterns are required, open `resources/implementation-playbook.md`. ## Safety - Avoid large rewrites without agreement on scope. - Keep changes reviewable and reversible. ## Output Format - Cleanup plan with prioritized steps - Key refactor targets and rationale - Expected impact and risk notes - Test/verification plan ## Resources - `resources/implementation-playbook.md` for detailed patterns and examples.
Related Skills
code-simplifier
Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Use when asked to "simplify code", "clean up code", "refactor for clarity", "improve readability", or review recently modified code for elegance. Focuses on project-specific best practices.
fp-refactor
Comprehensive guide for refactoring imperative TypeScript code to fp-ts functional patterns
codebase-cleanup-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
codebase-audit-pre-push
Deep audit before GitHub push: removes junk files, dead code, security holes, and optimization issues. Checks every file line-by-line for production readiness.
code-refactoring-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
code-refactoring-context-restore
Use when working with code refactoring context restore
clean-code
This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."
nft-standards
Master ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.
nextjs-app-router-patterns
Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.
new-rails-project
Create a new Rails project
networkx
NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.
network-engineer
Expert network engineer specializing in modern cloud networking, security architectures, and performance optimization.