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".

Stars 30
Forks 9

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

  1. Analyze: Understand current structure and issues
  2. Identify: Detect applicable design patterns
  3. Plan: Create incremental, safe transformations
  4. Validate: Ensure behavior preservation
  5. Test: Generate tests for refactored code

Goals

  • readability: Extract expressions, rename for clarity
  • performance: Algorithm improvements, caching
  • maintainability: SOLID principles, reduce coupling
  • testability: Dependency injection, pure functions
  • all: 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

Expand your agent's capabilities with these related and highly-rated skills.

Uniswap/ai-toolkit

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".

30 9
Explore
Uniswap/ai-toolkit

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".

30 9
Explore
Uniswap/ai-toolkit

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.

30 9
Explore
Uniswap/ai-toolkit

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.

30 9
Explore
Uniswap/ai-toolkit

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".

30 9
Explore
Uniswap/ai-toolkit

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

30 9
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results