Agent skill
refactor-code
Restructure code for improved clarity and maintainability. Use when addressing code smells or technical debt.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/refactor-code-homericintelligence-projectodyssey
SKILL.md
Refactor Code
Apply systematic refactoring techniques to improve code clarity, maintainability, and performance without changing functionality.
When to Use
- Addressing code smells identified in reviews
- Reducing cyclomatic complexity
- Extracting methods and classes
- Improving naming and organization
Quick Reference
# Common refactoring patterns
# Extract method
# BEFORE: Long function with multiple responsibilities
def process_data(data):
result = validate(data)
formatted = format_data(result)
return save(formatted)
# AFTER: Clear single responsibility
def process_data(data):
validated = _validate_and_format(data)
return save(validated)
def _validate_and_format(data):
return format_data(validate(data))
Workflow
- Identify refactoring targets: From code review or analysis tools
- Plan changes: Document what will change and why
- Apply refactoring: Use IDE refactoring tools or manual changes
- Run tests: Verify all tests still pass
- Verify performance: Check no performance regression
Output Format
Refactoring report:
- Issues addressed
- Refactoring techniques applied
- Metrics before/after (complexity, lines of code)
- Test coverage status
- Performance impact
References
- See
detect-code-smellsskill for identifying issues - See CLAUDE.md > SOLID principles for refactoring goals
- See
run-testsskill for verification
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?