refactor-complexity

Identify and refactor high-complexity functions into smaller units.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/TrevorPLam/agency --skill refactor-complexity
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-complexity
Source: https://github.com/TrevorPLam/agency/tree/main/.windsurf/skills/refactor-complexity
Command: npx skills add https://github.com/TrevorPLam/agency --skill refactor-complexity

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactors and decomposes overly complex functions into simpler, more maintainable units to improve readability, testability, and long-term maintainability.

Core Features & Use Cases

  • Automated identification of high-complexity functions via static analysis and code smells.
  • Refactoring strategies including extract-function, early-returns, and strategy pattern to reduce cyclomatic complexity.
  • Workflow support for planning, scaffolding tests, and creating clear refactor tasks across apps/packages.

Quick Start

Run the refactor workflow to extract complex functions into smaller units and update tests.

Frequently Asked Questions about refactor-complexity

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

FAQPage Schema
How do I refactor high-complexity functions to improve maintainability?

To refactor high-complexity functions, this Skill uses automated identification and extract-function workflows to decompose legacy code into smaller, more maintainable units without changing behavior. It applies static analysis to plan and execute the complexity reduction.

What is the best way to identify code smells in a complex legacy codebase?

Identifying code smells in a complex legacy codebase is achieved through static analysis, which automatically detects high-complexity functions across apps and packages. This process flags areas needing refactoring to reduce cyclomatic complexity.

Can I automatically scan for refactor strategies across multiple packages?

Yes, you can automatically scan for refactor strategies across multiple packages. The workflow supports planning and scaffolding tests for complex legacy functions across apps and packages, enabling strategy pattern application and safe extraction.

How do I reduce cyclomatic complexity without changing code behavior?

To reduce cyclomatic complexity without changing code behavior, the workflow applies extract-function, early-returns, and strategy pattern refactoring. It ensures safe test scaffolding is in place to avoid behavioral changes during decomposition.

Does this refactoring workflow support test scaffolding for extracted functions?

Yes, the refactoring workflow explicitly supports test scaffolding for extracted functions. It generates clear refactor tasks and scaffolds tests to ensure that decomposing complex legacy functions maintains existing behavior and improves testability.