Agent skill
refactor-code
Refactor code with safety checks and pattern application. Use when user says "refactor this code", "clean up this function", "simplify this logic", "extract this into a separate function", "apply the strategy pattern here", "reduce the complexity of this module", or "reorganize this file structure".
Install this agent skill to your Project
npx add-skill https://github.com/Uniswap/ai-toolkit/tree/next/packages/plugins/development-codebase-tools/skills/refactor-code
SKILL.md
Code Refactorer
Orchestrate sophisticated refactoring through multi-agent coordination with safety checks.
When to Activate
- User wants to refactor code
- Code complexity needs reduction
- Design patterns should be applied
- Technical debt cleanup needed
- Code structure improvements requested
- User mentions "clean up", "simplify", or "improve"
Refactoring Strategies
| Strategy | Risk | Use When |
|---|---|---|
| Safe (default) | Low | Production code, critical paths |
| Aggressive | Medium | Comprehensive restructuring with tests |
| Architectural | High | System-wide pattern application |
Quick Process
- Analyze: Understand current structure and issues
- Identify: Detect applicable design patterns
- Plan: Create incremental, safe transformations
- Validate: Ensure behavior preservation
- Test: Generate tests for refactored code
Goals
readability: Extract expressions, rename for clarityperformance: Algorithm improvements, cachingmaintainability: SOLID principles, reduce couplingtestability: Dependency injection, pure functionsall: Comprehensive improvement
Output Format
Provides:
- Summary with metrics and risk assessment
- Analysis of current issues and patterns
- Incremental patches with diffs
- Migration plan for architectural changes
- Validation results
Safety
- Small, reviewable patches
- Dependency ordering
- Rollback procedures
- Validation checkpoints
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
review-plan
Review implementation plans for completeness and feasibility. Use when user says "review this plan before I start", "is this implementation plan complete", "check if this plan aligns with our patterns", "give me feedback on my implementation strategy", or "validate this plan before we execute it".
plan-implementation
Create implementation plans for features and changes. Use when user says "plan how to implement user authentication", "how should I add dark mode to the app", "what's the best way to refactor the database layer", "create a plan for migrating to the new API", or "I need to implement [feature] - help me plan it out".
execute-plan
Execute implementation plans step-by-step. Use when user says "execute the plan", "implement the plan we created", "start building based on the plan", "go ahead and implement it", "proceed with the implementation", "execute as a stack", "create a PR stack while implementing", "implement with one PR per step", or references a plan file and wants to begin coding.
generate-commit-message
Generate well-structured git commit messages. Use when user says "generate commit message", "write a commit", "what should my commit message be", "create commit message for these changes", or needs help crafting conventional commit messages.
plan-swarm
Refine plans through multi-agent expert discussion. Use when user says "get multiple expert opinions on this plan", "I want different perspectives on this approach", "have the agents discuss this strategy", "refine the plan through collaborative review", or "what would different specialists think about this design".
create-pr
Create or update pull requests with conventional commits. Use when user says "create a PR for these changes", "submit this for review", "open a pull request", "push these changes and create a PR", "I'm ready to submit this work", or "create PR and link to issue
Didn't find tool you were looking for?