Refactor method complexity reduce

From github/awesome-copilot · View interactive version

Refactor method complexity reduce is an AI agent skill from the GitHub repository github/awesome-copilot. Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.

How to use this skill

Skill file

Refactor Method to Reduce Cognitive Complexity

Objective

Refactor the method ${input:methodName}, to reduce its cognitive complexity to ${input:complexityThreshold} or below, by extracting logic into focused helper methods.

Instructions

  1. Analyze the current method to identify sources of cognitive complexity:
  1. Identify extraction opportunities:
  1. Extract focused helper methods:
  1. Simplify the main method:
  1. Preserve functionality:
  1. Best practices:

Implementation Approach

Result

The refactored method should:

Testing and Validation

CRITICAL: After completing the refactoring, you MUST:

  1. Run all existing tests related to the refactored method and its surrounding functionality
  2. MANDATORY: Explicitly verify test results show "failed=0"
  1. If any tests fail (failed > 0):
  1. Verify compilation - Ensure there are no compilation errors
  2. Check cognitive complexity - Confirm the metric is at or below the target threshold of ${input:complexityThreshold}

Confirmation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.