complexity-refactoring

Extract pure helper functions from complex Python functions exceeding McCabe thresholds.

Updated Nov 11, 2025
One-click install
npx skills add https://github.com/libertininick/chain-reaction --skill complexity-refactoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: complexity-refactoring
Source: https://github.com/libertininick/chain-reaction/tree/main/.claude/skills/complexity-refactoring
Command: npx skills add https://github.com/libertininick/chain-reaction --skill complexity-refactoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers reduce cognitive load and improve maintainability by steering refactoring toward pure, return-valuing helpers instead of mutating state or writing long, complex functions.

Core Features & Use Cases

  • Enforces extraction of pure helpers that return values.
  • Guides patterns for breaking down complex logic, building collections, and isolating conditional branches.
  • Use Case: When a function grows beyond a manageable size, refactor by extracting focused helpers and composing them to form the final solution.

Quick Start

Identify a function with high McCabe complexity, extract a pure helper that computes a value, and refactor the caller to use the new helper. Then repeat for additional concerns until the codebase shows improved readability and testability.

Frequently Asked Questions about complexity-refactoring

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

FAQPage Schema
How do I refactor complex Python functions with high McCabe complexity?

Refactor complex Python functions by extracting focused, pure helper functions that return values instead of mutating state. This reduces McCabe complexity and improves overall readability.

What is the best way to break down a large function for testing?

Break down large functions by isolating conditional branches and extracting pure helpers that compute or validate data. Compose these focused helpers to form the final solution and improve testability.

Why does refactoring code into pure functions improve maintainability?

Refactoring into pure functions improves maintainability by enforcing no in-place mutations and returning values directly. This reduces cognitive load and makes code behavior predictable and easy to test.

What patterns should I use when extracting helpers to reduce code complexity?

Use patterns for extracting computation, building collections, and validating data. Ensure extracted helpers are pure functions with no in-place mutations, then refactor callers to compose these helpers.