refactoring

Apply refactoring patterns to resolve linter-detected code complexity issues.

1|Updated Nov 10, 2025
One-click install
npx skills add https://github.com/NovusAevum/dev-agents-orchestration --skill refactoring-novusaevum
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/NovusAevum/dev-agents-orchestration/tree/main/configs/claude-code/skills/refactoring
Command: npx skills add https://github.com/NovusAevum/dev-agents-orchestration --skill refactoring-novusaevum

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams reduce code complexity and improve readability by guiding linter-driven refactoring patterns. It addresses high cyclomatic and cognitive complexity, maintainability concerns, and messy functions. It provides a decision tree and concrete patterns to apply, such as storifying, type extraction, and function extraction patterns.

Core Features & Use Cases

  • Storifying (separate orchestration from leaf logic) to reduce cognitive load
  • Extract Type (convert primitives to typed domain concepts)
  • Extract Function (split long functions into focused helpers)
  • Early Returns / Switch Extraction to simplify branching
  • Decision tree guidance with references for complete patterns

Quick Start

Use this skill when a function or module triggers linter failures due to high complexity. Review the decision tree in reference.md, select an applicable pattern (Storifying, Extract Type, Extract Function, or Switch Extraction), implement the changes, and re-run the linter and tests.

Frequently Asked Questions about refactoring

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

FAQPage Schema
How do I reduce cyclomatic complexity in my code?

Cyclomatic complexity measures decision points in code. Reduce it by applying refactoring patterns like extract function to split logic, early returns to simplify branching, or switch extraction to consolidate conditionals. Linters flag high complexity; use this Skill's decision tree to select and apply the appropriate pattern.

What's the difference between storifying and extract function?

Storifying separates orchestration logic from leaf logic to reduce cognitive load in complex functions. Extract function splits a single function into smaller, focused helpers. Storifying targets coordination complexity; extract function targets length and responsibility.

How do I know which refactoring pattern to use?

Review your linter output to identify the complexity issue—cyclomatic, cognitive, or readability. The Skill provides a decision tree: use storifying for orchestration overhead, extract type for primitive-heavy parameters, extract function for long logic blocks, or switch extraction for nested conditionals.

Can I verify refactoring improved code quality?

Yes. After applying a refactoring pattern, re-run your linter to confirm complexity metrics decreased and re-run tests to ensure behavior is unchanged. The Skill implements a decision-driven workflow that includes verification with lint and tests.

What does extract type refactoring do?

Extract type converts primitive parameters and returns into typed domain concepts. Instead of passing multiple booleans or strings, create a dedicated type. This improves readability, type safety, and reduces function signature cognitive load.

When should I not refactor for complexity?

Avoid refactoring when tests are absent or brittle, since verification becomes unreliable. Prioritize test coverage first. Also defer refactoring stable, rarely-modified code unless it blocks new features or introduces maintenance risk.