refactor-code
Intelligently refactor and improve code quality
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 bd6fc91080ffc4c8… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
refactor-code.md
Intelligently Refactor and Improve Code Quality
Intelligently refactor and improve code quality
Instructions
Follow this systematic approach to refactor code: $ARGUMENTS
-
Pre-Refactoring Analysis
- Identify the code that needs refactoring and the reasons why
- Understand the current functionality and behavior completely
- Review existing tests and documentation
- Identify all dependencies and usage points
-
Test Coverage Verification
- Ensure comprehensive test coverage exists for the code being refactored
- If tests are missing, write them BEFORE starting refactoring
- Run all tests to establish a baseline
- Document current behavior with additional tests if needed
-
Refactoring Strategy
- Define clear goals for the refactoring (performance, readability, maintainability)
- Choose appropriate refactoring techniques:
- Extract Method/Function
- Extract Class/Component
- Rename Variable/Method
- Move Method/Field
- Replace Conditional with Polymorphism
- Eliminate Dead Code
- Plan the refactoring in small, incremental steps
-
Environment Setup
- Create a new branch:
git checkout -b refactor/$ARGUMENTS - Ensure all tests pass before starting
- Set up any additional tooling needed (profilers, analyzers)
- Create a new branch:
-
Incremental Refactoring
- Make small, focused changes one at a time
- Run tests after each change to ensure nothing breaks
- Commit working changes frequently with descriptive messages
- Use IDE refactoring tools when available for safety
-
Code Quality Improvements
- Improve naming conventions for clarity
- Eliminate code duplication (DRY principle)
- Simplify complex conditional logic
- Reduce method/function length and complexity
- Improve separation of concerns
-
Performance Optimizations
- Identify and eliminate performance bottlenecks
- Optimize algorithms and data structures
- Reduce unnecessary computations
- Improve memory usage patterns
-
Design Pattern Application
- Apply appropriate design patterns where beneficial
- Improve abstraction and encapsulation
- Enhance modularity and reusability
- Reduce coupling between components
-
Error Handling Improvement
- Standardize error handling approaches
- Improve error messages and logging
- Add proper exception handling
- Enhance resilience and fault tolerance
-
Documentation Updates
- Update code comments to reflect changes
- Revise API documentation if interfaces changed
- Update inline documentation and examples
- Ensure comments are accurate and helpful
-
Testing Enhancements
- Add tests for any new code paths created
- Improve existing test quality and coverage
- Remove or update obsolete tests
- Ensure tests are still meaningful and effective
-
Static Analysis
- Run linting tools to catch style and potential issues
- Use static analysis tools to identify problems
- Check for security vulnerabilities
- Verify code complexity metrics
-
Performance Verification
- Run performance benchmarks if applicable
- Compare before/after metrics
- Ensure refactoring didn't degrade performance
- Document any performance improvements
-
Integration Testing
- Run full test suite to ensure no regressions
- Test integration with dependent systems
- Verify all functionality works as expected
- Test edge cases and error scenarios
-
Code Review Preparation
- Review all changes for quality and consistency
- Ensure refactoring goals were achieved
- Prepare clear explanation of changes made
- Document benefits and rationale
-
Documentation of Changes
- Create a summary of refactoring changes
- Document any breaking changes or new patterns
- Update project documentation if needed
- Explain benefits and reasoning for future reference
-
Deployment Considerations
- Plan deployment strategy for refactored code
- Consider feature flags for gradual rollout
- Prepare rollback procedures
- Set up monitoring for the refactored components
Remember: Refactoring should preserve external behavior while improving internal structure. Always prioritize safety over speed, and maintain comprehensive test coverage throughout the process.
Files
1- refactor-code.md
6b25f38a7f4.3 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from davila7/claude-code-templates8
Execute GitHub Actions locally using act
Implement secure user authentication system with chosen method and security best practices
Generate and maintain project changelog with Keep a Changelog format
Setup comprehensive mutation testing with framework selection and CI integration
Add and configure new package to workspace with proper structure and dependencies
Setup comprehensive application performance monitoring with metrics, alerting, and observability
Implement property-based testing with framework selection and invariant identification
Add entry to project changelog following Keep a Changelog format
Related methodology skillsscan passed
Commit, push, and open a PR
Display Stripe test card numbers for various testing scenarios
Conduct a five-axis code review — correctness, readability, architecture, security, performance
Performs security-focused differential review of code changes
Conduct multi-turn deep research on a specific topic — traces actual code paths with zero tolerance for shallow analysis
Review code for Sanity best practices and common issues.