
Codebase Cleanup Refactor Clean
Run a structured refactor pass on smelly code using SOLID checks and a prioritized cleanup plan before you merge or release.
Overview
Codebase Cleanup Refactor Clean is an agent skill most often used in Ship review (also Build frontend and backend) that guides smell analysis, SOLID checks, and prioritized refactors with concrete extraction patterns.
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill codebase-cleanup-refactor-cleanWhat is this skill?
- Code smell checklist: long methods (>20 lines), large classes (>200 lines), duplication, dead code
- SOLID violation pass across responsibilities, extension points, and coupling
- Performance scan for algorithmic cost, leaks, blocking work, and cache gaps
- Prioritized plan: immediate fixes, method extraction, with before/after samples
- Code smell thresholds include methods longer than 20 lines and classes longer than 200 lines
- Refactoring plan uses three analysis areas: code smells, SOLID violations, and performance issues
Adoption & trust: 685 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your codebase grew fast and now has long functions, magic numbers, and tangled modules that make every change risky.
Who is it for?
Indie developers cleaning a mature module before merge, handoff, or a fundraising technical diligence pass.
Skip if: Greenfield scaffolding from zero or emergencies that need only a hotfix with no time for structural change.
When should I use this skill?
When the user wants to analyze code smells, plan refactors, apply SOLID-aligned extractions, or clean a module before merge or ship.
What do I get? / Deliverables
A prioritized refactor plan plus applied extractions and naming fixes that shrink complexity and align structure with SOLID without a big-bang rewrite.
- Prioritized refactor plan (immediate vs structural items)
- Refactored modules with extracted functions and improved naming
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
The playbook is shelved under Ship review because its output is merge-ready quality, but the same analysis applies while you are still building features. Code review subphase captures systematic smell detection, extraction refactors, and performance triage—not one-off typo fixes.
Where it fits
Run the smell and SOLID pass on a release branch before tagging v1.0.
Split a fifty-line order handler into validation, pricing, and notification helpers.
Rename opaque state flags and extract repeated JSX into components after a hackathon UI push.
How it compares
Use as a structured refactor ritual instead of asking the agent for vague make this cleaner without criteria.
Common Questions / FAQ
Who is codebase-cleanup-refactor-clean for?
Solo builders and tiny teams shipping SaaS, APIs, or CLIs who want agent-led cleanup guided by explicit smell and SOLID checklists.
When should I use codebase-cleanup-refactor-clean?
In Ship review before release merges, and during Build when a file exceeds smell thresholds and blocks safe feature work.
Is codebase-cleanup-refactor-clean safe to install?
Refactors can touch production logic; review the Security Audits panel here, use git branches, and require tests after each change set.
SKILL.md
READMESKILL.md - Codebase Cleanup Refactor Clean
# Refactor and Clean Code Implementation Playbook This file contains detailed patterns, checklists, and code samples referenced by the skill. ## Instructions ### 1. Code Analysis First, analyze the current code for: - **Code Smells** - Long methods/functions (>20 lines) - Large classes (>200 lines) - Duplicate code blocks - Dead code and unused variables - Complex conditionals and nested loops - Magic numbers and hardcoded values - Poor naming conventions - Tight coupling between components - Missing abstractions - **SOLID Violations** - Single Responsibility Principle violations - Open/Closed Principle issues - Liskov Substitution problems - Interface Segregation concerns - Dependency Inversion violations - **Performance Issues** - Inefficient algorithms (O(n²) or worse) - Unnecessary object creation - Memory leaks potential - Blocking operations - Missing caching opportunities ### 2. Refactoring Strategy Create a prioritized refactoring plan: **Immediate Fixes (High Impact, Low Effort)** - Extract magic numbers to constants - Improve variable and function names - Remove dead code - Simplify boolean expressions - Extract duplicate code to functions **Method Extraction** ``` # Before def process_order(order): # 50 lines of validation # 30 lines of calculation # 40 lines of notification # After def process_order(order): validate_order(order) total = calculate_order_total(order) send_order_notifications(order, total) ``` **Class Decomposition** - Extract responsibilities to separate classes - Create interfaces for dependencies - Implement dependency injection - Use composition over inheritance **Pattern Application** - Factory pattern for object creation - Strategy pattern for algorithm variants - Observer pattern for event handling - Repository pattern for data access - Decorator pattern for extending behavior ### 3. SOLID Principles in Action Provide concrete examples of applying each SOLID principle: **Single Responsibility Principle (SRP)** ```python # BEFORE: Multiple responsibilities in one class class UserManager: def create_user(self, data): # Validate data # Save to database # Send welcome email # Log activity # Update cache pass # AFTER: Each class has one responsibility class UserValidator: def validate(self, data): pass class UserRepository: def save(self, user): pass class EmailService: def send_welcome_email(self, user): pass class UserActivityLogger: def log_creation(self, user): pass class UserService: def __init__(self, validator, repository, email_service, logger): self.validator = validator self.repository = repository self.email_service = email_service self.logger = logger def create_user(self, data): self.validator.validate(data) user = self.repository.save(data) self.email_service.send_welcome_email(user) self.logger.log_creation(user) return user ``` **Open/Closed Principle (OCP)** ```python # BEFORE: Modification required for new discount types class DiscountCalculator: def calculate(self, order, discount_type): if discount_type == "percentage": return order.total * 0.1 elif discount_type == "fixed": return 10 elif discount_type == "tiered": # More logic pass # AFTER: Open for extension, closed for modification from abc import ABC, abstractmethod class DiscountStrategy(ABC): @abstractmethod def calculate(self, order): pass class PercentageDiscount(DiscountStrategy): def __init__(self, percentage): self.percentage = percentage def calculate(self, order): return order.total * self.percentage class FixedDiscount(DiscountStrategy): def __init__(self, amount): self.amount = amount def calculate(self, order): return self.amount class TieredDiscoun