refactor-agent

Refactor code iteratively to improve readability and preserve functionality.

Updated Dec 3, 2025
One-click install
npx skills add https://github.com/Unicorn/Radium --skill refactor-agent-unicorn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-agent
Source: https://github.com/Unicorn/Radium/tree/main/skills/examples/refactor-agent
Command: npx skills add https://github.com/Unicorn/Radium --skill refactor-agent-unicorn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers and reviewers identify and remediate code quality issues by performing iterative refactoring that improves readability, reduces complexity, and preserves original functionality.

Core Features & Use Cases

  • Iterative Refactoring: Analyze code to find high-complexity functions and propose incremental changes that can be applied in loops.
  • Structure and Performance Improvements: Suggest reorganizations, extraction of helper functions, and performance-minded optimizations while keeping behavior intact.
  • Review-driven Workflow: Request feedback, incorporate review comments, and repeat refinement cycles until the desired quality is reached.
  • Use Case: Convert a single large, hard-to-read function into a set of well-named, testable helpers while documenting the changes and ensuring existing tests continue to pass.

Quick Start

Refactor the following code to improve readability, reduce complexity, and preserve all existing behavior while documenting each change.

Frequently Asked Questions about refactor-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code to improve readability without changing its original functionality?

To refactor code without changing functionality, analyze high-complexity functions and propose incremental changes like extracting helper modules or applying design patterns. This iterative approach simplifies structure while preserving behavior and documenting each modification.

What is the best way to simplify complex functions and extract modules iteratively?

Simplifying complex functions involves an iterative refactoring workflow that extracts well-named, testable helper modules. This process reduces code complexity, improves overall structure, and generates change documentation for each incremental modification.

Can I use iterative code improvement to respond to reviewer feedback across a repository?

Yes, iterative code improvement supports a review-driven workflow across single files or repositories. It requests reviewer feedback, incorporates comments, and repeats refinement cycles until the desired code quality is reached.

How do I apply design patterns and optimize performance while preserving existing behavior?

Applying design patterns and optimizing performance requires suggesting reorganizations and performance-minded improvements while keeping behavior intact. The process maintains original functionality and ensures existing tests continue to pass.

Does code refactoring work for converting a single large function into testable helpers?

Yes, code refactoring works for converting a single large, hard-to-read function into a set of well-named, testable helpers. It documents the changes and ensures existing tests continue to pass throughout the conversion.

What are the limitations of iterative refactoring for reducing code complexity?

Iterative refactoring focuses on improving readability and reducing complexity while preserving behavior. It requires existing tests to pass and relies on repeated reviewer feedback cycles, meaning it needs active integration of comments to reach desired quality.